Compare commits

..
455 Commits
Author SHA1 Message Date
Ulya Trofimovich b8a4cddf80 Release 4.0. 2024-11-19 07:00:21 +00:00
Ulya Trofimovich 7f26edd716 Makefile.am: avoid POSIX-incompatible pattern rules.
This is to fix building with bmake on FreeBSD.

Replace all pattern rules with POSIX-compatible suffix rules. As the latter are
much less flexible than pattern rules, this required creating copies or symlinks
with appropriate names for source files that don't fit into the naming scheme
implied by suffix rules.

Also, dependencies on custom build scripts had to be dropped, as suffix rules
don't allow additional prerequisites.
2024-11-18 22:36:14 +00:00
Ulya Trofimovich cf7e2c7639 CMake: align disabled warnings with configure.ac. 2024-11-14 10:55:48 +00:00
Ulya Trofimovich 555331f6e7 Disable Clang warning -Wexit-time-destructors.
This warns on `static const std::map<...>`.

re2c is single-threaded, so there's no risk of race conditions when one
thread is terminating and the other one tries to access the object.
2024-11-14 07:08:27 +00:00
Ulya Trofimovich efc527c2ac Fix Clang warning -Wweak-vtables. 2024-11-13 23:01:05 +00:00
Ulya Trofimovich a5e37dcb8a Fix Clang -Wshadow-uncaptured-local warning. 2024-11-13 17:38:34 +00:00
Ulya Trofimovich bce5d21288 Fix Clang -Wshadow warning. 2024-11-13 17:36:31 +00:00
Ulya Trofimovich d85f08ac1f Disable a few warnings in Bison-generated code, as we cannot fix them.
Disabled warnings are: -Wdisabled-macro-expansion and -Wused-but-marked-unused
2024-11-13 17:29:39 +00:00
Ulya Trofimovich 01b78d8db7 Fix Clang warning -Wextra-semi-stmt. 2024-11-13 17:27:03 +00:00
Ulya Trofimovich 91f265b9f3 Makefile.am: add autogenerated help sources to CLEANFILES. 2024-11-13 16:21:51 +00:00
Ulya Trofimovich 61c14ce5e5 Fix some typos in documentation. 2024-11-13 06:07:18 +00:00
Sergei Trofimovich c4e779cab5 *.ypp: use api.prefix in all bison-generated parsers
Mostly a cospetic change. I hope to get to the state when `re2c` can be
built with `-flto -Werror=odr`. Right now it fails as:

    src/parse/parser.cc:121:6: error: type 'yysymbol_kind_t' violates the C++ One Definition Rule [-Werror=odr]

This change does not fix it, but at least it clearly solits the exposed
API namespace:

    https://www.gnu.org/software/bison/manual/html_node/Multiple-Parsers.html
2024-11-11 06:03:15 +00:00
Ulya Trofimovich a2d5361545 CHANGELOG: add online playground to the list. 2024-11-07 16:26:41 +00:00
Ulya Trofimovich 0dfc64d6ff Makefile.am: fix autogenerated header paths used by make bootstrap.
This is a fix for https://github.com/skvadrik/re2c/issues/498.
2024-11-04 15:49:43 +00:00
Ulya Trofimovich 59bec481e3 Docs: add description of syntax files. 2024-11-02 16:02:32 +00:00
Ulya Trofimovich cffecf2bc5 Use C-tyle comments in .dot output regardless of the target language.
This fixes #495.
2024-10-31 16:11:45 +00:00
Ulya Trofimovich 04eb0ae86d Remove unused variables from the allowed set for code:yyrestoretag. 2024-10-30 22:45:01 +00:00
Ulya Trofimovich 2228e8f6d0 Get rid of syntax configuration code:type_cond_enum.
There's no need for it, as YYCONDTYPE can be either the name of the
enumeration, or an integer type if there is no enumeration.
2024-10-29 22:56:14 +00:00
Ulya Trofimovich d85e7e97fd Docs: add descriptions of new block types and warning. 2024-10-27 22:19:35 +00:00
Ulya Trofimovich 2bbd803796 Docs: update configurations an API descriptions. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 1a050e0eb8 Docs: update option list and descriptions. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 8571400c7f Examples: replace re2c:api = default with --api simple. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich a73bb4cddd Update configuration descriptions in the docs and CHANGELOG. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 181bfe95cc Use simplified configuration syntax in examples for Zig. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 73637f91a8 Use simplified configuration syntax in examples for V. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich d6c2a60f88 Use simplified configuration syntax in examples for Rust. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 48435b5a1b Use simplified configuration syntax in examples for Python. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 103271952c Use simplified configuration syntax in examples for OCaml. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 27e0855534 Use simplified configuration syntax in examples for JS. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich cec1803ac0 Use simplified configuration syntax in examples for Java. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 06c0ffa90d Use simplified configuration syntax in examples for Haskell. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 960cd7dee5 Use simplified configuration syntax in examples for Go. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich f3f3194a35 Use simplified configuration syntax in examples for D. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 25b3626c38 Use simplified configuration syntax in examples for C/C++. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 9218113a8e Allow dropping define: and variable: part in configurations.
These parts are used inconsistently in configuration names, e.g. we have
`re2c:tags:expression` which has to be scoped under `tags:` but it's also a
definition, so it should be scoped under `define:` (and other examples like
this). In fact, most of the string configurations are defines of some sort.

Also, change `conf:` prefix in syntax files to `re2c:`, as in
configurations. From now on, "c" in "re2c" stands not for C/C++ language,
but rather "code" or "compiler", so it's good for all languages.

Also, use prefix `.` (dot) for conditionals in syntax files to make it
easy to distinguish them from variables in code templates.

Also, fix warnings and error messages to use backtick quotes consistently.

Also, fix some comments in the code that still used the word "directive" for
special-purpose blocks.
2024-10-27 16:07:27 +00:00
Ulya Trofimovich f3ecbb16ae Docs: rearrange manual section layout.
Also, use the word "blocks" consistently instead of "directives".
2024-10-27 16:07:27 +00:00
Ulya Trofimovich fea7f92b2a CMake: factor out common helper function for docs generation. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 2c5c5003e8 Docs (help): use language-specific program name instead of "re2c".
Split help source file for all language backends.
2024-10-27 16:07:27 +00:00
Ulya Trofimovich 85f7d36227 Docs (manpage): use language-specific program name instead of "re2c".
Perform substitutions throughout the whole manual.
2024-10-27 16:07:27 +00:00
Ulya Trofimovich 77735b9f67 Docs: merge "blocks and directives" section into "syntax" section. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich d7c0cc09bc Update BUILD.md. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 2b349129eb Add manpages for new languages.
Automake: generalize generation rules for docs (make split_man.py infer
language from its second argument, as POSIX make does not seem to have a way
to pass languge name to the rule). Explicitly list all example files (provide
a `find` command to generate the list in a comment).

CMake: Add forgotten install files for re2java and re2js. Use GLOB_RECURSIVE
with CONFIGURE_DEPENDS to add examples to the list of source file.

Also, update description of submatch extraction and change captures example:
use the one without POSIX-style array `yypmatch`, as not all languages support
it (Haskell doesn't, as it has no mutable arrays in the standard library).
2024-10-27 16:07:27 +00:00
Ulya Trofimovich 2027021c1a Unify filename for Haskell example with other languages, fix run script. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 650c4bc0c2 Docs: update API descriptions. 2024-10-27 16:07:27 +00:00
Ulya Trofimovich 77eb8fbaa1 Rename files. 2024-10-27 16:07:26 +00:00
Ulya Trofimovich ff9f27c6f7 Update split_man.py for new languages. 2024-10-27 16:07:26 +00:00
Ulya Trofimovich b6803c4a88 Drafted changelog for the upcoming release. 2024-10-27 16:07:26 +00:00
Ulya Trofimovich f310f6d635 Docs: separate authors into its own RST file. Regenerate.
This is to avoid duplication of the contents on gh-pages-gen branch.
2024-10-27 16:07:26 +00:00
Ulya Trofimovich db1a4d6951 Update CONTRIBUTING.md. 2024-10-27 16:07:26 +00:00
Ulya Trofimovich c03459572b Use new configuration aliases in syntax files (for better readability). 2024-10-27 16:07:26 +00:00
Ulya Trofimovich 0936b3aa72 Rearrange the order of configurations in syntax files (cosmetic). 2024-10-27 16:07:26 +00:00
Ulya Trofimovich c641280e1c Add syntax configuration code:continue. Use labelled loops for Zig. 2024-10-27 16:07:26 +00:00
Ulya Trofimovich a543138bd1 Clean up label definitions in syntax files. Use labelled loops fpr D. 2024-10-27 16:07:26 +00:00
PolarGoose 3f0f46ff75 Fix a static analysis warning: "trie.next" is assigned with the same value 2024-10-24 20:53:42 +01:00
PolarGoose c8e8ab51dd Fix a static analysis warning: "input" file is not closed before returning 2024-10-24 20:53:42 +01:00
PolarGoose 7aba30555d Fix a static analysis warning: useless null check 2024-10-24 20:53:42 +01:00
PolarGoose 95dde201b8 Fix a static analysis warning: unusual code formatting 2024-10-24 20:53:42 +01:00
PolarGoose 10bd44025e Fix a static analysis warning: "oneline" is always true 2024-10-24 20:53:42 +01:00
Ulya Trofimovich 5c84dfc5aa Use spaces instead of tabs for Rust. 2024-09-23 16:20:09 +01:00
Ulya Trofimovich ddb1add809 Use spaces instead of tabs for OCaml. 2024-09-23 16:15:31 +01:00
Ulya Trofimovich dfae2f2361 Use spaces instead of tabs for D. 2024-09-23 16:11:44 +01:00
Ulya Trofimovich 08ce33838b Rename char_or_hex to char-or-hex to align with other option values. 2024-09-23 16:02:07 +01:00
Ulya Trofimovich 409dcabf7d Add bitmaps support (Haskell backend).
Also, mark some incorrect but unused syntax definitions as undefined.
2024-09-21 17:20:10 +01:00
Ulya Trofimovich da97854a4a Use code:array_global instead of code:array_local in rec/func mode. 2024-09-21 17:16:01 +01:00
Ulya Trofimovich eac735f66d Add bitmaps support (OCaml backend). 2024-09-20 16:05:20 +01:00
Ulya Trofimovich 5a4afb1bfb Add syntax configurations code:yybm_filter, code:yybm_match.
Remove syntax configurations `code:bit_and`, `implicit_bool_conversion`
as they are no longer needed. Strictly speaking, `code:bit_and` was also
used in generation of computed goto, but it's fine to hardcode `&` for
now, as computed goto are only implemented in C/C+. Later they will be
reimplemented using a syntax configuration similar to the bitmap ones.
2024-09-19 22:31:35 +01:00
Ulya Trofimovich 5830f0387e Use CodeGoIfL (linear IF) for bitmap transition.
This unifies bitmap transition with other transitions that are constructed
during the analyze phase and removes the need for special handling during
the generate phase.
2024-09-16 15:49:32 +01:00
Ulya Trofimovich da5e4c947c Move bitmap initialization to analyze phase.
This commit splits table initialization (populating it with values) and code
generation for the initialized table. The former is moved to analyze phase, and
the latter remains in the generate phase.

Bitmap values are needed when generating preconditions for bitmap transitions.
Currently this is done during generate phase, but there is a plan to move it to
analyse phase so that bitmap transitions could be generated using the same code
primitives as other transitions (linear IF).
2024-09-15 21:56:00 +01:00
Ulya Trofimovich 4103ae3737 Replace CodeOp with a string generated during the analyze phase. 2024-09-15 21:56:00 +01:00
Ulya Trofimovich e045138660 Match IF with ELSE when generating bitmap transition in rec/func mode.
Some functional languages like OCaml require that IF statement has an ELSE part.
This requirement may be relaxed if the statement under IF returns void, but this
is not necessarily the case in re2c-generated code (it depends on how the user
defines YYFN: they may choose it to be a void or non-void function). Besides,
other functional languages like Haskell do not have this relaxation.
2024-09-10 15:08:34 +01:00
Ulya Trofimovich 0d25d42c03 Fail with a comprehensible error if bitmaps are used in rec/func mode. 2024-08-26 06:54:36 +01:00
Ulya Trofimovich a0c1968ede Add bitmaps support (Zig backend). 2024-08-25 16:12:49 +01:00
Ulya Trofimovich 8c3d145276 Add bitmaps support (Python backend). 2024-08-25 06:56:28 +01:00
Ulya Trofimovich 4bcbd2a60a Add bitmaps support (JS backend). 2024-08-25 06:40:44 +01:00
Ulya Trofimovich 1d8320afe2 Add bitmaps support (Java backend). 2024-08-25 06:40:29 +01:00
Ulya Trofimovich 319da16127 Add bitmaps support (Rust backend). 2024-08-25 06:39:36 +01:00
Ulya Trofimovich d885f95f23 Use configuration code:array_elem for bitmap elements. Add cast if needed. 2024-08-24 07:47:23 +01:00
Ulya Trofimovich e4566bc7ce Add syntax configuration code:bit_and and use it for bitmap checks. 2024-08-23 06:40:16 +01:00
Ulya Trofimovich 0f79acd852 Generalize comparison operations to binary operations in codegen. 2024-08-23 06:39:56 +01:00
Ulya Trofimovich 98f2a41393 Allow tags on transitions with --eager-skip, if tags are identical.
The added test works correctly both before and after this change, however
it shows incorrect behavior if tags are not checked for equivalence at all
(in that case some URI fragments are missing in the test output).
2024-08-20 16:46:21 +01:00
Ulya Trofimovich 11b400ac0e Rewrite code that creates bitmap transition to use CodeJump. 2024-08-20 10:23:33 +01:00
Ulya Trofimovich 377758aa1e Allow bitmap optimization with --eager-skip.
Limit it to the cases when there is YYSKIP on both transitions or neither.
2024-08-19 07:07:24 +01:00
Ulya Trofimovich 399be1f9df Add syntax file features "tags", "captures", "captvars".
Also add an unsupported feature test for "captures" in Haskell.
2024-08-15 16:47:46 +01:00
Ulya Trofimovich 205ad4e098 Use let keyword instead of var in JS syntax file and examples. 2024-08-15 16:10:51 +01:00
Ulya Trofimovich 223dbc9599 Add directives svars and mvars.
These directives allow the user to simplify declaration of tags variables,
which is especially useful when the variables are for capturing paretheses.

Also, adjust commnets in submatch examples.
2024-08-15 16:10:51 +01:00
Ulya Trofimovich aca50bb123 Rename POSIX submatch examples, add examples for captures with variables. 2024-08-15 16:10:51 +01:00
Ulya Trofimovich d539bc3da2 Save boolean configuration value in a field.
Previously it was recomputed from the numeric value every time. Although
the recomputation was trivial (comparing against zero), it made the code
more verbose and less readable.
2024-08-12 07:12:04 +01:00
Ulya Trofimovich 5fc38030e1 Add capturing groups with variables instead of array.
This commit adds the following options and the corresponding configurations:
    --captures (alias for existing --leftmost-captures)
    --leftmost-captvars, --captvars (alias for --leftmost-captvars)
    --posix-captvars

Variables are named `yytl<n>` and `yytr<n>` for the left and right
parentheses of n-th capturing group.
2024-08-11 16:36:21 +01:00
Ulya Trofimovich 6246dbde8f Print undefined configuration name in the stub to make debugging easier. 2024-08-10 13:31:10 +01:00
Ulya Trofimovich d360fb41e8 Add missing Haskell test for unsupported case ranges. 2024-08-09 06:56:42 +01:00
Ulya Trofimovich 87a031fc85 Turn on some warnings by default.
Warnings like -Wundefined-control-flow should be on by default, as they report
severe issues with the code that should be fixed. If the user wants to suppress
such warnings, they will have to do it explicitly on the command-line.
2024-08-08 16:08:47 +01:00
Ulya Trofimovich 497fedc5c9 Remove configuration standalone_single_quotes.
The only purpose of this configuration was to make the lexer fail on standalone
single quotes for languages that do not allow them. Removing it does not affect
how the lexer works: it still attempts to lex single quote as the beginning of a
char literal and looks for a matching closing quote. The only thing changed is
that now the lexer does not raise an error on standalone single quotes for
languages that do not allow them; it simply ignores them in the same way it does
for languages that do allow them (e.g. identifiers in Haskell/OCaml, numbers in
C++, labels/lifetimes in Rust, etc.). This goes along with the general re2c
behaviour: it does not attempt to parse any languge - it only does the bare
minimum of work needed to parse re2c blocks correctly.

This takes care of bug #482 "Handle single quotes correctly in the lexer".
2024-08-07 15:16:02 +01:00
Ulya Trofimovich a3f619e6ab Handle Vlang backtick-quoted strings correctly. 2024-08-07 14:43:02 +01:00
Ulya Trofimovich e256f5012e Add syntax configuration single_quoted_strings and set it for Python. 2024-08-07 14:43:02 +01:00
Ulya Trofimovich ed0f2124ff Set standalone_single_quotes configuration for C. Add some tests.
The lexer does not attempt to lex all lexemes that may contain a standalone
single quote - those would differ a lot for different languages. Instead, it
tries to lex paired single quotes (character literals) which are similar enough
in different languages to allow a single generic lexer rule. If this attempt
fails, lexer checks if standalone single quotes are allowed (if yes, it just
skips the single quote and resumes lexing; if not, it fails with a syntax
error). This way lexer doesn't need to know about different types of lexemes
that may contain a standalone single quote.
2024-08-06 06:45:07 +01:00
Ulya Trofimovich 1b5ae59fa5 Set backtick_quoted_strings configuration for languages that need it. 2024-08-06 06:45:07 +01:00
Ulya Trofimovich ffb70cfa47 Add option --lang none to inhibit loading any default syntax file. 2024-08-05 15:30:54 +01:00
Ulya Trofimovich 675e94eaf7 Search for syntax files relative to the current directory.
Paths relative to the current directory should work without any additional
include paths.
2024-08-05 06:21:28 +01:00
Ulya Trofimovich 82e91b6646 Rename supported features to match configuration names. 2024-08-03 22:13:35 +01:00
Ulya Trofimovich 2d773639be Allow setting immutable configurations in syntax files.
This fixes a problem with libre2c introduced by the previous commit
8e9bfda737 which required that all code options
are defined (non-null). The problem was caused by testing if `line_dirs` option
is defined: the test happened in the code that is shared with libre2c, while
normally such tests happen in the code that is not shared. This commit moves
`line_dirs` initialization to config files, so the faulty test is removed
entirely.

It also changes the way that implied imuutable options are set: former
`set_default_*` functions that soft-set an option (mark it as not user-defined)
are replaced with `set_*` functions that hard-set the option (mark it as
user-defined). It shouldn't matter for immutable options, as they cannot be
redefined by the user.

an option  only set an option specified in a syntax
file if it's not explicitly defined by the user. No tests have changed.
2024-08-03 22:07:36 +01:00
Ulya Trofimovich 8e9bfda737 Don't crash on undefined configurations. Give a warning.
This commit adds a new warning: -Wundefined-syntax-config. It is not an
error, so that old syntax files stay valid as new syntax configurations
are added. Warnings allow the user notice that new configurations are
available and it's time to update their syntax file.
2024-08-01 22:45:59 +01:00
Ulya Trofimovich 1fb357c20f Make yych:conversion language-specific. Add tests.
Not all languages support `yych:conversion` (this commit adds support
for it in C/C++, D, Go, Rust and Zig backends). Conversion is only
useful for backends that implement simple/record API and have a type
system strict enough to prevent implicit conversion.
2024-07-30 22:04:35 +01:00
Ulya Trofimovich 0efd012137 Rename "default" API to "simple", and "custom" to "generic".
Keep old options and configurations for backwards compatibility.

Update all examples to use the new configurations.
2024-07-29 16:38:46 +01:00
Ulya Trofimovich 9714371ecb Unify syntax file definitions for code:yy{g,s}et{accept,cond,state}.
Add some comments for C, where we cannot provide useful defaults for
code:yy{g,s}et{cond,state} without breaking backward compatibility.
2024-07-28 22:18:42 +01:00
Ulya Trofimovich 67e2f080b0 Don't reset yycond variable based on code model.
The reset code wa added by mistake.
2024-07-28 22:14:57 +01:00
Ulya Trofimovich c76135cd6b Add syntax configurations for relational operators.
The following configurations were added:

    code:cmp_eq
    code:cmp_ne
    code:cmp_lt
    code:cmp_gt
    code:cmp_le
    code:cmp_ge
2024-07-28 07:05:48 +01:00
Ulya Trofimovich 7fd5ec66fb Don't set file pointers past the end of include file.
Don't adjust file start/end pointers in cases when we reached the end of
the include file when reading from it, as YYLIMIT may point outside of
the portion of the input buffer occupied by this file. It may happen if
the previous `read()` invocation drained this file, then read some data
from the parent file (the one that contains include directive), and then
YYFILL got triggered while YYCURSOR was still in this file, so this file
could not be popped off the stack yet.

The error was rare - I found it by a lucky accident when the buffer got
resized to a certain size due to a change in syntax file. This triggered
YYFILL in the right moment (in encodings/unicode_identifier.re example).
2024-07-27 06:43:47 +01:00
Ulya Trofimovich 29d5c87957 Update GitHub Actions config and CMake presets for new languages. 2024-07-24 22:34:52 +01:00
Ulya Trofimovich e7de8841fd Rename a few more syntax file variables. 2024-07-24 18:02:34 +01:00
Ulya Trofimovich da8d553052 Rename syntax file variables to match API names. 2024-07-23 23:04:27 +01:00
Ulya Trofimovich 1f644a0438 Provide default YYCTYPE definition for OCaml. 2024-07-22 22:54:52 +01:00
Ulya Trofimovich 02a133fba1 Provide default YYCTYPE definition for V. 2024-07-22 22:30:43 +01:00
Ulya Trofimovich 13249489b2 Provide default YYCTYPE definition for Zig. 2024-07-22 22:30:43 +01:00
Ulya Trofimovich fff50f785f Update example run scripts to use language-specific program name.
They were broken by commit 7dfe119353.
2024-07-22 22:30:43 +01:00
Ulya Trofimovich 39f1becb62 Adjust comments in examples. 2024-07-22 15:39:01 +01:00
Ulya Trofimovich b609e814b3 Add some forgotten Zig tests. 2024-07-22 10:28:20 +01:00
Ulya Trofimovich 7dfe119353 Make program name in the fingerprint comment language-specific.
Use re2c for C/C++, re2hs for Haskell, etc.
2024-07-22 10:25:34 +01:00
Ulya Trofimovich bf61e090d3 Always apply default syntax file, but allow overriding it.
This way the user may provide a syntax file with only a few overrides
instead of copy-pasting default definitions for all configurations.

As an example, add a test for the Haskell backend that pretends to be a
test for the Python backend, but overrides default Python config with
Haskell config. We don't use default C config in this case as it
defines a few optional configurations for oneline switch cases/ifs that
are not overridden by the Haskell config. The generated code is
identical to examples/haskell/01_basic.re.

Also, remove a stale TODO comment.
2024-07-22 06:49:29 +01:00
Ulya Trofimovich f06c17ef32 Add configuration tags:negative for the negative tag constant.
This should be configurable, as in some languages type system is strict
and defaulting to any particular constant means that tags must have the
type of this constant (and by extension cursor, marker, ctxmarker and
limit). It would still be possible to override them, but it would
require using generic API and providing definitions for all primitives.

In generic API `tags:negative` defaults to the tag variable that is set
to the negative tag value (substituited by re2c). We keep this behaviour
for backwards compatibility.
2024-07-21 07:01:28 +01:00
Ulya Trofimovich f2395c2998 Allow raw digits in regular expressions in Flex mode.
This fixes bug #483 "handling digits in flex mode".
2024-07-19 22:37:17 +01:00
Ulya Trofimovich d4df07f7ce Use flex-style block start/end markers for Zig examples. 2024-07-19 16:51:51 +01:00
Ulya Trofimovich 1c27fd45d4 Use flex-style block start/end markers for OCaml examples. 2024-07-19 16:51:51 +01:00
Ulya Trofimovich 940349f50a Use flex-style block start/end markers for Haskell examples. 2024-07-19 16:51:51 +01:00
Ulya Trofimovich a5e547794e Use flex-style block start/end markers for Python examples.
Also, add a missing directive in one of examples and remove a few
useless semicolons.
2024-07-19 16:51:51 +01:00
Ulya Trofimovich dd7a7a2044 Add flex-style braces for all directives / block openings.
Also, slightly change parser rules for `%{`: instead of requiring that
it is on a new line (possibly preceded by whitespace), allow arbitrary
text before it on the same line, but require a newline immediately after
it. This simplifies parser rules, and it should be good enough to avoid
parsing `%{` occurrences in the middle of a string or comment by mistake
in most of the cases.
2024-07-19 16:51:51 +01:00
Ulya Trofimovich d3f727cd8c Add basic support for Zig (no documentation). 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 11075509c6 Add basic support for JavaScript (no documentation). 2024-07-16 06:55:26 +01:00
Ulya Trofimovich ba9cfabc49 Add basic support for Java (no documentation). 2024-07-16 06:55:26 +01:00
Ulya Trofimovich f6c7f3a8e3 Fix extenstion in python example run script. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich d3b83eb329 Implement default API for V and switch examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich e64c45ba83 Implement default API for Rust, switch of the examples to it.
Note that is cannot be enabled by default due to backwards compatibility.
2024-07-16 06:55:26 +01:00
Ulya Trofimovich b2e11e1e64 Implement default API for Python and switch examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 7e924d6e9b Implement default API for Go, switch of the examples to it.
Note that is cannot be enabled by default due to backwards compatibility.
2024-07-16 06:55:26 +01:00
Ulya Trofimovich 8197f6d5b8 Check if skip/peek/backup specializations are defined before using them. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich d1732352f1 Add new API primitive YYINPUT and update all the tests/examples.
The new primitive is used for the input string (for languages that use
array / string indices rather than pointers).
2024-07-16 06:55:26 +01:00
Ulya Trofimovich 8a632a3d69 Make cursor, marker, limit, ctxmarker configurable fields in record API.
Previously their names were hardcoded in syntax files, now they delegate to
configurations `define:YYCURSOR`, `define:YYMARKER`, `define:YYLIMIT` and
`define:YYCTXMARKER`. This results in slightly longer field names, but also
more consistent with default and generic APIs.

In some cases it may be necessary to override the default names, e.g. Go
requires public struct fields to be uppercase, while private ones should be
lowercase.
2024-07-16 06:55:26 +01:00
Ulya Trofimovich 7ef8e672e2 Make accept, condition and state configurable fields in record API.
Previously their names were hardcoded in syntax files, now they delegate to
configurations `variable:yyaccept`, `variable:yycond` and `variable:yystate`.
2024-07-16 06:55:26 +01:00
Ulya Trofimovich 49c5388b2f Allow negation and logical AND / OR in syntax file conditionals. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich a33065033d Rename syntax file conditionals to avoid name collision with variables. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich fbd5a8621e Add configuration variable:cond, update tests. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 2e3a312466 Add missing example for D. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 7dddb5843a Allow newlines before and after the equals sign in configurations.
Previously only spaces were allowed.
2024-07-16 06:55:26 +01:00
Ulya Trofimovich c5493a3e4d Switch D backend to pointer API by default, fix examples and tests. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich a3c9b1963d Implement record API for D and switch some examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 77503713d3 Implement record API for V and switch some examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich a65cde175a Implement record API for Go and switch some examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich a44f902312 Implement record API for Rust and switch some examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 2cb7706148 Implement record API for Python and switch some examples to it. 2024-07-16 06:55:26 +01:00
Ulya Trofimovich 9aa7766037 Implement record API for OCaml and make it the default one. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 608910d419 Implement record API for Haskell and make it the default one. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich ab8a5f0098 Don't reset API definitions to defaults if generic/default API is not used.
With the new record API defined via syntax files, it may actually be useful to
delegate some `code:` syntax configurations to generic API primitives. It allows
one to customize the generated code for record API by redefining only a few
selected primitives.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 7df5fe0994 Add record API.
Add a new option `--api record` and a new configuration `re2c:api = record`.

Use the new record API in syntax file for C. Switch some C examples to it.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich d2a7b9320b Use code templates instead of strings for API primitives in syntax files.
Previously API definitions like YYPEEK, YYSKIP etc. were always strings, both in
syntax files and in source files. Now in syntax files they are code templates;
in particular, they should use variable `sigil` instead of substring `@@`. In
source files they are still strings: there's no need for code templates there,
and if fact it's not possible for them to become code templates, as source files
allow unquoted strings which would be mis-parsed as variables in code templates.

Using code templates in syntax files allows one to make conditional language-
specific defaults for APIs depending on mutable options, such as the current
API, API style, etc. Previously it was only possible to use immutable options as
predicates. Using variable substitution for `sigil` allows us to automatically
replace default sigil `@@` with a user-defined one.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 736f608e3e Simplify macros in option lists, add some comments. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 1d931b7a23 Clean up syntax configuration definitions.
Add "yy" prefix to configuration identifiers. Also, deduplicate
configuration identifiers and the associated strings.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 7d0e7a725f Add syntax configuration code:yylessthan. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 6b93da5c82 Rename local syntax file conditional multival -> many.
The new name is more generic, so it can be reused in other
configurations
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 066e2b7d7e Do substitutions in the API primitives regardless of the API style.
Previously sustitutions were always done in the free-form API style,
while the function style was inconsistent: for most primitives
substitutions weren't done, but for a few primitives they were done.
This doesn't matter in real life, as the function style assumes that the
primitives are function names, which cannot contain the sigil string
"@@" (unless it was redefined to some alphanumeric string by the user,
which is unlikely).
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 753ffe4622 Add syntax configurations code:yygetcond/code:yysetcond and code:yygetstate/code:yysetstate. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 07f7532567 Use RecordWildcards instead of OverloadedRecordDot in Haskell examples.
This extension results in more concise syntax and configuration
defintitons that are easier to understand.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 7c16c52239 Change the meaning of the optional 3rd component in YYFN elements.
Previously it was used to specify optional modifiers. Syntax configs for
some languages utilized modifiers for mutability annotations (Rust) or
strictness annotations (Haskell). More generally, it was used in cases
when the formal parameter syntax differs from the argument syntax.
However, modifiers were not flexible enough: they can only be added on
one side, while sometimes both left and right context is needed.

This patch makes the 3rd component mean the whole formal parameter. It's
still optional: when not specified, 3rd component defaults to the 1st
component (argument). However, if parameter syntax differs from the
argument syntax, it is now possible to specify arbitrary text in each.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 99c5a7a3a6 Use backend-specific re2c binary name when reporting generic errors.
Instead of always emitting error prefix `re2c:` emit `re2go:`  for
re2go, `re2rust:` for re2rust, etc. Note that this doesn't affect the
runtime --lang option, e.g. for `re2c --lang go` the error still starts
with `re2c:`.

No tests, as the testing script replaces all binary names with --lang.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich b53103c9d4 Break long lines with configuration strings in Haskell examples/tests. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 60ba7d8ec0 Allow configuration strings to span across multiple lines.
Long configuration strings can now be broken into parts that are
separated with spaces and newlines. Each part should be a double-quoted
string.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 74e510800a Move YYDEBUG implementation to syntax files.
As in the case of all other API primitives, YYDEBUG logic for default
or generic API should be in the syntax file for each language.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 457092c89a Add basic support for Haskell (no documentation). 2024-07-16 06:55:25 +01:00
Ulya Trofimovich cd4e9be142 Simplify syntax-based expression rendering in "generate" codegen pass.
Provide a less verbose interface for generating language-specific expressions
during "generate" codegen pass. Encapsulate some of the details in helper
methods of the `opt_t` class.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 9d5091b3e3 Add API primitives SETACCEPT/GETACCEPT and configurations code:yysetaccept/code:yygetaccept.
The new primitives and configurations allow one to override `yyaccept`
syntax for a single source file or for a given language backend.

For existing languages the new primitives have default definitions:
nothing changes in the code generation, and no new definitions are
required from the user. The change is fully backwards compatible.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 8e3f03cdb9 Add missing OCaml example of s-tags with YYFILL. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 8a51834851 Remove some examples of custom end-of-input checks, rename files.
Namely, remove examples that use end-of-input rule `$`, and leave
examples that are based on the sentinel method (as they are simpler and
demonstrate the technique well enough.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 44a091a18f Provide multival condition in configurations code:if_then_else{,_oneline}.
This condition is true when there's more than one IF branch. It is
needed for Haskell, which uses a different syntax for one-branch IF
(the `when` statement).
2024-07-16 06:55:25 +01:00
Ulya Trofimovich a12eb0f5c6 Slightly tweak OCaml example for m-tags. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich e67b1afb2e Add configurations variable:yynmatch and variable:yypmatch.
Don't generate `yynmatch` assignment in case the configuration is set
to empty string.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich b1b797a866 Move the logic that checks if a fixed tag is negative into syntax files.
This is needed because the check itself is language-specific, and also
the IF construct is problematic in some languages (e.g. in Haskell it
would be impossible to get the updated state out of the IF branch
without making the IF expression part of the YYSHIFTSTAG operation.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 7e316e1b8a Get rid of the "materialize no-match value" comment.
This is language-specific (comment syntax differs for different
languages), but adding it to syntax files seems an overkill.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 0ad6a8205c Add syntax configurations for tag operations.
The following configurations have been added:
    - code:shiftstag
    - code:shiftmtag
    - code:stagp
    - code:stagn
    - code:mtagp
    - code:mtagn
    - code:copystag
    - code:copymtag

Mark `code:shiftstag` and `code:shiftmtag` as oneline configurations
(in fact they should be named one-statement, not oneline).

Note that the user can define YYSHIFTSTAG/YYSHIFTMTAG as multi-statement
without the curly braces, and thus break the assumption re2c makes about
the generated code. But it is also the case with YYFILL (and has always
been), so we don't make the situation much worse. This requirement
should be documented, though.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 49faa46c38 Unify the way tag operations are generated with default and generic API.
Previously default API had some shortcuts, e.g. in case of fixed tags
the operations of copying base tag and subtracting offset were fused
into one. This is no longer the case.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich b27dbc9be7 Prepare YYSHIFT implementation for handling default API. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 653bb7440e Clean up code generation for tag operations. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich d1424e57bd Add missing copy operations for nested fixed tags with generic API. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 1a1ce4bf3b Slightly simplify helper functions that accept is_mtag parameter. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich a6e8bca983 Move common codegen logic out of syntax files.
Replace the complex `code:yyrestorectx` configuration that had many
conditionals with a few simple configurations `code:yyrestorectx`,
`code:yyrestoretag`, `code:yyshift`. Common language-independent logic
belongs in the re2c source code (to avoid duplicating it in each syntax
file, and also to avoid unecessarily complicating syntax files).
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 9b9d762de6 Simplify code generation for tag assignment.
Previously re2c generated assignment chains like this:

    t1 = t2 = ... = tN = YYCURSOR;

Now it generates a sequence of simple statements:

    t1 = YYCURSOR;
    t2 = YYCURSOR;
    ...
    tN = YYCURSOR;

Syntax configuration `code:assign` has been updated accordingly:
the `lhs` variable no longer needs to be a list variable.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 60b167b710 Drop support for function-like API style for all languages except C and Go.
This breaks backwards compatibility for Rust, but it was hard to use
function-like API with Rust anyway (if at all possible).
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 9415c7ab1b Add syntax configurations code:yyrestore and code:yyrestorectx.
Also, drop `code:assign_op`, as it is useless now.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 637110ada6 Add syntax configuration code:yybackupctx. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 2a4b846696 Drop configuration code:yyaccept, use generic code:assign instead. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich b0f43dec71 Add API primitives YYCOPYSTAG, YYCOPYMTAG.
For most languages they have default values (in syntax files) that never
need to be configured manually by the user. However, for languages like
haskell it is impossible to provide a reasonable default value - that's
why we need these primitives.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich fb450d3054 Revert "Rename apis YY{S,M}TAG{N,P} -> YYSET{S,M}TAG{N,P}. Keep old aliases for compatibility."
This reverts commit 8fb3d50f8d6dd8aace87631bb1a961b6e13c4536.

Reason for revert: change of plans: no need to rename these primitives
unless we add YYGET{S,M}TAG, and the latter can be avoided if we use the
3rd component of YYFN elements for arguments (as opposed to parameters).
2024-07-16 06:55:25 +01:00
Ulya Trofimovich c536ef0770 Pass boolean param instead of recomputing it in nested function calls. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 1311331e0a Replace default sigil with user-defined one in default API definitions.
E.g. if some API primitive X is defined as "...@@..." in syntax file,
and the user specifies sigil "$" instead of "@@", then default X
definition should become "...$...".

Previously this was only done for `re2c:cond:goto`, as no API primitives
have default definitions that contain sigil. But we don't really know
default API definitions, as the user may provide a custom syntax file
with custom definitions.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 0bb4569f33 Fix MTAG{N,P} defaults in syntax files. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich 73fb142345 Rename apis YY{S,G}ETCONDITION -> YY{S,G}ETCOND. Keep old aliases for compatibility. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich b4537dbed3 Rename apis YY{S,M}TAG{N,P} -> YYSET{S,M}TAG{N,P}. Keep old aliases for compatibility. 2024-07-16 06:55:25 +01:00
Ulya Trofimovich c27f521f3d Mark case_ranges feature as supported for backends that enable it by default.
Add tests for unsupported `case_ranges` feature.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 197ff08f00 Move and rename backend specific tests.
Add some trivial tests for unsupported features. Update runner scripts.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 42b50636d3 Make checks for unsupported features stricter.
Error on disabling unsupported features (previously re2c only errored
on enabling them).

Add `unsafe` and `monadic` features and tests for them.

Update tests for existing unsupported features.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich c0721980e1 Add configurations monadic and variable:yyfill.
The new configurations are needed to support monadic lexers in the
upcoming Haskell backend.

Configuration `monadic` affects control flow constructs: when it is on,
the "do" keyword is generated before nested blocks.

Configuration `variable:yyfill" allows one to decouple YYFILL invocation
from the check whether YYFILL has failed. This is needed becausse YYFILL
performs I/O (like reading from file), so it should return the updated
state of the world together with the status whether it has failed or not.
2024-07-16 06:55:25 +01:00
Ulya Trofimovich 9703f0088b Add basic support for V (no documentation). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich c5b5ed735e Add syntax option wrap_blocks_in_braces.
The new option cotrols whether to strip curly braces from semantic
actions, and whether to wrap the whole program in curly braces.
Previously this was deduced from other options, e.g. from
`indentation_sensitive` in Python. However, in some other languages this
cannot be so easily deduded (e.g. Vlang uses curly bracees in constructs
like `if`, `switch`, etc., but it rejects a compound statement wrapped
in curly braces, unless it's separated from the previous statement with
a semicolon).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 1da9c2eb64 Clean up codegen tests.
Replace many copies of examples for each language/codegen model
combination with just two tests for all auxiliary code models: a basic
one and an advanced one that covers storable states, conditions, tags,
end-of-input rule $ and `yyaccept`. Other tests are left only for C/C++
backend, as it is sufficient to have them for one backend (e.g. to test
errors specific to this codegen model).

The rationale for this change is: when new backends are added to re2c,
the amount of tests grows significantly, slowing down test run time for
no good purpose (most of the new backends are experimental). Also, it
slows down the addition of new languages (e.g. Vlang supports all three
codegen models --- goto/label, loop/switch and rec/func --- but adding
three full sets of examples for it is an overkill).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich c490dfda00 Ensure that code:abort is a one-line configuration.
Also, remove semicolon from `code:abort` definition in Rust syntax file,
so that it can be used in one-line switch-case context.

Update test results accordingly.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 47527697e7 Verify that certain syntax configurations are one-line, as expected by codegen. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 321e57917f Add syntax configuration code:goto.
This is needed to wrap `goto` in `unsafe { ... }` block for the
upcoming V backend. Currently it is used in goto/label mode for C, D and
Go backends.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 8f1f11def4 Provide initializer for yych.
It may be used in syntax file - but not necesarily. C, D and Go backends
don't use it. Rust, on the other hand, requires that all variables are
initialized.

Previously there was a hardcoded 0 constant in the syntax file for Rust.
Now the initializer is 0 or '\x00' depending on `variable:yych:literals`
configuration and the current encoding (the same condition which is used
to decide how to print YYCTYPE literals).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 8592b84deb Python backend: enable -s (nested ifs) by default.
They are usually faster than switch cases on the tests, e.g. on the
newly added test/switch_vs_ifs.re

    nested ifs took 0.17752790451049805
    switch cases took 0.6691319942474365
2024-07-16 06:55:24 +01:00
Ulya Trofimovich ff3350e51a Add basic support for Python (no documentation). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 2703a077d6 Add syntax option indentation_sensitive.
With this option, strip curly braces from semantic actions and adjust
indentation to match the rest of the generated code.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 85d8b5b560 Add checks for more features (nested ifs and bitmaps). Add tests. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich a3b9f460ca Rename cgoto syntax file feature into computed_gotos.
Configuration `re2c:cgoto` is still supported for backwards
compatibility.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 76b3938ddc Add helper methods to simplify option checks. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich a4545f966c Specialize std::hash for enum classes.
This is needed for some toolchains (e.g it fixes the build on masOS
12.7.3).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 89d1fa1767 Disable some Clang warnings globally. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 3d2c1c2c07 Fix Clang warning -Wmissing-variable-declarations. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich a84087bc02 Remove extra semicolon. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 5dc4461d04 Add missing override keyword. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 5ed9d68cda Rewrite switch case to get rid of Clang -Wimplicit-fallthrough warning.
As this case is trivial, it's easier to copy-paste the following case
than to add a portable fallthrough annotation (I'm not aware of an easy
way to do it in C++11).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich aff269bc12 Add a few missing static keywords to local functions. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 5ef3d700b2 Fix Clang warning -Wshadow. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich c8bacb2dc0 Fix Clang's warning -Wdeprecated-literal-operator. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 80030878f9 Silence Clang warnings in bison-generated code. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 07b0148337 Merge syntax.{h,cc} into opt.{h,cc} and get rid of Stx struct.
Syntax file handling is completely tied up with option handling, there's
no need to maintain separate infrastructure for syntax configurations.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 5afd992238 Rework syntax file lexer/parser and the way configurations are stored.
Put syntax configurations in a struct and make it part of the immutable
options instead of storing them in a map. This simplifies their handling
and access, as there's no need to check if a key is in the map, etc.

Merge syntax file lexer/parser into configuration lexer/parser, reuse
existing methods.

Rename list syntax configurations and define them as lists of strings in
quotes (rather than words) so that we can reuse configuration parser for
lists.

Remove separate "features" syntax configurations and replace them with a
single list  of features (to be augmented in future commits).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 283d970655 Use numbers instead of strings to handle syntax file identifiers. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 62cb5b2cdd Check that the chosen code model is supported for the given backend. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 4b149addab Go backend: fix syntax configuration for constants.
For some reason constants were previously generated as variables.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich ebbf84f9f3 Split syntax configurations for variables/constants/arrays into local and global. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich e3670059f6 Allow aliasing another code:* configuration in syntax file.
Referencing another `code:*` configuration in the middle of a definition
is not allowed (that would be hard to implement, as appending/prepending
to `StxCodes` list when using it in another configuration would alter
the original list). However, referencing another configuration as an
entire definition is ok, as it doesn't alter the existing configuration.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 04725305d2 Add configurations for YYMAXFILL and YYMAXNMATCH.
For OCaml, set defaults to `yymaxfill` and `yymaxnmatch`, as capitalized
identifiers are reserved for constructors. Update OCaml tests.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 231bc8e25a OCaml backend: render case ranges compactly for char type.
OCaml supports character ranges like 'a'..'z', but it does not support
numeric ranges like 0..9, therefore previously all ranges were rendered
in expanded form, like 'a'|'b'|'c'|...|'z'. This results in sometimes
very long lines with a lot of alternatives in match expressions.

This commit fixes it by adding a conditional into syntax file
definition. It checks if the range is of char type. If so, then the
range is rendered compactly.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 364fed920f OCaml backend: render YYCTYPE literals as chars, not integers.
One exception is the case of multibyte encoding: in that case
YYCTYPE literals are rendered as numbers (because in many languages
char type cannot hold values more than 1-byte).

Replace syntax configuration `yyctype_literals` with
`variable:yych:literals` that may have values `char`, `hex` and
`char_or_hex`.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich abf813d324 Configuration lexer: replace some functions with re2c blocks. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich c418aa1717 Add basic support for OCaml language (no documentation). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich a3deb57658 Add syntax configuration code:array_elem. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 688565f922 Add syntax configurations code:assign, code:assign_op. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich d015911fb7 Fix spurious parser error on backticks in user-defined code.
Don't give a syntax error on backticks if the language does not support
backtick-quoted strings. Instead, simply skip them and move on.

Incorrect behaviour was introduced in commit
624aa6d72059e6180bab7298128e86b5f337e07c.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 3631e7ed3a Don't try to omit tag operation for empty trailing context.
This is a very unlikely and useless case (trailing context that is
always empty), it is not worth specializing the code. In such case we
might as well generate a no-op operatio that decrements cursor by zero.
(Previously the operation was omitted, but an empty statement was still
generated.)
2024-07-16 06:55:24 +01:00
Ulya Trofimovich a664f57331 In rec/func mode, strip curly braces around semantic actions.
This is safe because each semantic action is placed into a separate
function, so there won't be any name collisions with local variables.

It is needed for language backends that don't use curly braces for
compound statements (like OCaml).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 52ce445326 run_tests.py: respect warnings set by individual tests. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 1840d22061 Add tests for --recursive-functions mode (Go backend). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 8072b3acc6 Add tests for --recursive-functions mode (Rust backend). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 751358f5cf Allow one to specify return value in function call configurations.
Add `have_retval` conditional to `code:fncall`/`code:tailcall` and
`retval` variable to `code:fncall` only (it is not needed in
`code:tailcall` as the latter returns immediately).

Also, change `code:fncall` to be a statement, like `code:tailcall`
(generate `retval = ...` if there is a return value).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich ca01df5bde Handle '\r' characters as whitespace in configuration lexer.
They may appear in newline sequences on windows.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 621f29c918 Generate comma in oneline match arms in Rust.
This was problematic because previously newline was always rendered in
oneline statements (when rendering the statement itself, without any
knowledge of the surrounding context).

Now newline is no longer considered part of the oneline statement: if
needed, it should be added in the surrounding syntactic construct (in a
syntax file).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 42fe7163cb Change YYFN format to allow type modifiers.
In some languages type modifiers go on the left of function parameters,
while the type itself is on the right (like `mut n: usize` in Rust). For
such cases, we need to allow optional third component of an argument
descriptor in YYFN. So, change its format from a list of 2*N strings to
a list of N strings with semicolon-separated parts (name, type, optional
modifiers).

Add `fn:sep` configuration to allow the users configure the separator.

Precompute function parameters and arguments, as they are common for all
function definitions / calls.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 892359a77c Add tests for --recursive-functions mode (C/C++ backend). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 2d575a3907 In rec/func mode, don't pass yych to functions that don't use it.
Some state functions don't check `yych` value because all possible
transitions go to the same destination (for any `yych` value).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 883b7008ba Don't print first letter of an option in error messages, it's confusing. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich ef86a22304 Add a helper function to generate abort statement. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich e0c1fffee6 Add configuration cond:abort (similar to state:abort).
Enable them both in rec/func mode for C, and in other modes as well for
other languages.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich b7597813e9 Initialize configuration defaults in syntax files (part 2).
Move individual configuration initialization from re2c code to syntax
configs (previously it ws done in a post-initialization fixup step, but
now there's no need for it).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 977b0a2c52 Initialize configuration defaults in syntax files (part 1).
Add defaults to syntax files. Be careful not to override user-defined
command-line options with defaults.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 46882167bc Correctly handle empty header file specified in configurations.
Previously empty header filename was concatenated with directory path,
resulting into incorrect header filepath. Change this to only prepend
directory path if the header filename is nonempty.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 8aed8322e8 Match conditionals in syntax files during parser phase.
Previously this was done after parsing, and conditionals were stored as
strings. Nuw they are converted to enum values by the parser.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 3aadda2292 Use a boolean var to determine if the lexer is lexing syntax file.
Previously this was done by comparing filepaths, however it broke on
windows as one of the filepaths was escaped (and on windows filepaths
have backslashes, so the escaped name differed from the original).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich df692885a9 GitHub Actions: add relative path to upload artifacts step (to get some artifacts on Windows).
This only works for in-tree builds, but it's usually enough to debug
Windows-only failures.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 1ad3831c4d Use maximum YYMAXFILL among all lexer files.
The same lexer state is used for all lexer files, so YYMAXFILL must be
the maximum of the individual YYMAXFILL values for each file. Previously
YYMAXFILL value for the main lexer was used everywhere, but this is
incorrect and may cause unexpected end of input errors on other lexers.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich e509ed1cc7 Rename files (configuraton lexer, main lexer and autogenerated header). 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 895c3f33fe Add configuration parser that allows conditionals.
Previously all configurations were handled by the lexer, but the
grammar for conditionals is more complex (it allows nested conditional
expressions). These will be used in syntax files to set configuration
defaults for a language based on the global options.

One part of the old lexer still remains: the lexer for string
configurations in source files. Unlike syntax files, source files may
have raw (unquoted) string configurations, which may contain special
symbols used in other parts of the grammar (e.g in the new syntax for
conditionals). Switching to the new parser would require excluding these
symbols and thus breaking backwards compatibility.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 0a8629dbf0 Fix link error in libre2c. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 71294d38f6 Add all configurations allowed in source files to syntax configs.
The added configurations are named in the same way as in source files,
except that they use prefix `conf:` rather than `re2c:`. E.g. for a
source file configuration `re2c:state:abort` the corresponding syntax
file configuration is is a `conf:state:abort`.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 2c4e48aa4b Use the same Input class for both normal lexer and syntax file lexer. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 90cc00e333 Move syntax file lexer/parser to the same subdirectory as normal lexer/parser. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich a793a3f59d Stricten the precondition for eliding fallback transition.
Check that tags and YYSKIP are the same as on transition to which the
control flow falls through if the fallback transition is elided.
(Previously the code assumed that tags and YYSKIP are the same, but it
is not obvious why it should be so.)
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 0f29e41d45 Do not elide fallback transitions in rec/func mode, except if YYFILL is disabled.
Fallback transition is part of an IF/THEN/ELSE statement. In rec/func
mode both THEN and ELSE must end in a tailcall, therefore elisiion is
forbidden (except if YYFILL is disabled, then the whole IF/THEN/ELSE can
be replaced with a tailcall to to-state).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 739c509ac6 Fix test helper script to avoid erroneously filtering out valid test. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich 891b109abf Reuse tags:expression configuration for final tags in rec/func mode.
Normally final tags are user-defined local variables in the function
that wraps the generated DFA. However, in rec/func mode each DFA state
is a separate autogenerated function, so there's no place for the user
to define local variables. Therefore in rec/func mode final tags are
part of the state that is passed from one function to another.

We could theoretically autogenerate final tag declarations before
setting them in the final states, so that they are still local
variables. This would require adding YYSTAGTYPE / YYMTAGTYPE. But what's
worse, it would't work for languages like OCaml, where variables are
immutable bindings: fixed tags with generic API require a few operations
(set, then shift). If, however, final tags are part of the state struct,
they can be updated.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich ad1d82bd26 Add syntax configuration code:yyaccept.
Also, don't reset `re2c:variable:yyaccept` to default value if storable
states are not enbled, as it may be needed in other cases as well.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 8ab63d0805 Forbid the combination of --skeleton and --recursive-functions.
It is possible to add support for skeleton in rec/func mode, but it will
take some effort as skeleton programs use a lot of local variables that
must be passed as function parameters. Disable it for now.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 17a435e953 Use first block options in getstate:re2c with a list of blocks.
If `getstate:re2c` is global (it has no explicit block list, assuming
that it covers all blocks in a file) then use global options accumulated
over the whole file. Otherwise use options of the first block listed in
the directive. For block-level labels/function always use block options.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich a522ee160f Add syntax configurations for YYPEEK, YYSKIP, YYBACKUP and combinations.
The following configurations have been added:
    `code:skip`
    `code:yybackup`
    `code:yyskip_peek`
    `code:yypeek_skip`
    `code:yyskip_backup`
    `code:yybackup_skip`
    `code:yybackup_peek`
    `code:yyskip_backup_peek`
    `code:yybackup_peek_skip`
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 7a53cb2a73 Define code:recursive_functions in default syntax files. 2024-07-16 06:55:24 +01:00
Ulya Trofimovich af618f6481 Add code:fndecl syntax configuration.
It allows one to generate forward declarations of all functions in
rec/func mode, which is needed for some languages (C/C++).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 5a341e25a9 Add code:tailcall, use it instead of code:fncall in rec/func mode.
Unlike `code:fncall` which is an expression, `code:tailcall` is a
statement with `return` (if the language needs it) and indent/newline.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich bc6c23c02f In rec/func mode, generate arguments based on YYFN configuration.
Also, tweak syntax configuration `code:recursive_functions` to assume
toplevel functions rather than closures (as most languages do not allow
co-recursive closures, and some don't have closures at all).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 163d32b6e3 Rearrange functions in a file to bring other static functions in scope.
Prepare source file for the follow-up changes (minimize the diff).
2024-07-16 06:55:24 +01:00
Ulya Trofimovich fee0446b48 Emit default case after (not before) all other cases in state switch.
In some languages (e.g. OCaml) default case is not special, and if it
comes before other cases, it always matches and makes all other cases
useless.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 63c77e8528 Add helper function to generate function calls.
Use YYFN configuration to generate user-defined arguments.
2024-07-16 06:55:24 +01:00
Ulya Trofimovich 42c93b3684 Small cleanups/comments in location tracking in lexer/parser. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich fbd146465e Add configuration re2c:define:YYFN of a new configuration type (list). 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 9a3904265f Make rec/func mode work with storable states. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 15ea590914 Make rec/func mode work with conditions. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich da4a307a96 Do not generate "if" without "else" in rec/func mode.
In functional languages both branches must have the same type, and
C-style early returns are not possible.

In goto/label and loop/switch mode early returns are still preferred,
because the "else" part is often elided.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 6b16784a25 Add prepend operation on lists. Add a unit test for list operations. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 67620440d3 Simplify append operation on lists. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich af410c7065 Simplify checks for transition elision. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich e1878caf9f In rec/func mode, don't elide transitions in "if/else-if/else" branches.
This is because in functional languages like OCaml "if/else-if/else" is
an expression where all branches must have the same type (except perhaps
for a single "if" branch that may have void type.

One exception is the case of a single branch that goes to the next state
(in that case "if/else-if/else" construct is not needed).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 01e9d8adab Avoid early return from an "if" statement in recursive functions mode.
Generate "if/else-if.../else" instead of a sequence of "if"s,
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 8013918c11 Remove unused oneline field and the wrapper struct. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich b9f9872990 Allow oneline if/else statements with condition in the "else" branch.
This is part of a general effort to unify rendering of oneline if/else
statements (either render them all on the same line without braces, or
all on a new line with braces).

Users that prefer always rendering if/else statements in braces should
be able to do so by commenting out `code:if_then_else_oneline`
configuration in the syntax file (`--syntax` option).

Note that default syntax file include/syntax/<language> (the one that is
used without `--syntax` option) is built into re2c; changing it requires
rebuilding re2c with configure option `--enable-syntax` or CMake option
`-DRE2C_REBUILD_SYNTAX=on`.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich e0ad5b1218 Allow oneline if/else statements for skeleton programs.
This is part of a general effort to unify rendering of oneline if/else
statements (either render them all on the same line without braces, or
all on a new line with braces).

Users that prefer always rendering if/else statements in braces should
be able to do so by commenting out `code:if_then_else_oneline`
configuration in the syntax file (`--syntax` option).

Note that default syntax file include/syntax/<language> (the one that is
used without `--syntax` option) is built into re2c; changing it requires
rebuilding re2c with configure option `--enable-syntax` or CMake option
`-DRE2C_REBUILD_SYNTAX=on`.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich e46f998c95 Allow oneline if/else statements for computed goto check.
(It is not used anyway, as there is always a multi-line "else" branch
that makes the whole "if-then-else" construct render as multiline.)

This is part of a general effort to unify rendering of oneline if/else
statements (either render them all on the same line without braces, or
all on a new line with braces).

Users that prefer always rendering if/else statements in braces should
be able to do so by commenting out `code:if_then_else_oneline`
configuration in the syntax file (`--syntax` option).

Note that default syntax file include/syntax/<language> (the one that is
used without `--syntax` option) is built into re2c; changing it requires
rebuilding re2c with configure option `--enable-syntax` or CMake option
`-DRE2C_REBUILD_SYNTAX=on`.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich c00ea29161 Allow oneline if/else statements for yybm check (bitmaps).
This is part of a general effort to unify rendering of oneline if/else
statements (either render them all on the same line without braces, or
all on a new line with braces).

Users that prefer always rendering if/else statements in braces should
be able to do so by commenting out `code:if_then_else_oneline`
configuration in the syntax file (`--syntax` option).

Note that default syntax file include/syntax/<language> (the one that is
used without `--syntax` option) is built into re2c; changing it requires
rebuilding re2c with configure option `--enable-syntax` or CMake option
`-DRE2C_REBUILD_SYNTAX=on`.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 271746cdbe Allow oneline if/else statements for yyaccept check.
This is part of a general effort to unify rendering of oneline if/else
statements (either render them all on the same line without braces, or
all on a new line with braces).

Users that prefer always rendering if/else statements in braces should
be able to do so by commenting out `code:if_then_else_oneline`
configuration in the syntax file (`--syntax` option).

Note that default syntax file include/syntax/<language> (the one that is
used without `--syntax` option) is built into re2c; changing it requires
rebuilding re2c with configure option `--enable-syntax` or CMake option
`-DRE2C_REBUILD_SYNTAX=on`.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 279c4e20f3 Allow oneline if/else statements for condition dispatch.
This is part of a general effort to unify rendering of oneline if/else
statements (either render them all on the same line without braces, or
all on a new line with braces).

Users that prefer always rendering if/else statements in braces should
be able to do so by commenting out `code:if_then_else_oneline`
configuration in the syntax file (`--syntax` option).

Note that default syntax file include/syntax/<language> (the one that is
used without `--syntax` option) is built into re2c; changing it requires
rebuilding re2c with configure option `--enable-syntax` or CMake option
`-DRE2C_REBUILD_SYNTAX=on`.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich e6057e22b5 Render oneline statements from else branch(es) on the same line.
Keep a few exceptions for `yyaccept` and conditional dispatch for now
(to avoid updating many tests at once).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 4e330457e7 Allow multiple else branches in syntax configurations for if-then-else. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 82577ce06d CMakeLists.txt: remove unneeded dependency for re2c_test_argsubst. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 7e43200796 Reduce the number of parameters to helper function print_char_or_hex. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich b1a7a11d28 Rename syntax configuration char_literals to yyctype_literals. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich b2701c7f4c Implement codegen model rec/func (recursive functions).
Add syntax configuration "code:recursive_functions".
2024-07-16 06:55:23 +01:00
Ulya Trofimovich c30fe1e7b7 Rename syntax file value rec_funcs to recursive_functions. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 2aaf2b329a Correctly render oneline function call statements. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 472373796c Add syntax configurations for functions: code:fndef and code:fncall.
These are currently used only for skeleton backend (which supports only
C/C++), but later they will be used for rec/func codegen model.

Split codegen for function definitions and function calls. Make it
simpler (don't try to format differently based on the length of
arguments, just output all the arguments on the same line).

Some function calls in skeleton programs are syntactically too complex
(they are part of OR expressions, or they have multiline arguments) ---
for such function calls do not use syntax configurations and fallback to
generating text. This works because skeleton supports only one language
backend.

If there is a need for more complex syntax constructs that contain
function calls in the future, it will be possible to add them as
separate syntax configurations (for that purpose `code:fncall` is an
expression, not a statement).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 62afc3674d Simplify handling of semicolon when generating function calls. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 2f6c71a38c Initial support for a new codegen model rec/func (recursive functions).
Add options --goto-label and --recursive-functions in addition to the
existing option --loop-switch.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 67f6680ce5 Track "is default" status for global options.
This is needed to correctly set defaults based on syntax file, which is
itself based on global option --lang.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 0d5fe165b3 Get rid of useless macro CONSTOPT1. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 0621b973ed Make YYDEBUG configurable in syntax file or using in-file configuration.
Add tests.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 762ced0a3c Simplify rendering of YYPEEK statement, update syntax configuration. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich d6e2ca3316 Simplify generation of YYDEBUG.
Pass `yych` instead of YYPEEK as the second argument to YYDEBUG.
Also, move YYDEBUG invocation in the initial state past YYPEEK so that
`yych` is properly set to the first symbol.

The motivation for this change is to decouple codegen for YYPEEK and
YYDEBUG statements and avoid having two syntax configurations for YYPEEK
(one for the expression that was previously used in YYDEBUG, and one for
the statement). Also, this helps in cases where YYPEEK modifies internal
lexer state, e.g. reads a character from file and moves file pointer.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 4f7ad682f5 Add basic support for D language (no documentation).
Use examples provided in https://github.com/skvadrik/re2c/pull/431
(suitably modified).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich cf1b735fdb Correctly initialize language (based on RE2C_LANG definition).
Previously re2go/re2rust/re2d binaries erroneously used syntax config
for C/C++ by default.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich a08cdec815 Generate abort in default switch case (for some languages).
Replace syntax configuration `abort_requires_include` with
`abort_in_default_case`. Enable it for Go and Rust, but not for C/C++ as
it requires an `#include` directive that must be provided by the user.

Update Go tests. Rust tests do not need updates because they use a
different codegen model (loop/switch) that has no initial switch on
conditions.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 39cfb282e9 Add syntax configuration code:enum_elem (used to render enum members). 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 7ddb79a70a Generate parentheses around & operator to clarify precedence.
This is only needed if the expression is explicitly compared to zero.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 539c99ea2a Remove language from options. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 20ff170efb Get rid of the last language check using syntax configurtion case_ranges. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 2b7945a75e Do not abort on undefined syntax configurations.
Instead, provide default values:
  - empty string for string-valued configurations
  - false for boolean-valued ones
  - no output for `code:*` configurations

Also, fix an error in libre2c initialization: it now has to manually set
the target option, as it does not load syntax file (and so the options
are not properly initialized).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 776397ccb0 Get rid of another language check using syntax configuration computed_goto 2024-07-16 06:55:23 +01:00
Ulya Trofimovich f013593448 Get rid of another language check using syntax configuration api. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 02bae836a2 Get rid of another language check using syntax configuration target. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 0872f12815 Replace another language check with syntax configuration semicolons. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich d535fee6ed Add syntax configuration code:loop_label.
This is the first example of a single string valued configuration.
Leave it in the "code" group for now (`code:...`) but add a special
`Stx`method that returns an error if the value is not a single string.
Make the default value empty string, as we don't want to specify such
configurations in syntax files for languages that don't need them.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 1ba6cdd6a5 Add syntax configurations "backtick_quoted_strings" and "standalone_single_quotes".
Use them instead of the language checks in the lexer.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich b51d2b67ab Add Stx reference to immutable (global) options.
This is needed to check syntax configurations from lexer/parser (global
options are the only options available at that point).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 06f72154ef Implement syntax configuration abort_requires_include. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 8ac61bb6d9 Forward methods that evaluate syntax configurations to opt_t.
This is to simplify calling these methods from the codegen subsystem.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 215ef38d7f Move StxFile to syntax file parser (to avoid pulling it into libre2c sources). 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 320f319faa Constify Stx struct in opt_t.
Options are passed everywhere by const pointer, as they should not be
modified anywhere in the program once they have been set for a block.
Syntax configurations also should be immutable, with the exception of
mutable stacks that are used when evaluating immutable configurations.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 8428bfa82d Move struct Stx into Opt.
The idea is to merge them: configurations in syntax files are yet
another kind of options, and they are always used together with the
usual options.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 911cfa494d Don't copy second output block options into the first block.
This was necessary to fix https://github.com/skvadrik/re2c/issues/201,
where line directives suppression was configured using configuration
`re2c:flags:no-debug-info` (the problem was that it didn't affect the
first block, and the first line directive was generated contrary to the
user's intent).

Now this workaround is no longer needed as the configuration
`re2c:flags:no-debug-info` was deprecated in re2c-2.2 and later removed.

Dropping this allows us to get rid of default copy semantics for `opt_t`
which is necessary in preparation to store `Stx` reference there
(the compiler won't generate default defintions in that case).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 91dee4a860 Specify prefix for bison-generated primitives in syntax file parser.
So that they don't collide with the main parser (potential collisions
are possible due to header includes).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich d51775c857 Fix "undefined reference" build errors in libre2c library.
Some `Stx::*` methods are now called from src/options.opt.cc, but the
source file that defines them (src/options/syntax.cc) weren't added to
the list of library sources.

The fix is to make these methods inline, as they are small and the other
alternative (to include src/options/syntax.cc) would pull in even more
unrelated source files for the definition of DEFAULT_SYNTAX_{C,GO,RUST}.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 09ffa6a3ab Move syntax* source files from src/codegen to src/options. 2024-07-16 06:55:23 +01:00
Ulya Trofimovich 2c70bf5da2 Disallow conditionals in word configuration (in syntax files).
Conditionals in syntax files were based on options, which caused a
dependency cycle: options required syntax configurations to initialize
default values, and evaluating syntax configurations required options.
Now syntax configurations do not depend on options.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich f83f3903e0 Get rid of conditionals in non-code syntax options.
The only conditional was in `char_literals` (a test for EBCDIC).
It can be as well hardcoded in the re2c source code, as there is nothing
language-specific in it.

The next step will be to simplify non-code syntax configurations and
allow only single word values or word lists (no conditionals).
2024-07-16 06:55:23 +01:00
Ulya Trofimovich c3bb892add Get rid of some language checks when initializing default options.
Use syntax file instead.
2024-07-16 06:55:23 +01:00
Ulya Trofimovich 752c499714 Simplify handling of line directives.
Commit 1d9319548bc97313426499ad7b7aa6dfdfe71ac2 added a fix-up pass that
removes line directives (if they are not needed). It turns out that this
is unnecessary, as line directives cannot be enabled/disabled with a
configuration --- only with a command-line option. This option is
available early at program start, so there's no need for a clean-up pass
as we can test the option before adding line directives.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich b684f22fd0 Add a fix-up pass that removes line directives (if they are not needed).
Line directives are generated by default for C and Go, but not for Rust
(which does not support them at all). They can be turned off/on with a
command-line option or configuration. From the codegen perspective,
there are multiple ways to avoid generating line directives:

  1) do not add them in the first place
  2) remove them during fix-up phase
  3) render them as empty during rendering phase

1 is the most efficient, but it canot be used with configuration, as the
latter may be parsed later than the directive must be generated (some of
them are generated early during parsing, at which point the block
options are not known yet).

3 is the easiest to implement, but it confuses the checks for oneline
statements and results in ugly multiline formatting and lots of trivial
test updates.

Previously we used a combination of 1 and 3: for Rust directives were
not generated (language is an immutable option which is known at program
start), and for other languages directives were generated but not
rendered.

This commit changes the behaviour to 2 and makes it uniform for all
languages. C tests for which re2c is now able to properly detect oneline
statements have been updated.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 305b0d497a Implement syntax configuration implicit_bool_conversion.
Add a function specialized for boolean-valued configurations ("yes" /
"no") and rewrite code for other configurations with it.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 0ea51ba272 Implement syntax configuration semicolons. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 994d4ae525 Implement syntax configuration char_literals.
It is the first configuration of the "word" type (all the previous ones
were "code" configurations).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 3e274664b8 Implement syntax configuration code:yypeek_expr.
Move YYDEBUG generation to the rendering phase, as it depends on
`code:yypeek_expr`.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 15a5971468 Replace configuration code:bitmap_check with implicit_conv_to_bool.
The only language-dependent syntax is the check against zero which is
emitted for Go but not for C (and Rust codegen does not support bitmaps
at all).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich f85fa16c4b Rust codegen: emit semicolon after panic.
It worked without a semicolon as well because panic was the last
statement in a block. However, this was unintentional and it may change
in the future.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 3645616065 Implement syntax configuration code:abort. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich f5f559df8b Drop unnecessary syntax configuration code:label.
Rust has an unusual syntax for labels: they have to start with a single
quote. But it is inconvenient to encode the quote in a syntax config ---
it's easier to encode it in the name, since the only kind of label used
in Rust is the yyloop label (which has a string name that is configured
with `re2c:label:yyloop` that can easily encode the quote as well).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich bb0bfa189f Implement code:const syntax configuration.
Reuse code item for `code:var` configuration.

Change Go codegen to assume that YYMAXFILL and YYMAXNMATCH are unsigned
and update test results accordingly. (Other codegens already assume that
YYMAXFILL and YYMAXNMATCH are unsigned).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich a65d0ad67b Don't copy options string when creating code items.
Options lifetime covers codegen, and they are not moved.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 9e0cf884bb Use internal scratchbuf stream instead of creating a temporary one. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich a5531ecd7b Use a fake filename for default syntax file (rather than empty string).
This makes error reporting less confusing (in the unlikely case there is
an error in the default syntax file).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 7f40ae1780 Implement code:line_info syntax configuration. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich bdc040e986 Parse escape sequences in string literals in syntax files. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 4812be8b9f Implement syntax configuration code:fingerprint. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich f143b2dc1c Make code:enum configuration more generic.
Namely:
  - add `have_init` conditional instead of using `jumps.loop_switch`
  - add `type` variable instead of using `storable_state` conditional
    and `code:type_cond_enum` configuration for the underlying type

These changes make `code:enum` more generic and usable not only for the
specific case of condition enum, but for any enum (although it's not
needed at the moment, as condition enum is the only use).

Remove obsolete `GenEnum` class.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich af3c3ca319 Rename OutptuCallback to RenderCallback.
All syntax file base codegen has been moved to rendering phase.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 88e2223326 Render list variable "row" in code:array configuration.
Although it generates no code, it should not cause an abort.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 8a219d3d7b Move language-dependent enum code generation to the rendering phase.
The goal is to do all language-specific codegen during rendering phase
(based on the provided language syntax file).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich ce8f4a7b5b Rename syntax handlers to match code:array configuration. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 0bb7705981 Add a function for evaluating syntax configurations without variables. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 872d601c42 Implement syntax configuration code:type_yytarget. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich e027b25abd Implement syntax configuration code:type_yybm. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 0bd9783532 Rename syntax configuration code:const_array to code:array.
Don't add `static const` type qualifiers in the C syntax file. Instead,
add them as part of the type specified in the re2c source code. This
will be fixed later, as the type should not be hardcoded based on the
language (it will become a config in the syntax file).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 5f90615f63 Implement syntax configuration code:const_array.
Update syntax files for C and Go.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich cac96326a3 Constify yytarget array in the generated code for C.
It was meant to be constant from the beginning, so the missing `const`
was probably an omission.

Also, generate explicit array size for Go.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 5f8b5a443b Move table codegen from "generate" phase to "render" phase.
Prepare for rendering tables using syntax configuration.

Update test results. There is a lot of changes, but they are trivial:
  - drop optional comma at the end of array initializer for C
  - change formatting: `void *` to `void* `
  - add explicit array size in array definitions
2024-07-16 06:55:22 +01:00
Ulya Trofimovich a9988c4e46 Implement syntax handlers for variable definitions.
Update syntax files for C/Go/Rust accordingly. Remove unnecessary
syntax configuration `code:yyctype`, as it is already configurable
via `re2c:define:YYCTYPE`.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 03d110f45d Delete uselsess syntax configuration label_indent.
This was mean to be used with `code_loop` for languages that have a
label preceding a loop, so that re2c would know whether to indent the
label or not (the default assumption being to indent everything).
However, now that we use explicit `topindent` variable everywhere,
there's no need for `label_indent`.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich e5a0fe4880 Implement syntax handlers for for-loop statements.
Update syntax files for C/Go/Rust accordingly.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich fd26a6e16b Move duplicate code that finds list bounds into a separate function. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich d3ffadb7bf Cache tests for specific syntax configurations in the Stx class. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 9b3c4e3af9 Make configurations map in the Stx class private. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 0aba0ed97c Implement syntax handlers for if-then-else statements.
And update syntax files for C/Go/Rust accordingly.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich cffdfd3e87 Split syntax configurations code:switch_cases and code:switch_cases_oneline.
This is so that syntax files for languages that don't need special
handling for oneline statements (like Go) do not have to handle
`oneline` conditional (which may be confusing and unexpected).
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 90142297ff Implement syntax handlers for switch statements.
Also, update syntax files for C/Go/Rust accordingly.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 9ccd146f79 Fix stack usage during nested calls to Stx::gen_code.
Previously stack was cleared at the beginning of a call, but this wipes
out the state for the outer call.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 94db280d2b Fix check for vars in syntax files.
Previously list vars were erroneously looked up among simple vars as
well (in case they haven't been found among list vars,)
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 88d33f439a Simplify codegen handling of lists in syntax files.
List bounds need to be evaluated at codegen time (not earlier), because
the indices specified in syntax file may be negative and must be
converted to non-negative (the size of a list varies and is not known
until codegen time). To avoid duplicating the same code for every list
handler, this commit moves it to the generic function that renders
syntax trees.

Also, add `eval_cond` method to evaluate conditionals in syntax files
and fix the generic `eval_cond` method to respect configuration-local
conditionals.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 48b05810c3 Use embedded syntax files if no --syntax option has been provided.
This allows one to run re2c/re2go/re2rust without --syntax option and
get the same behaviour as before.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich d4c186b642 Embed default syntax files for all three languages into each binary.
Previously re2c was built with syntax file for C, re2go with that for Go
and re2rust with that for Rust. However each binary needs all three
configs, as the language may be changed dynamically with --lang option.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 1bbcf89767 CMakeLists.txt: add a way to embed syntax files into re2c binary and update them.
Add CMake option RE2C_REBUILD_SYNTAX.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 6f6c0fba7b Makefile.am: add a way to embed syntax files into re2c binary and update them.
Add configure option --enable-syntax.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich be6f7e2a23 Makefile.am, CMakeLists.txt: add syntax files to distribution. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 074250e210 Update CMakeLists.txt with the recently added code for syntax files. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 97fa5ad3e9 Generate code for condition enum based on syntax configuration.
It is the first codegen function that is based on syntax configuration.
The chosen configuration is generic enough: it has lists with specific
bounds, conditionals, global and local variables.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 41c563c50b Update syntax files for C/Go/Rust. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 1ebe649de8 Update the list of allowed syntax configurations and conditionals.
Also, fix associated checks.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 2fb4f360a3 Update syntax file parser for new configuration format.
Code configuration names now start with `code:`, other configurations
can be either lists or conditional expressions.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 66e08da942 Slightly change list syntax in syntax files, improve variable checks. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 8c24b9a09f Add a list of syntax configurations, improve validation of syntax files. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich ca2e0ce183 Slightly reformat option definitions (cosmetic, no functional changes). 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 0cdd39e79c Validate conditionals and variable names in syntax configs. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 3885b0da1b Fix switch statement definitions in syntax configs for C/Go/Rust. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 4a05f11eb6 Store syntax configurations in a map instead of a list. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 1dcbfee713 Merge util/list.h into util/containers.h. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich eebdfddb57 Rename SyntaxConfig into StxFile to unify with other names. 2024-07-16 06:55:22 +01:00
Ulya Trofimovich 1b878f6682 Construct AST for syntax files.
The AST is not used yet, it is only created and discarded.

Also, move list template to a separate file to reuse the existing
definition from codegen.
2024-07-16 06:55:22 +01:00
Ulya Trofimovich 0f27e43f24 Fix syntax file grammar to parse boolean right-hand-side correctly.
Previously it was parsed as part of complex expressions, which should
not be allowed by the grammar as it makes it too lax and introduces
meaningless constructs.

Also, remove parenthesized expressions other than conditionals, as they
aere not used (they also caused LR conflicts in grammar).
2024-07-16 06:55:21 +01:00
Ulya Trofimovich b30bccb4d3 Parse numbers and strings in syntax configs correctly. Use allocator. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 80e6339242 Remove unused function. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 045752dc73 Track line/column information for error reporting in syntax configs. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 4e955f25aa Reuse message class for error reporting in syntax config parser. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 8cc3315138 Add class that encapsulates parsing details for syntax config files. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 5acb29fea4 Remove unused and unimplemented method prototype. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 30fa370ee1 Implement basic lexer/parser for syntax files.
Currently it can parse C, Go and Rust configs without errors, but it
does not build AST yet (parse results are discarded).
2024-07-16 06:55:21 +01:00
Ulya Trofimovich c9c3dc699e Read syntax file contents into a buffer. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 652f7e3a6d Add initial parser for syntax files (can't parse anything yet). 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 1f5ec6cad7 Add initial lexer for syntax files (can't lex anything yet). 2024-07-16 06:55:21 +01:00
Ulya Trofimovich a760f723e7 Add option --syntax that accepts a path to a syntax file. 2024-07-16 06:55:21 +01:00
Ulya Trofimovich 4fbf0847dc Initial syntax files for C, Go and Rust. 2024-07-16 06:55:21 +01:00
D.musique 6841306953 Flag to make python optional as build dependency
Only require the python dependency when docs, tests or benchmarks are requested.
This makes packaging simpler in some cases (eg. vcpkg).
2024-06-14 18:26:58 +01:00
Peter Kokot 671fc0bc08 Use Python version in find_package()
This simplifies the find_package() call. The version in find_package()
has been initially supported in CMake 2 and 3. Version ranges
(versionMin...[<]versionMax), on the other hand, are only supported by
CMake 3.19+.

And this also helps a bit when adding re2c as a FetchContent dependency
in CMake project where finding Python is not necessary and can be
disabled with CMAKE_DISABLE_FIND_PACKAGE_Python3 variable.
2024-04-24 08:57:30 +01:00
Stephen Wassell 75fa3dbef8 Correct definition of stub CLOSE macro 2024-03-04 21:47:53 +00:00
Ulya Trofimovich 08d414b8b2 Fix undefined behaviour in Rust examples.
This addresses bug https://github.com/skvadrik/re2c/issues/471
"Examples in re2rust manual have undefined behavior".

In Rust, it is UB to call `get_unchecked` on a slice that may be empty,
and many examples had functions that did just that (when invoked on
incorrect input data, since they use some form of sentinel method to
handle the end of input, which relies on the input being sentinel-
terminated).

The introductory example has been fixed to avoid UB and use simple
indexing with bounds checks instead of `get_unchecked`. Other examples
that had UB are now annotated with `assert` that checks conditions under
which the functions are safe to invoke.

Also, eof/02_bounds_checks.re example now uses a more efficient way to
construct YYMAXFILL-padded input string.
2024-02-26 12:53:19 +00:00
Sergei Trofimovich 0fe50b3165 IDEAS.md: fix typo s/inforamtion/information/ 2024-02-26 07:11:34 +00:00
Ivan Egorov 15f503c97f [bazel] Fix _re2c_impl
Mainly `[err_file]` is an undefined variable.

Probably some tl&c would be worth it, converting to bazel module,
but that's for another day.
2024-02-22 17:20:19 +00:00
Sergei Trofimovich 9885ee7119 .github/workflows/ci-cmake.yml: avoid pwd and use ${{ github.workspace }}
It loks like at least in `windows` `actions/upload-artifact@v4` CI step
fails to collect files at `${{ steps.build-info.outputs.BUILD_DIR }}/test_[0-9]*`

My theory is that `glob` is not able to match paths like

    `D:/a/re2c/re2c/install-2`

against theit unix-like form of

    `/d/a/re2c/re2c/install-2`

I suspect that `pwd` returns us the second form while
`${{ github.workspace }}` might keep an original form.
2024-01-31 21:47:43 +00:00
Ulya Trofimovich 1655c7f9a3 GitHub Actions: update versions of dependency actions. 2024-01-31 10:43:56 +00:00
Sergei Trofimovich 1630149d14 .github/dependabot.yml: add basic plumbing to auto-update used actions 2024-01-31 10:40:18 +00:00
Ulya Trofimovich bfa77bc471 Rewrite lexer of string/char literals in code blocks.
Lex char literals properly as single characters or escape sequences
rather than lexing them as single-quoted strings. Add syntax rules from
C/C++, Go and Rust (they are similar and do not contradict).

Add a Go test for string and character literals (prior to this patch it
caused a syntax error).

Note that the same lexer method is used for indented code blocks and
code blocks in curly braces.
2023-12-16 14:52:54 +00:00
Ulya Trofimovich 0ea38276d5 Wrap lexer body in braces only if there're local variable declarations.
This is a revert of commit 77714fce94.

While it is easier to always generate braces, in some languages (Go) it
is a compilation error to jump into the wrapped block (a scenario that
happens if there is an outer state switch generated with `getstate:re2c`
directive.

This regression was found because one of the examples for Go didn't
compile (examples/state/push.go). Now it does.
2023-12-06 21:51:35 +00:00
Ulya Trofimovich 22721f0b0e release.sh: check that examples work. 2023-12-06 21:45:34 +00:00
Ulya Trofimovich 0b6d0b510e CMake: set C++17 standard for benchmarks that use re2. 2023-07-25 07:10:51 +01:00
Ulya Trofimovich 96104a6526 CMakeLists.txt: make C++11 standard required (not optional).
This fixes https://github.com/skvadrik/re2c/issues/455 "Test for C++11
compiler at configure time".
2023-07-21 22:29:45 +01:00
Ulya Trofimovich 59c56044b9 configure.ac: make C++ compiler flag -std=c++11 required (not optional).
This fixes https://github.com/skvadrik/re2c/issues/455 "Test for C++11
compiler at configure time".
2023-07-21 22:15:34 +01:00
Ulya Trofimovich 3841e83f85 Makefile.am: add missing files to distribution.
This fixes https://github.com/skvadrik/re2c/issues/454 "BUILD.md not
present in tarball".
2023-07-21 21:42:54 +01:00
Ulya Trofimovich 7d6641778c BUILD.md: document C++11 requirement.
This fixes https://github.com/skvadrik/re2c/issues/453 "Document C++11
compiler requirement in BUILD.md".
2023-07-21 21:32:51 +01:00
Ulya Trofimovich ece4bb76e3 Release 3.1. 2023-07-19 22:50:22 +01:00
Ulya Trofimovich c3f267b248 release.sh: make the script NixOS-friendly, fix quoting in echo command. 2023-07-19 22:42:25 +01:00
Ulya Trofimovich 60b40d94bd Makefile.lib.am: remove nonexistent header from the list. 2023-07-19 21:47:14 +01:00
Ulya Trofimovich 5abc35226b Update CHANGELOG. 2023-07-18 22:56:45 +01:00
Ulya Trofimovich e868cc58b9 Document configure option --enable-parsers in BUILD.md. 2023-07-13 23:22:55 +01:00
Ulya Trofimovich c633d5de3e Update documentation for capturing and non-capturing groups.
Document the following options:
    --leftomost-captures
    --invert-captures

And the following configurations:
    re2c:leftmost-captures
    re2c:invert-captures

And the new `(! ...)` syntax.
2023-07-13 22:59:47 +01:00
Ulya Trofimovich c86a8bcf5d Add tests for re2c:leftmost-captures and re2c:posix-captures. 2023-07-13 22:27:13 +01:00
Ulya Trofimovich 3a98b54363 Add configuration re2c:leftmost-captures.
It has the same meaning as the --leftmost-captures option.
2023-07-13 22:16:37 +01:00
Ulya Trofimovich 0384cffd9f Fix build scripts for Wine to run on NixOS.
Wine cannot find DLLs by their absolute paths on NixOS, so find and copy
them before running re2c.exe.
2023-07-13 08:06:00 +01:00
Ulya Trofimovich a303a8500d Add missing header include to make src/codegen/code.h self-contained. 2023-07-13 06:22:48 +01:00
Ulya Trofimovich 8c2127d420 Replace enum GorPass with uint32_t as it is used in a bitfield.
It cannot be a `enum class` because it's used in a bitfield and this
triggers compiler warnings and errors on some toolchains (see
https://github.com/skvadrik/re2c/issues/446 for details).

It cannot be a plain `enum` defaulting to `int` as well because of
-Wsigned-enum-bitfield warning (noticed when testing on OpenBSD with
clang-13).
2023-07-12 22:48:57 +01:00
Ulya Trofimovich 54ffc58440 Make function static as it is used in one file. 2023-07-12 22:19:09 +01:00
Ulya Trofimovich 00cbfe90af Drop _POSIX_SOURCE, enable -std=gnu++11 for CMake.
On Unix systems, re2c uses POSIX functions (e.g. fdopen). Certain
systems, such as Cygwin and NetBSD, enable these funtions conditionally
based on certain preprocessor definitions.

Previously https://github.com/skvadrik/re2c/pull/376 fixed the build on
Cygwin by setting _POSIX_SOURCE. However, this broke the build on
FreeBSD which was fixed by commit

This worked for Autotools build system which uses -std=c++11 due to the
use of AC_USE_SYSTEM_EXTENSIONS, but it didn't work for CMake that used
-std=c++11 and disabled extensions with `set(CMAKE_CXX_EXTENSIONS OFF)`.

This commit drops `set(CMAKE_CXX_EXTENSIONS OFF)`, which effectively
enables -std=gnu++11 instead of -std=c++11 for CMake builds. This allows
us to get rid of the problematic _POSIX_SOURCE that breaks the build on
NetBSD.

This was tested on NetBSD-9.3, FreeBSD-13.2 and Cygwin with both
Autotools and CMake.
2023-07-11 23:34:53 +01:00
Ulya Trofimovich bb143b980c libre2c: omit redundant semicolon after namespace.
This gets rid of compiler warnings on some older toolchains (e.g. GCC-10
emits pedantic diagnostic about it, which was fixed in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96068).
2023-07-08 15:02:40 +01:00
Ulya Trofimovich fce87b493f Omit redundant semicolon after namespace.
This gets rid of compiler warnings on some older toolchains (e.g. GCC-10
emits pedantic diagnostic about it, which was fixed in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96068).
2023-07-08 14:17:31 +01:00
Ulya Trofimovich d87f86ed71 Correctly parse raw UTF-8 characters in Flex mode.
With `--flex-syntax` option re2c accepts raw (unquoted) strings.
If `--input-encoding utf8` is also enabled, re2c should parse raw UTF-8
characters in such strings. Previously it failed to do so because the
characters in raw string literals were limited to alphanumeric ASCII and
underscore (those allowed in indentifiers, as in normal mode unquoted
strings would be parsed as identifiers).

This commit fixes it: now in Flex mode and with UTF-8 input, if all
previous rules failed, re2c tries to lex the input as a UTF-8 character.

This fixes bug #447 "Re2go fail when compiling expression containing
combining character".
2023-06-22 07:53:03 +01:00
Ulya Trofimovich d7c697138a Convert GorPass from enum class to plain enum to fix compiler error.
GCC-5.4 is unhappy that `GorPass` which is `enum class: uint32_t` is
stored in a bitfield of size 2 (2 bits). In practice it is safe since
the enum has only three values (0, 1, 2).

Reported in:
  - #445 "make failure for re2c"
  - #446 "make failure for re2c on centos7"
2023-06-18 07:41:04 +01:00
Ulya Trofimovich 580ab173dd run_tests.py: remove exception for overflow-1.re test on Windows.
The test no longer causes stack overflow, so it can now run on Windows
which has a smaller stack than Linux and macOS.
2023-04-27 22:15:20 +01:00
Ulya Trofimovich 6e844850bb run_tests.py: patch backslashes in depfile to fix tests on Windows.
Change file context definition to cover more scenarios that include
filenames, e.g. the case when there is a depfile generated and appended
to the output.
2023-04-27 22:15:20 +01:00
helly25 3205c867bd Provide a min viable http://bazel.build integration.
This allows other projects that use bazel to utilize re2c as a tool.

Limitations:

. Input files (docs, lexer, parser) are not being re-generated.
. No tests are executed.
. Only the main binary is being build as nothing else is needed.

A user will load the package using bazel's 'http_archive' in their
WORKSPACE file.

In their BUILD files they can then use:

```
load("@re2c//bazel:re2c.bzl", "re2c_gen")

re2c_gen(
    name = "file_re2c",
    srcs = ["file.re2c"],
    outs = [
        "file.cc",
        "file.h",
    ]
)

cc_library(
    name = "file_cc",
    srcs = ["file.cc"],
    hdrs = ["file.h"],
)
```

The approach here is to automate as much as possible. In that way, all
source and header files will be found automatically (using glob). Also,
the provided bazel integration is kept to an absolute minimum.

An alternative is to use a `rules_foreign_cc` based approach. But that
would require much more bazel work and knowledge. Plus the result would
end up being a non-hermetic build, thereby bypassing bazel's advantages.
Further, using a rules_foreign_cc approach is much slower (for me ~x10).
2023-04-27 13:22:59 +01:00
Ulya Trofimovich 2dda36aa66 Header file should be a dependency, not a target.
So move it before the colon in the dependency file generated with
--depfile option. This fixes bug #440.
2023-04-26 00:04:33 +01:00
Ulya Trofimovich f807f7636e Add header file to the dependencies generated with --depfile option.
This fixes bug #440 "Generated header file is not present in depfile".
2023-04-25 23:44:14 +01:00
Ulya Trofimovich ce75619557 Add configuration re2c:invert_captures.
Make option --invert-captures configurable. This requires postponing the
decision whether a group is capturing or not to the after-parsing stage
when the configurations for a block are known and the immutable AST is
converted to a regexp.

Add a test for the new configuration.
2023-04-24 23:55:49 +01:00
Ulya Trofimovich dedd72dd66 Add tests for --invert-captures option. 2023-04-24 23:55:49 +01:00
Ulya Trofimovich bf3ff8f3ab Merge AST nodes CAP and REF for capturing and non-capturing groups.
These nodes are similar enough so that it is easier to handle them as
one node with a boolean parameter.
2023-04-21 22:12:40 +01:00
Ulya Trofimovich 20030ff194 Add option --invert-captures.
The new option inverts the meaning on capturing and non-capturing
parentheses: `(! ...)` becomes capturing, and `( ... )` becomes
non-capturing, including the implicit whole-regexp group, which also
becomes non-capturing.

The idea of the new option is to let the user decide which gropus should
be capturing and which are purely structural, and explicitly mark only
the capturing ones for submatch extraction.
2023-04-21 22:10:14 +01:00
Ulya Trofimovich 338806b96c Change syntax for explicit non-capturing groups.
The old syntax was `(? ...)`, the new syntax is `(! ...)`. This is in
preparation to add --invert-captures option that will flip the meaning
of capturing and non-capturing parentheses.
2023-04-19 07:20:42 +01:00
1576 changed files with 281290 additions and 84045 deletions
+1
View File
@@ -1,2 +1,3 @@
* text=auto
test/newlines/** -text
test/codegen/python/indentation_sensitive_crlf.re -text
+12
View File
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
commit-message:
include: "scope"
prefix: "Actions"
directory: "/"
labels:
- "enhancement"
schedule:
interval: "weekly"
+11 -3
View File
@@ -33,15 +33,15 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
@@ -71,8 +71,16 @@ jobs:
cmake -S . -B .build \
-G "Unix Makefiles" \
-DRE2C_BUILD_LIBS=ON \
-DRE2C_BUILD_RE2D=OFF \
-DRE2C_BUILD_RE2GO=OFF \
-DRE2C_BUILD_RE2HS=OFF \
-DRE2C_BUILD_RE2JAVA=OFF \
-DRE2C_BUILD_RE2JS=OFF \
-DRE2C_BUILD_RE2OCAML=OFF \
-DRE2C_BUILD_RE2PY=OFF \
-DRE2C_BUILD_RE2RUST=OFF \
-DRE2C_BUILD_RE2V=OFF \
-DRE2C_BUILD_RE2ZIG=OFF \
-DRE2C_BUILD_BENCHMARKS=ON \
-DCMAKE_CXX_FLAGS="-O3"
+5 -8
View File
@@ -36,16 +36,13 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup apt cache (Linux)
if: startsWith(runner.os, 'Linux')
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
/var/cache/apt
!/var/cache/apt/archives/lock
!/var/cache/apt/archives/partial
path: /var/cache/apt
key: ${{ runner.os }}-apt-cache-${{ matrix.os }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-apt-cache-${{ matrix.os }}-
@@ -72,7 +69,7 @@ jobs:
esac
- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: 3.x
architecture: x64
@@ -149,7 +146,7 @@ jobs:
- name: Archive test artifacts
# Run this step only if tests failed (otherwise there is nothing to upload).
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
# To ensure that jobs don't overwrite existing artifacts,
# use a different name per job.
+13 -12
View File
@@ -62,11 +62,11 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup chocolatey Cache (Windows)
if: startsWith(runner.os, 'Windows')
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
key: ${{ runner.os }}-chocolatey-${{ matrix.os }}-${{ github.sha }}
@@ -76,12 +76,9 @@ jobs:
- name: Setup apt cache (Linux)
if: startsWith(runner.os, 'Linux')
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
/var/cache/apt
!/var/cache/apt/archives/lock
!/var/cache/apt/archives/partial
path: /var/cache/apt
key: ${{ runner.os }}-apt-cache-${{ matrix.os }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-apt-cache-${{ matrix.os }}-
@@ -108,7 +105,7 @@ jobs:
esac
- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: 3.x
architecture: x64
@@ -138,9 +135,9 @@ jobs:
id: build-info
run: |
if echo "${{ matrix.name }}" | grep -q "ootree"; then
BUILD_DIR="$(pwd)/.build/${{ matrix.name }}-full"
BUILD_DIR="${{ github.workspace }}/.build/${{ matrix.name }}-full"
else
BUILD_DIR="$(pwd)"
BUILD_DIR="${{ github.workspace }}"
fi
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_OUTPUT
@@ -168,13 +165,17 @@ jobs:
- name: Archive test artifacts
# Run this step only if tests failed (otherwise there is nothing to upload).
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
# To ensure that jobs don't overwrite existing artifacts,
# use a different name per job.
name: test-${{ matrix.name }}
# Tests run in a temporary directory that has a name test_<timestamp>.
path: ${{ steps.build-info.outputs.BUILD_DIR }}/test_[0-9]*
# Provide both relative and absolute paths. Absolute path should work for all builds,
# but it doesn't work on Windows. Relative path works for in-tree Windows builds.
path: |
test_[0-9]*
${{ steps.build-info.outputs.BUILD_DIR }}/test_[0-9]*
# Artifacts are retained for 90 days by default.
# In fact, we don't need such long period.
retention-days: 30
+1
View File
@@ -11,6 +11,7 @@
/m4
/test_*
/.build*
/bazel-*
# Ignore user defined CMake presets
CMakeUserPresets.json
+45
View File
@@ -0,0 +1,45 @@
package(default_visibility = ["//visibility:private"])
genrule(
name = "re2c_config",
srcs = [
"CMakeLists.txt",
"//bazel:re2c_config.h",
],
outs = ["config.h"],
cmd = """
cat $(location //:CMakeLists.txt) |\\
sed -rne 's/project\\(re2c VERSION ([^ ]+).*/#define PACKAGE_VERSION "\\1-bootstrap"/p' >> "$@"
cat $(location //bazel:re2c_config.h) >> "$@"
""",
)
cc_library(
name = "re2c_config_cc",
hdrs = ["config.h"],
defines = ["""RE2C_STDLIB_DIR='"$(BINDIR)/re2c.runfiles/re2c/include"'"""],
data = ["include/unicode_categories.re"],
)
cc_library(
name = "re2c_bootstrap_cc",
includes = ["bootstrap"],
hdrs = glob([
"bootstrap/src/**/*.h",
"src/**/*.h",
]),
srcs = glob([
"bootstrap/src/**/*.cc",
"src/**/*.cc",
]),
deps = [
"re2c_config_cc", # Needed for 're2c_config_cc' data files
],
)
cc_binary(
name = "re2c",
srcs = ["src/main.cc"],
deps = [":re2c_bootstrap_cc"],
visibility = ["//visibility:public"],
)
+75 -11
View File
@@ -5,9 +5,9 @@ How to build
Dependencies
------------
To build re2c from a release tarball one needs only a C++ compiler and Python 3
(for build-time scripts and for testing). Building on Windows additionally
requires either CMake or a Mingw build environment.
To build re2c from a release tarball one needs only a C++ compiler (supporting
at least C++11) and Python 3 for build-time scripts and for testing. Building on
Windows additionally requires either CMake or a Mingw build environment.
To develop re2c one also needs CMake or Autotools (both build systems are
maintained). Other dependencies include Bison (to rebuild parsers), Python 3
@@ -45,16 +45,48 @@ The configure script has many options (to see them all, run
* `--enable-debug`
Enable debug checks in the re2c source code. Also enables debug options.
* `--enable-dlang`
Build re2d (identical to `re2c --lang d`). This is on by default.
* `--enable-golang`
Build re2go (identical to `re2c --lang go`). This is on by default.
* `--enable-haskell`
Build re2hs (identical to `re2c --lang haskell`). This is on by default.
* `--enable-java`
Build re2java (identical to `re2c --lang java`). This is on by default.
* `--enable-js`
Build re2js (identical to `re2c --lang js`). This is on by default.
* `--enable-ocaml`
Build re2ocaml (identical to `re2c --lang ocaml`). This is on by default.
* `--enable-python`
Build re2py (identical to `re2c --lang python`). This is on by default.
* `--enable-rust`
Build re2rust (identical to `re2c --lang rust`). This is on by default.
* `--enable-vlang`
Build re2v (identical to `re2c --lang v`). This is on by default.
* `--enable-zig`
Build re2zig (identical to `re2c --lang zig`). This is on by default.
* `--enable-lexers`
Enable regeneration of *.re* files (as opposed to using bootstrap files).
This requires setting `RE2C_FOR_BUILD` to an existing re2c executable
path.
Enable regeneration of lexers from *.re* files (as opposed to using
pre-generated bootstrap files). This requires setting `RE2C_FOR_BUILD` to
an existing re2c executable path.
* `--enable-parsers`
Enable regeneration of parsers from *.ypp* files with bison (as opposed to
using pre-generated bootstrap files).
* `--enable-syntax`
Enable regeneration of default syntax files from the ones provided in
include/ directory (as opposed to using pre-generated bootstrap files).
* `--enable-docs`
Enable regeneration of documentation (requires Python 3 Docutils).
@@ -144,21 +176,53 @@ A simple build (objects are generated in a separate build directory):
CMake supports a lot of configuration options. Here is the list of options
specific to re2c:
* `-DRE2C_BUILD_RE2D=yes`
Build re2d executable (an alias to `re2c --lang d`). Enabled by default.
* `-DRE2C_BUILD_RE2GO=yes`
Build re2go executable (an alias to `re2c --lang go`). Enabled by default.
* `-DRE2C_BUILD_RE2HS=yes`
Build re2hs executable (an alias to `re2c --lang haskell`). Enabled by
default.
* `-DRE2C_BUILD_RE2JAVA=yes`
Build re2java executable (an alias to `re2c --lang java`). Enabled by
default.
* `-DRE2C_BUILD_RE2JS=yes`
Build re2js executable (an alias to `re2c --lang js`). Enabled by default.
* `-DRE2C_BUILD_RE2OCAML=yes`
Build re2ocaml executable (an alias to `re2c --lang ocaml`). Enabled by
default.
* `-DRE2C_BUILD_RE2PY=yes`
Build re2py executable (an alias to `re2c --lang python`). Enabled by
default.
* `-DRE2C_BUILD_RE2RUST=yes`
Build re2rust executable (an alias to `re2c --lang rust`). Enabled by
default.
* `-DRE2C_BUILD_RE2V=yes`
Build re2v executable (an alias to `re2c --lang v`). Enabled by default.
* `-DRE2C_BUILD_RE2ZIG=yes`
Build re2zig executable (an alias to `re2c --lang zig`). Enabled by default.
* `-DRE2C_REBUILD_LEXERS=yes`
Enable regeneration of *.re* files (as opposed to using bootstrap files).
This requires setting `-DRE2C_FOR_BUILD` to an existing re2c executable
path.
Enable regeneration of lexers from *.re* files (as opposed to using
pre-generated bootstrap files). This requires setting `-DRE2C_FOR_BUILD` to
an existing re2c executable path.
* `-DRE2C_REBUILD_PARSERS=yes`
Enable regeneration of `parser.cc` and `parser.h` files (as opposed to
using bootstrap files). This requires an available Bison parser generator.
Enable regeneration of parsers from *.ypp* files with bison (as opposed to
using pre-generated bootstrap files).
* `-DRE2C_REBUILD_SYNTAX=yes`
Enable regeneration of default syntax files from the ones provided in
include/ directory (as opposed to using pre-generated bootstrap files).
* `-DRE2C_REBUILD_DOCS=yes`
Enable regeneration of documentation (requires Python 3 Docutils).
+327
View File
@@ -2,10 +2,337 @@ Changelog
=========
----
4.0x
----
4.0 (2024-11-19)
~~~~~~~~~~~~~~~~
- Added a generic technique for describing language backends based on the idea
of syntax files (`#450 <https://github.com/skvadrik/re2c/issues/450>`_).
- Added support for new languages: D, Haskell, Java, JavaScript, OCaml, Python,
V, Zig.
- Added new record API for all languages (enabled with ``--api record``,
``re2c:api = record``) and made it the default API for Haskell and OCaml.
- Renamed former "default API" to "simple API", implemented it for all backends
except Haskell and OCaml, and enabled by default API for C, D, Java,
JavaScript, Python, V and Zig.
- Added new code generation model - recursive functions (enabled with
``--recursive-functions``), primarily to be used for functional languages.
- Added options:
+ ``--syntax <file>``
+ ``--api simple``
+ ``--api generic``
+ ``--api record``
+ ``--goto-label``
+ ``--recursive-functions``
+ ``--lang none``
+ ``--lang d``
+ ``--lang haskell``
+ ``--lang java``
+ ``--lang js``
+ ``--lang ocaml``
+ ``--lang python``
+ ``--lang v``
+ ``--lang zig``
+ ``--leftmost-captvars``
+ ``--posix-captvars``
+ ``--captvars`` (alias for ``--leftmost-captvars``)
+ ``--captures`` (alias for ``--leftmost-captures``)
- Added configurations:
+ ``re2c:api = simple`` (alias for ``re2c:api = default``)
+ ``re2c:api = generic`` (alias for ``re2c:api = custom``)
+ ``re2c:api = record``
+ ``re2c:computed-gotos`` (alias for ``re2c:cgoto``)
+ ``re2c:cond:abort``
+ ``re2c:tags:negative``
+ ``re2c:leftmost-captvars``
+ ``re2c:posix-captvars``
+ ``re2c:captvars`` (alias for ``re2c:leftmost-captvars``)
+ ``re2c:captures`` (alias for ``re2c:leftmost-captures``)
+ ``re2c:monadic``
+ ``re2c:fn:sep``
+ ``re2c:[define:]YYFN``
+ ``re2c:[define:]YYINPUT``
+ ``re2c:[define:]YYGETACCEPT``
+ ``re2c:[define:]YYSETACCEPT``
+ ``re2c:[define:]YYCOPYSTAG``
+ ``re2c:[define:]YYCOPYMTAG``
+ ``re2c:[define:]YYGETCOND`` (alias for ``re2c:[define:]YYGETCONDITION``)
+ ``re2c:[define:]YYSETCOND`` (alias for ``re2c:[define:]YYSETCONDITION``)
+ ``re2c:[variable:]yyfill``
+ ``re2c:[variable:]yynmatch``
+ ``re2c:[variable:]yypmatch``
+ ``re2c:[variable:]yych:literals``
- All configurations that have ``define:`` or ``variable:`` part in their name
now have an alias without this part.
- Added new block types:
+ ``/*!svars:re2c ... */``
+ ``/*!mvars:re2c ... */``
- Flex-style opening/closing braces ``%{`` and ``%}`` for block start/end
markers now work for all block types.
- Added syntax file feature lists:
+ ``supported_apis`` with values from the list:
``simple``, ``generic``, ``record``
+ ``supported_api_styles`` with values from the list:
``free-form``, ``functions``
+ ``supported_code_models`` with values from the list:
``goto-label``, ``loop-switch``, ``recursive-functions``
+ ``supported_targets`` with values from the list:
``code``, ``dot``, ``skeleton``
+ ``supported_features`` with values from the list:
``nested-ifs``, ``bitmaps``, ``computed-gotos``, ``case-ranges``,
``tags``, ``captures``, ``captvars``, ``monadic``, ``unsafe``
- Added syntax file language-specific options:
+ ``semicolons``
+ ``backtick_quoted_strings``
+ ``single_quoted_strings``
+ ``indentation_sensitive``
+ ``wrap_blocks_in_braces``
- Added syntax file code templates:
+ ``code:var_local``
+ ``code:var_global``
+ ``code:const_local``
+ ``code:const_global``
+ ``code:array_local``
+ ``code:array_global``
+ ``code:array_elem``
+ ``code:enum``
+ ``code:enum_elem``
+ ``code:assign``
+ ``code:type_int``
+ ``code:type_uint``
+ ``code:type_cond_enum``
+ ``code:type_yybm``
+ ``code:type_yytarget``
+ ``code:cmp_eq``
+ ``code:cmp_ne``
+ ``code:cmp_lt``
+ ``code:cmp_gt``
+ ``code:cmp_le``
+ ``code:cmp_ge``
+ ``code:if_then_else``
+ ``code:if_then_else_oneline``
+ ``code:switch``
+ ``code:switch_cases``
+ ``code:switch_cases_oneline``
+ ``code:switch_case_range``
+ ``code:switch_case_default``
+ ``code:loop``
+ ``code:continue``
+ ``code:goto``
+ ``code:fndecl``
+ ``code:fndef``
+ ``code:fncall``
+ ``code:tailcall``
+ ``code:recursive_functions``
+ ``code:fingerprint``
+ ``code:line_info``
+ ``code:abort``
+ ``code:yydebug``
+ ``code:yypeek``
+ ``code:yyskip``
+ ``code:yybackup``
+ ``code:yybackupctx``
+ ``code:yyskip_yypeek``
+ ``code:yypeek_yyskip``
+ ``code:yyskip_yybackup``
+ ``code:yybackup_yyskip``
+ ``code:yybackup_yypeek``
+ ``code:yyskip_yybackup_yypeek``
+ ``code:yybackup_yypeek_yyskip``
+ ``code:yyrestore``
+ ``code:yyrestorectx``
+ ``code:yyrestoretag``
+ ``code:yyshift``
+ ``code:yyshiftstag``
+ ``code:yyshiftmtag``
+ ``code:yystagp``
+ ``code:yymtagp``
+ ``code:yystagn``
+ ``code:yymtagn``
+ ``code:yycopystag``
+ ``code:yycopymtag``
+ ``code:yygetaccept``
+ ``code:yysetaccept``
+ ``code:yygetcond``
+ ``code:yysetcond``
+ ``code:yygetstate``
+ ``code:yysetstate``
+ ``code:yylessthan``
+ ``code:yybm_filter``
+ ``code:yybm_match``
- Added global variables in syntax files:
+ ``nl``
+ ``indent``
+ ``dedent``
+ ``topindent``
- Added global conditionals in syntax files:
+ ``.api.simple``
+ ``.api.generic``
+ ``.api.record``
+ ``.api_style.functions``
+ ``.api_style.freeform``
+ ``.case_ranges``
+ ``.code_model.goto_label``
+ ``.code_model.loop_switch``
+ ``.code_model.recursive_functions``
+ ``.date``
+ ``.loop_label``
+ ``.monadic``
+ ``.start_conditions``
+ ``.storable_state``
+ ``.unsafe``
+ ``.version``
- Added warning ``-Wundefined-syntax-config``.
- Warnings that indicate serious issues are now turned on by default
(and can be disabled with ``-Wno-<warning>`` options.
- Added configure options:
+ ``--enable-syntax`` (Autoconf)
+ ``RE2C_REBUILD_SYNTAX`` (CMake)
- Dropped support for function-like API style for Rust.
(it was hard to use, if at all possible)
- Added online playground that allows one to run re2c in a web browser:
https://re2c.org/playground.
- Infra work on Github Actions CI.
----
3.0x
----
3.1 (2023-07-19)
~~~~~~~~~~~~~~~~
- Added capturing groups with leftmost greedy semantics:
+ Enabled with ``--leftmost-captures`` option or ``re2c:leftmost_captures``
configuration
(`55de79d8 <https://github.com/skvadrik/re2c/commit/55de79d8>`_,
`3a98b543 <https://github.com/skvadrik/re2c/commit/3a98b543>`_).
- Added non-capturing groups:
+ Added new syntax ``(! ...)`` for non-capturing groups
(`1edd25d3 <https://github.com/skvadrik/re2c/commit/1edd25d3>`_,
`b813c9b4 <https://github.com/skvadrik/re2c/commit/b813c9b4>`_,
`338806b9 <https://github.com/skvadrik/re2c/commit/338806b9>`_).
+ Added the ability to flip defaults: make ``(...)`` capturing and ``(! ...)``
non-capturing with ``--invert-captures`` option or ``re2c:invert_captures``
configuration
(`20030ff1 <https://github.com/skvadrik/re2c/commit/20030ff1>`_,
`ce756195 <https://github.com/skvadrik/re2c/commit/ce756195>`_).
- Regenerated Unicode include header to support a newer standard
(`e3ec2597 <https://github.com/skvadrik/re2c/commit/e3ec2597>`_).
- Published TDFA paper: https://arxiv.org/abs/2206.01398, co-authored with
Angelo Borsotti
(`fa94d9c7 <https://github.com/skvadrik/re2c/commit/fa94d9c7>`_).
- Removed experimental algorithms that are superseded by TDFA(1) and
generally less efficient:
+ Removed staDFA algorithm and deprecated ``--stadfa`` option
(`ac5c06cc <https://github.com/skvadrik/re2c/commit/ac5c06cc>`_).
+ Removed TDFA(0) algorithm and deprecated ``--no-lookahead`` option
(`dc8f264a <https://github.com/skvadrik/re2c/commit/dc8f264a>`_).
+ (libre2c) Removed backward-matching algorithm
(`27256be1 <https://github.com/skvadrik/re2c/commit/27256be1>`_).
+ (libre2c) Removed Kuklewicz POSIX disambiguation algorithm
(`aa97b014 <https://github.com/skvadrik/re2c/commit/aa97b014>`_).
+ (libre2c) Removed GTOP shortest path finding algorithm
(`511a030c <https://github.com/skvadrik/re2c/commit/511a030c>`_).
- Bug fixes:
+ Fixed parsing of raw UTF-8 characters in Flex compatibility mode
(`d87f86ed <https://github.com/skvadrik/re2c/commit/d87f86ed>`_).
+ Added header file to the dependencies generated with ``--depfile`` option
(`f807f763 <https://github.com/skvadrik/re2c/commit/f807f763>`_
and `2dda36aa <https://github.com/skvadrik/re2c/commit/2dda36aa>`_).
+ Fixed stack overflow on large regular expressions by rewriting recursive
functions in iterative form
(`46a9b4c4 <https://github.com/skvadrik/re2c/commit/46a9b4c4>`_,
`aaf68292 <https://github.com/skvadrik/re2c/commit/aaf68292>`_,
`02e5d797 <https://github.com/skvadrik/re2c/commit/02e5d797>`_,
`5fffb187 <https://github.com/skvadrik/re2c/commit/5fffb187>`_)
and limited stack to 256K on GithubActions CI
(`111ee5da <https://github.com/skvadrik/re2c/commit/111ee5da>`_).
- Build system:
+ Added minimal http://bazel.build integration
(`3205c867 <https://github.com/skvadrik/re2c/commit/3205c867>`_).
+ Added configure option ``--enable-parsers`` that regenerates bison parsers
(`9e0dbd3c <https://github.com/skvadrik/re2c/commit/9e0dbd3c>`_).
+ Added CMake option ``RE2C_REBUILD_PARSERS``
(`6e91c22d <https://github.com/skvadrik/re2c/commit/6e91c22d>`_).
+ With CMake, fixed documentation generation on Windows.
- Codebase improvements:
+ Moved the entire codebase to C++11.
+ Added uniform error handling (return codes are now properly checked and
returned to the caller).
+ Reorganized codegen subsystem in four well-defined phases (analyze,
generate, fixup, render) and separated codegen from parsing phase.
+ Improved memory allocation by using slab allocators instead of global free
lists.
+ Moved to pure API for bison parsers.
+ Unified code style.
- Testing:
+ Added ``--verbose`` flag to run_tests.py and suppressed verbose output by
default.
+ Multiple improvements of continuous testing with GithubActions.
3.0 (2022-01-27)
~~~~~~~~~~~~~~~~
+285 -167
View File
@@ -1,17 +1,25 @@
cmake_minimum_required(VERSION 3.12)
project(re2c VERSION 3.0 HOMEPAGE_URL "https://re2c.org/")
project(re2c VERSION 4.0 HOMEPAGE_URL "https://re2c.org/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Re2cAutotoolsHelpers)
include(Re2cBootstrapLexer)
include(Re2cBootstrapParser)
include(Re2cBootstrapSyntax)
include(Re2cBuildType)
include(Re2cGenDocs)
include(Re2cCompilerFlags)
ac_subst(PACKAGE_VERSION "${PROJECT_VERSION}")
# check whether re2c is the root project
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(RE2C_IS_ROOT_PROJECT TRUE)
else()
set(RE2C_IS_ROOT_PROJECT FALSE)
endif()
option(RE2C_REBUILD_LEXERS "Regenerate lexers" OFF)
if(RE2C_REBUILD_LEXERS AND NOT RE2C_FOR_BUILD)
message(FATAL_ERROR "option RE2C_FOR_BUILD is required for RE2C_REBUILD_LEXERS")
@@ -22,22 +30,32 @@ if(RE2C_REBUILD_PARSERS AND NOT RE2C_FOR_BUILD)
find_package(BISON REQUIRED)
endif()
option(RE2C_REBUILD_SYNTAX "Regenerate default syntax files" OFF)
option(RE2C_REBUILD_DOCS "Regenerate manpage" OFF)
option(RE2C_BUILD_LIBS "Build libraries" OFF)
option(RE2C_BUILD_RE2D "Build re2d executable (an alias for `re2c --lang d`)" ON)
option(RE2C_BUILD_RE2GO "Build re2go executable (an alias for `re2c --lang go`)" ON)
option(RE2C_BUILD_RE2HS "Build re2hs executable (an alias for `re2c --lang haskell`)" ON)
option(RE2C_BUILD_RE2JAVA "Build re2java executable (an alias for `re2c --lang java`)" ON)
option(RE2C_BUILD_RE2JS "Build re2js executable (an alias for `re2c --lang js`)" ON)
option(RE2C_BUILD_RE2OCAML "Build re2ocaml executable (an alias for `re2c --lang ocaml`)" ON)
option(RE2C_BUILD_RE2PY "Build re2py executable (an alias for `re2c --lang python`)" ON)
option(RE2C_BUILD_RE2RUST "Build re2rust executable (an alias for `re2c --lang rust`)" ON)
option(RE2C_BUILD_RE2V "Build re2v executable (an alias for `re2c --lang v`)" ON)
option(RE2C_BUILD_RE2ZIG "Build re2zig executable (an alias for `re2c --lang zig`)" ON)
option(RE2C_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(RE2C_REGEN_BENCHMARKS "Regenerate C code for benchmarks" OFF)
# test targets are enabled by default only if re2c is the root project
option(RE2C_BUILD_TESTS "Build tests" "${RE2C_IS_ROOT_PROJECT}")
# checks for programs
find_package(Python3 COMPONENTS Interpreter)
# starting from cmake 3.19 find_package can do version check, but we are on 3.12
if(Python3_VERSION VERSION_LESS 3.7)
message(FATAL_ERROR "python version 3.7 or higher is required")
if(RE2C_REBUILD_DOCS OR RE2C_BUILD_TESTS OR RE2C_BUILD_BENCHMARKS)
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter)
endif()
if(RE2C_REBUILD_DOCS)
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c "import docutils"
@@ -49,9 +67,11 @@ if(RE2C_REBUILD_DOCS)
endif()
endif()
# checks for C++ compiler flags
# Use C++11 standard. Note that without `set(CMAKE_CXX_EXTENSIONS OFF)` this enables
# -std=gnu++11, not -std=c++11. Extensions are needed to enable POSIX functions on
# Cygwin and NetBSD.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # fail if the C++ compiler does not support this standard
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # make sure object libraries work with shared libraries
# needed for POSIX file API
@@ -63,26 +83,50 @@ ac_check_headers("unistd.h")
ac_check_headers("io.h")
# docs (manpages and help)
set(re2c_manpage_source "${CMAKE_CURRENT_BINARY_DIR}/doc/manpage.rst")
set(re2c_help_source "${CMAKE_CURRENT_BINARY_DIR}/doc/help.rst")
set(re2c_manpage_bootstrap_c "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/doc/re2c.1")
set(re2c_manpage_bootstrap_go "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/doc/re2go.1")
set(re2c_manpage_bootstrap_rust "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/doc/re2rust.1")
set(re2c_help_bootstrap "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/src/msg/help.cc")
set(re2c_manpage_c "${CMAKE_CURRENT_BINARY_DIR}/doc/re2c.1")
set(re2c_manpage_go "${CMAKE_CURRENT_BINARY_DIR}/doc/re2go.1")
set(re2c_manpage_rust "${CMAKE_CURRENT_BINARY_DIR}/doc/re2rust.1")
set(re2c_help "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help.cc")
set(re2c_rst2man "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2man.py")
set(re2c_rst2txt "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2txt.py")
set(re2c_splitman "${CMAKE_CURRENT_SOURCE_DIR}/build/split_man.py")
set(re2c_manpage_source "${CMAKE_CURRENT_BINARY_DIR}/doc/manpage.rst")
set(re2c_help_source "${CMAKE_CURRENT_BINARY_DIR}/doc/help.rst")
set(re2c_manpage_c "${CMAKE_CURRENT_BINARY_DIR}/doc/re2c.1")
set(re2c_manpage_d "${CMAKE_CURRENT_BINARY_DIR}/doc/re2d.1")
set(re2c_manpage_go "${CMAKE_CURRENT_BINARY_DIR}/doc/re2go.1")
set(re2c_manpage_haskell "${CMAKE_CURRENT_BINARY_DIR}/doc/re2hs.1")
set(re2c_manpage_java "${CMAKE_CURRENT_BINARY_DIR}/doc/re2java.1")
set(re2c_manpage_js "${CMAKE_CURRENT_BINARY_DIR}/doc/re2js.1")
set(re2c_manpage_ocaml "${CMAKE_CURRENT_BINARY_DIR}/doc/re2ocaml.1")
set(re2c_manpage_python "${CMAKE_CURRENT_BINARY_DIR}/doc/re2py.1")
set(re2c_manpage_rust "${CMAKE_CURRENT_BINARY_DIR}/doc/re2rust.1")
set(re2c_manpage_v "${CMAKE_CURRENT_BINARY_DIR}/doc/re2v.1")
set(re2c_manpage_zig "${CMAKE_CURRENT_BINARY_DIR}/doc/re2zig.1")
set(re2c_help_c "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2c.cc")
set(re2c_help_d "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2d.cc")
set(re2c_help_go "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2go.cc")
set(re2c_help_haskell "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2hs.cc")
set(re2c_help_java "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2java.cc")
set(re2c_help_js "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2js.cc")
set(re2c_help_ocaml "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2ocaml.cc")
set(re2c_help_python "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2py.cc")
set(re2c_help_rust "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2rust.cc")
set(re2c_help_v "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2v.cc")
set(re2c_help_zig "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2zig.cc")
set(re2c_rst2man "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2man.py")
set(re2c_rst2txt "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2txt.py")
set(re2c_splitman "${CMAKE_CURRENT_SOURCE_DIR}/build/split_man.py")
set(re2c_docs
"${re2c_help}"
"${re2c_manpage_c}"
"$<$<BOOL:${RE2C_BUILD_RE2D}>:${re2c_manpage_d}>"
"$<$<BOOL:${RE2C_BUILD_RE2GO}>:${re2c_manpage_go}>"
"$<$<BOOL:${RE2C_BUILD_RE2HS}>:${re2c_manpage_haskell}>"
"$<$<BOOL:${RE2C_BUILD_RE2JAVA}>:${re2c_manpage_java}>"
"$<$<BOOL:${RE2C_BUILD_RE2JS}>:${re2c_manpage_js}>"
"$<$<BOOL:${RE2C_BUILD_RE2OCAML}>:${re2c_manpage_ocaml}>"
"$<$<BOOL:${RE2C_BUILD_RE2PY}>:${re2c_manpage_python}>"
"$<$<BOOL:${RE2C_BUILD_RE2RUST}>:${re2c_manpage_rust}>"
"$<$<BOOL:${RE2C_BUILD_RE2V}>:${re2c_manpage_v}>"
"$<$<BOOL:${RE2C_BUILD_RE2ZIG}>:${re2c_manpage_zig}>"
)
# syntax files
set(re2c_stx2cpp "${CMAKE_CURRENT_SOURCE_DIR}/build/stx2cpp.py")
set(top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
set(top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
set(PYTHON "${Python3_EXECUTABLE}")
@@ -90,10 +134,12 @@ set(PYTHON "${Python3_EXECUTABLE}")
configure_file(doc/manpage.rst.in doc/manpage.rst @ONLY)
configure_file(doc/help.rst.in doc/help.rst @ONLY)
configure_file(run_tests.py.in run_tests.py @ONLY)
set(RE2C_RUN_TESTS "${CMAKE_CURRENT_BINARY_DIR}/run_tests.py")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND chmod +x "${RE2C_RUN_TESTS}")
if(RE2C_BUILD_TESTS)
configure_file(run_tests.py.in run_tests.py @ONLY)
set(RE2C_RUN_TESTS "${CMAKE_CURRENT_BINARY_DIR}/run_tests.py")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND chmod +x "${RE2C_RUN_TESTS}")
endif()
endif()
ac_config_headers("config.h")
@@ -111,12 +157,25 @@ include_directories(. "${CMAKE_CURRENT_BINARY_DIR}")
# WARNING: custom target that depends on autogenerated sources won't do here
# as its dependencies get built multiple times, which ruins parallel builds.
add_library(re2c_objects_autogen OBJECT
"${CMAKE_CURRENT_BINARY_DIR}/src/options/parse_opts.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lexer.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lexer.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/parser.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/parser.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lex.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lex.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lex_conf.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/options/parse_opts.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/conf_lexer.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/conf_parser.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/conf_parser.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_c.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_d.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_go.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_haskell.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_java.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_js.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_ocaml.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_python.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_rust.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_v.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_zig.cc"
"${re2c_docs}"
)
add_library(re2c_objects_autogen_ver_to_vernum OBJECT
@@ -187,156 +246,207 @@ set(re2c_sources
$<TARGET_OBJECTS:re2c_objects_autogen_ver_to_vernum>
)
re2c_bootstrap_lexer("src/msg/ver_to_vernum.re" "src/msg/ver_to_vernum.cc")
re2c_bootstrap_lexer("src/options/parse_opts.re" "src/options/parse_opts.cc")
re2c_bootstrap_lexer("src/parse/lexer.re" "src/parse/lexer.cc" "src/parse/lexer.h")
re2c_bootstrap_parser("src/parse/parser.ypp" "src/parse/parser.cc" "src/parse/parser.h")
re2c_bootstrap_lexer("src/parse/conf_lexer.re" "src/parse/conf_lexer.cc")
re2c_bootstrap_parser("src/parse/conf_parser.ypp" "src/parse/conf_parser.cc" "src/parse/conf_parser.h")
re2c_bootstrap_syntax("include/syntax/c" "src/default_syntax_c.cc")
re2c_bootstrap_syntax("include/syntax/d" "src/default_syntax_d.cc")
re2c_bootstrap_syntax("include/syntax/go" "src/default_syntax_go.cc")
re2c_bootstrap_syntax("include/syntax/haskell" "src/default_syntax_haskell.cc")
re2c_bootstrap_syntax("include/syntax/java" "src/default_syntax_java.cc")
re2c_bootstrap_syntax("include/syntax/js" "src/default_syntax_js.cc")
re2c_bootstrap_syntax("include/syntax/ocaml" "src/default_syntax_ocaml.cc")
re2c_bootstrap_syntax("include/syntax/python" "src/default_syntax_python.cc")
re2c_bootstrap_syntax("include/syntax/rust" "src/default_syntax_rust.cc")
re2c_bootstrap_syntax("include/syntax/v" "src/default_syntax_v.cc")
re2c_bootstrap_syntax("include/syntax/zig" "src/default_syntax_zig.cc")
# docs
file(GLOB_RECURSE re2c_docs_sources CONFIGURE_DEPENDS
"examples/*"
"doc/manual/*"
"${re2c_manpage_source}"
)
re2c_gen_help("${re2c_help_source}" "${re2c_help_c}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_c}")
add_custom_target(docs DEPENDS "${re2c_docs}")
# re2c
add_executable(re2c ${re2c_sources})
add_executable(re2c ${re2c_sources} "${re2c_help_c}")
# re2d
if (RE2C_BUILD_RE2D)
re2c_gen_help("${re2c_help_source}" "${re2c_help_d}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_d}")
add_executable(re2d ${re2c_sources} "${re2c_help_d}")
target_compile_definitions(re2d PUBLIC
"RE2C_LANG=Lang::D"
"RE2C_PROG=\"re2d\""
)
endif()
# re2go
if (RE2C_BUILD_RE2GO)
add_executable(re2go ${re2c_sources})
target_compile_definitions(re2go PUBLIC "RE2C_LANG=Lang::GO")
re2c_gen_help("${re2c_help_source}" "${re2c_help_go}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_go}")
add_executable(re2go ${re2c_sources} "${re2c_help_go}")
target_compile_definitions(re2go PUBLIC
"RE2C_LANG=Lang::GO"
"RE2C_PROG=\"re2go\""
)
endif()
# re2hs
if (RE2C_BUILD_RE2HS)
re2c_gen_help("${re2c_help_source}" "${re2c_help_haskell}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_haskell}")
add_executable(re2hs ${re2c_sources} "${re2c_help_haskell}")
target_compile_definitions(re2hs PUBLIC
"RE2C_LANG=Lang::HASKELL"
"RE2C_PROG=\"re2hs\""
)
endif()
# re2java
if (RE2C_BUILD_RE2JAVA)
re2c_gen_help("${re2c_help_source}" "${re2c_help_java}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_java}")
add_executable(re2java ${re2c_sources} "${re2c_help_java}")
target_compile_definitions(re2java PUBLIC
"RE2C_LANG=Lang::JAVA"
"RE2C_PROG=\"re2java\""
)
endif()
# re2js
if (RE2C_BUILD_RE2JS)
re2c_gen_help("${re2c_help_source}" "${re2c_help_js}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_js}")
add_executable(re2js ${re2c_sources} "${re2c_help_js}")
target_compile_definitions(re2js PUBLIC
"RE2C_LANG=Lang::JS"
"RE2C_PROG=\"re2js\""
)
endif()
# re2ocaml
if (RE2C_BUILD_RE2OCAML)
re2c_gen_help("${re2c_help_source}" "${re2c_help_ocaml}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_ocaml}")
add_executable(re2ocaml ${re2c_sources} "${re2c_help_ocaml}")
target_compile_definitions(re2ocaml PUBLIC
"RE2C_LANG=Lang::OCAML"
"RE2C_PROG=\"re2ocaml\""
)
endif()
# re2py
if (RE2C_BUILD_RE2PY)
re2c_gen_help("${re2c_help_source}" "${re2c_help_python}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_python}")
add_executable(re2py ${re2c_sources} "${re2c_help_python}")
target_compile_definitions(re2py PUBLIC
"RE2C_LANG=Lang::PYTHON"
"RE2C_PROG=\"re2py\""
)
endif()
# re2rust
if (RE2C_BUILD_RE2RUST)
add_executable(re2rust ${re2c_sources})
target_compile_definitions(re2rust PUBLIC "RE2C_LANG=Lang::RUST")
re2c_gen_help("${re2c_help_source}" "${re2c_help_rust}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_rust}")
add_executable(re2rust ${re2c_sources} "${re2c_help_rust}")
target_compile_definitions(re2rust PUBLIC
"RE2C_LANG=Lang::RUST"
"RE2C_PROG=\"re2rust\""
)
endif()
re2c_bootstrap_lexer("src/parse/lex.re" "src/parse/lex.cc" "src/parse/lex.h")
re2c_bootstrap_lexer("src/parse/lex_conf.re" "src/parse/lex_conf.cc")
re2c_bootstrap_lexer("src/options/parse_opts.re" "src/options/parse_opts.cc")
re2c_bootstrap_lexer("src/msg/ver_to_vernum.re" "src/msg/ver_to_vernum.cc")
re2c_bootstrap_parser("src/parse/parser.ypp" "src/parse/parser.cc" "src/parse/parser.h")
# re2v
if (RE2C_BUILD_RE2V)
re2c_gen_help("${re2c_help_source}" "${re2c_help_v}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_v}")
add_executable(re2v ${re2c_sources} "${re2c_help_v}")
target_compile_definitions(re2v PUBLIC
"RE2C_LANG=Lang::V"
"RE2C_PROG=\"re2v\""
)
endif()
# docs
set(re2c_docs_sources
"${re2c_manpage_source}"
"doc/manual/api/interface.rst_"
"doc/manual/conditions/blocks.rst_"
"doc/manual/conditions/conditions.rst_"
"doc/manual/configurations/configurations.rst_"
"doc/manual/directives/directives.rst_"
"doc/manual/dot/dot.rst_"
"doc/manual/encodings/encodings.rst_"
"doc/manual/eof/01_sentinel.rst_"
"doc/manual/eof/02_bounds_checking.rst_"
"doc/manual/eof/03_eof_rule.rst_"
"doc/manual/eof/04_generic_api.rst_"
"doc/manual/eof/eof.rst_"
"doc/manual/fill/01_fill.rst_"
"doc/manual/fill/02_fill.rst_"
"doc/manual/fill/fill.rst_"
"doc/manual/headers/headers.rst_"
"doc/manual/includes/includes.rst_"
"doc/manual/options/debug.rst_"
"doc/manual/options/internal.rst_"
"doc/manual/options/options.rst_"
"doc/manual/regexps/regular_expressions.rst_"
"doc/manual/reuse/reuse.rst_"
"doc/manual/skeleton/skeleton.rst_"
"doc/manual/state/state.rst_"
"doc/manual/submatch/submatch_example_mtags.rst_"
"doc/manual/submatch/submatch_example_posix.rst_"
"doc/manual/submatch/submatch_example_stags_fill.rst_"
"doc/manual/submatch/submatch_example_stags.rst_"
"doc/manual/submatch/submatch.rst_"
"doc/manual/synopsis.rst_"
"doc/manual/syntax/api1.rst_"
"doc/manual/syntax/api2_c.rst_"
"doc/manual/syntax/api2_go.rst_"
"doc/manual/syntax/api2_rust.rst_"
"doc/manual/syntax/api3.rst_"
"doc/manual/syntax/intro.rst_"
"doc/manual/syntax/syntax.rst_"
"doc/manual/warnings/warnings_general.rst_"
"doc/manual/warnings/warnings_list.rst_"
"examples/c/01_basic.re"
"examples/c/01_basic.c"
"examples/c/conditions/parse_u32_blocks.re"
"examples/c/conditions/parse_u32_conditions.re"
"examples/c/encodings/unicode_identifier.re"
"examples/c/eof/01_sentinel.re"
"examples/c/eof/02_bounds_checking.re"
"examples/c/eof/03_eof_rule.re"
"examples/c/eof/05_generic_api_eof_rule.re"
"examples/c/fill/01_fill.re"
"examples/c/fill/02_fill.re"
"examples/c/headers/header.re"
"examples/c/headers/lexer/state.h"
"examples/c/includes/include.re"
"examples/c/includes/definitions.h"
"examples/c/reuse/reuse.re"
"examples/c/reuse/usedir.re"
"examples/c/state/push.re"
"examples/c/submatch/01_stags_fill.re"
"examples/c/submatch/01_stags.re"
"examples/c/submatch/02_mtags.re"
"examples/c/submatch/03_posix.re"
"examples/go/01_basic.re"
"examples/go/01_basic.go"
"examples/go/conditions/parse_u32_blocks.re"
"examples/go/conditions/parse_u32_conditions.re"
"examples/go/encodings/unicode_identifier.re"
"examples/go/eof/01_sentinel.re"
"examples/go/eof/02_bounds_checking.re"
"examples/go/eof/03_eof_rule.re"
"examples/go/eof/05_generic_api_eof_rule.re"
"examples/go/fill/01_fill.re"
"examples/go/fill/02_fill.re"
"examples/go/headers/header.re"
"examples/go/headers/lexer/state.go"
"examples/go/includes/include.re"
"examples/go/includes/definitions.go"
"examples/go/reuse/reuse.re"
"examples/go/reuse/usedir.re"
"examples/go/state/push.re"
"examples/go/submatch/01_stags_fill.re"
"examples/go/submatch/01_stags.re"
"examples/go/submatch/02_mtags.re"
"examples/go/submatch/03_posix.re"
"examples/rust/01_basic.re"
"examples/rust/01_basic.rs"
"examples/rust/conditions/parse_u32_blocks.re"
"examples/rust/conditions/parse_u32_conditions.re"
"examples/rust/encodings/unicode_identifier.re"
"examples/rust/eof/01_sentinel.re"
"examples/rust/eof/02_bounds_checking.re"
"examples/rust/eof/03_eof_rule.re"
"examples/rust/eof/05_generic_api_eof_rule.re"
"examples/rust/fill/01_fill.re"
"examples/rust/fill/02_fill.re"
"examples/rust/headers/header.re"
"examples/rust/headers/lexer/state.rs"
"examples/rust/includes/include.re"
"examples/rust/includes/definitions.rs"
"examples/rust/reuse/reuse.re"
"examples/rust/reuse/usedir.re"
"examples/rust/state/push.re"
"examples/rust/submatch/01_stags_fill.re"
"examples/rust/submatch/01_stags.re"
"examples/rust/submatch/02_mtags.re"
"examples/rust/submatch/03_posix.re"
)
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_c}" "${re2c_manpage_bootstrap_c}" "c")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_go}" "${re2c_manpage_bootstrap_go}" "go")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_rust}" "${re2c_manpage_bootstrap_rust}" "rust")
re2c_gen_help("${re2c_help_source}" "${re2c_help}" "${re2c_help_bootstrap}")
add_custom_target(docs DEPENDS "${re2c_docs}")
# re2zig
if (RE2C_BUILD_RE2ZIG)
re2c_gen_help("${re2c_help_source}" "${re2c_help_zig}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_zig}")
add_executable(re2zig ${re2c_sources} "${re2c_help_zig}")
target_compile_definitions(re2zig PUBLIC
"RE2C_LANG=Lang::ZIG"
"RE2C_PROG=\"re2zig\""
)
endif()
# install and test targets are enabled only if re2c is the root project
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# install targets are enabled only if re2c is the root project
if(RE2C_IS_ROOT_PROJECT)
# install
install(TARGETS re2c RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_c}" DESTINATION "share/man/man1")
if(RE2C_BUILD_RE2D)
install(TARGETS re2d RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_d}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2GO)
install(TARGETS re2go RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_go}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2HS)
install(TARGETS re2hs RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_haskell}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2JAVA)
install(TARGETS re2java RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_java}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2JS)
install(TARGETS re2js RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_js}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2OCAML)
install(TARGETS re2ocaml RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_ocaml}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2PY)
install(TARGETS re2py RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_python}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2RUST)
install(TARGETS re2rust RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_rust}" DESTINATION "share/man/man1")
endif()
install(FILES include/unicode_categories.re DESTINATION "${RE2C_STDLIB_DIR}")
if(RE2C_BUILD_RE2V)
install(TARGETS re2v RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_v}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2ZIG)
install(TARGETS re2zig RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_zig}" DESTINATION "share/man/man1")
endif()
install(FILES
include/syntax/c
include/syntax/d
include/syntax/go
include/syntax/haskell
include/syntax/java
include/syntax/js
include/syntax/ocaml
include/syntax/python
include/syntax/rust
include/syntax/v
include/syntax/zig
include/unicode_categories.re
DESTINATION "${RE2C_STDLIB_DIR}")
# rebuild all re2c sources using newly built re2c
add_custom_target(bootstrap
@@ -344,7 +454,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
COMMAND "${CMAKE_COMMAND}" -E remove_directory "doc"
COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}"
)
endif()
if(RE2C_BUILD_TESTS)
# tests
add_custom_target(tests
DEPENDS "${RE2C_RUN_TESTS}"
@@ -364,6 +476,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
COMMAND "${Python3_EXECUTABLE}" "${RE2C_RUN_TESTS}" --wine -j1
)
add_dependencies(wtests re2c)
add_executable(re2c_test_list
src/test/list/test.cc
)
add_executable(re2c_test_range
src/test/range/test-impl.h
src/test/range/test.cc
@@ -381,9 +496,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
)
add_executable(re2c_test_argsubst
src/test/argsubst/test.cc
src/codegen/helpers.cc
)
add_custom_target(check_re2c
COMMAND ./re2c_test_list
COMMAND ./re2c_test_range
COMMAND ./re2c_test_s_to_n32_unsafe
COMMAND ./re2c_test_ver_to_vernum
@@ -508,12 +623,14 @@ if (RE2C_BUILD_LIBS)
endif()
# libre2c test
add_executable(test_libre2c lib/test.cc)
target_link_libraries(test_libre2c libre2c)
target_link_libraries(test_libre2c test_libre2c_objects_autogen)
add_custom_target(check_libre2c
COMMAND ./test_libre2c
)
if(RE2C_BUILD_TESTS)
add_executable(test_libre2c lib/test.cc)
target_link_libraries(test_libre2c libre2c)
target_link_libraries(test_libre2c test_libre2c_objects_autogen)
add_custom_target(check_libre2c
COMMAND ./test_libre2c
)
endif()
if(RE2C_BUILD_BENCHMARKS)
add_subdirectory(benchmarks/submatch_nfa)
@@ -522,15 +639,16 @@ if (RE2C_BUILD_LIBS)
endif()
else()
# empty check target
add_custom_target(check_libre2c)
if(RE2C_BUILD_TESTS)
add_custom_target(check_libre2c)
endif()
endif()
if(RE2C_BUILD_BENCHMARKS)
add_subdirectory(benchmarks/submatch_dfa_aot)
endif()
# only add check target if toplevel project
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
if(RE2C_BUILD_TESTS)
add_custom_target(check)
add_dependencies(check check_re2c check_libre2c)
endif()
+107 -11
View File
@@ -11,8 +11,16 @@
"hidden": true,
"installDir": "${sourceDir}/install-2",
"cacheVariables": {
"RE2C_BUILD_RE2D": true,
"RE2C_BUILD_RE2GO": true,
"RE2C_BUILD_RE2HS": true,
"RE2C_BUILD_RE2JAVA": true,
"RE2C_BUILD_RE2JS": true,
"RE2C_BUILD_RE2OCAML": true,
"RE2C_BUILD_RE2PY": true,
"RE2C_BUILD_RE2RUST": true,
"RE2C_BUILD_RE2V": true,
"RE2C_BUILD_RE2ZIG": true,
"RE2C_BUILD_LIBS": true,
"RE2C_REBUILD_LEXERS": true,
"RE2C_REBUILD_DOCS": true,
@@ -48,8 +56,16 @@
"CMAKE_BUILD_TYPE": "Ubsan",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -67,8 +83,16 @@
"CMAKE_BUILD_TYPE": "Asan",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -86,8 +110,16 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -111,8 +143,16 @@
"CMAKE_CXX_FLAGS": "-O2 -m32",
"CMAKE_EXE_LINKER_FLAGS": "-m32",
"CMAKE_SHARED_LINKER_FLAGS": "-m32",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -128,8 +168,16 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -177,8 +225,16 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -196,8 +252,16 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -213,8 +277,16 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -250,8 +322,16 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -267,8 +347,16 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -284,8 +372,16 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
+4
View File
@@ -47,6 +47,10 @@ with options `--enable-parsers` (Autotools) or `-DRE2C_REBUILD_PARSERS=ON`
(CMake). In this case `bison` must be installed on the system. Otherwise
Autoconf or CMake will fail at configuration stage.
For changes that affect syntax files, regeneration mode is configured
with options `--enable-syntax` (Autotools) or `-DRE2C_REBUILD_SYNTAX=ON`
(CMake).
For changes that update documentation, it is necessary to rebuild the bootstrap
manpages by reconfiguring and rebuilding re2c with options `--enable-docs`
(Autotools) or `-DRE2C_REBUILD_DOCS=ON` (CMake).
+1 -1
View File
@@ -41,6 +41,6 @@ requires some research. Does TDFA present any special difficulties?
## Location support
It would be good to have something like Bison locations (automatic tracking of
line/column/filename inforamtion). This is primarily useful for tokenizers and
line/column/filename information). This is primarily useful for tokenizers and
large lexers.
+487 -138
View File
@@ -130,146 +130,329 @@ re2c_SOURCES = \
$(re2c_SRC)
# autogenerated sources
re2c_GEN_HELP = src/msg/help.cc
re2c_GEN_LEX = src/parse/lex.cc
re2c_GEN_PARSER = src/parse/parser.cc
re2c_GEN_PARSER_HDR = src/parse/parser.h
re2c_GEN_VER_TO_VERNUM = src/msg/ver_to_vernum.cc
re2c_GEN_SRC = \
$(re2c_GEN_HELP) \
$(re2c_GEN_LEX) \
$(re2c_GEN_PARSER) \
$(re2c_GEN_VER_TO_VERNUM) \
src/parse/lex_conf.cc \
src/options/parse_opts.cc
src/default_syntax_c.cc \
src/default_syntax_d.cc \
src/default_syntax_go.cc \
src/default_syntax_haskell.cc \
src/default_syntax_java.cc \
src/default_syntax_js.cc \
src/default_syntax_ocaml.cc \
src/default_syntax_python.cc \
src/default_syntax_rust.cc \
src/default_syntax_v.cc \
src/default_syntax_zig.cc \
src/msg/ver_to_vernum.cc \
src/options/parse_opts.cc \
src/parse/lexer.cc \
src/parse/parser.cc \
src/parse/conf_lexer.cc \
src/parse/conf_parser.cc
re2c_GEN_HDR = \
src/parse/lex.h \
$(re2c_GEN_PARSER_HDR)
src/parse/parser.h \
src/parse/conf_parser.h \
src/parse/lexer.h
re2c_GEN = \
$(re2c_GEN_SRC) \
$(re2c_GEN_HDR)
nodist_re2c_SOURCES = $(re2c_GEN)
nodist_re2c_SOURCES = \
$(re2c_GEN) \
src/msg/help_re2c.cc
# custom rules create headers and must go before normal rules
BUILT_SOURCES = $(re2c_GEN_SRC)
# bootstrap sources
re2c_BOOT_PARSER = bootstrap/src/parse/parser.cc
re2c_BOOT_PARSER_HDR = bootstrap/src/parse/parser.h
re2c_BOOT_DOC_C = bootstrap/doc/re2c.1
re2c_BOOT_DOC_GO = bootstrap/doc/re2go.1
re2c_BOOT_DOC_RUST = bootstrap/doc/re2rust.1
re2c_BOOT_HELP = bootstrap/src/msg/help.cc
re2c_BOOT = \
$(re2c_BOOT_DOC_C) \
$(re2c_BOOT_DOC_GO) \
$(re2c_BOOT_DOC_RUST) \
$(re2c_BOOT_HELP) \
$(re2c_BOOT_PARSER) \
$(re2c_BOOT_PARSER_HDR) \
bootstrap/src/parse/lex.cc \
bootstrap/src/parse/lex.h \
bootstrap/src/parse/lex_conf.cc \
bootstrap/doc/re2c.1 \
bootstrap/doc/re2d.1 \
bootstrap/doc/re2go.1 \
bootstrap/doc/re2hs.1 \
bootstrap/doc/re2java.1 \
bootstrap/doc/re2js.1 \
bootstrap/doc/re2ocaml.1 \
bootstrap/doc/re2py.1 \
bootstrap/doc/re2rust.1 \
bootstrap/doc/re2v.1 \
bootstrap/doc/re2zig.1 \
bootstrap/src/default_syntax_c.cc \
bootstrap/src/default_syntax_d.cc \
bootstrap/src/default_syntax_go.cc \
bootstrap/src/default_syntax_haskell.cc \
bootstrap/src/default_syntax_java.cc \
bootstrap/src/default_syntax_js.cc \
bootstrap/src/default_syntax_ocaml.cc \
bootstrap/src/default_syntax_python.cc \
bootstrap/src/default_syntax_rust.cc \
bootstrap/src/default_syntax_v.cc \
bootstrap/src/default_syntax_zig.cc \
bootstrap/src/msg/help_re2c.cc \
bootstrap/src/msg/help_re2d.cc \
bootstrap/src/msg/help_re2go.cc \
bootstrap/src/msg/help_re2hs.cc \
bootstrap/src/msg/help_re2java.cc \
bootstrap/src/msg/help_re2js.cc \
bootstrap/src/msg/help_re2ocaml.cc \
bootstrap/src/msg/help_re2py.cc \
bootstrap/src/msg/help_re2rust.cc \
bootstrap/src/msg/help_re2v.cc \
bootstrap/src/msg/help_re2zig.cc \
bootstrap/src/msg/ver_to_vernum.cc \
bootstrap/src/options/parse_opts.cc \
bootstrap/src/msg/ver_to_vernum.cc
bootstrap/src/parse/lexer.cc \
bootstrap/src/parse/lexer.h \
bootstrap/src/parse/parser.cc \
bootstrap/src/parse/parser.h \
bootstrap/src/parse/conf_lexer.cc \
bootstrap/src/parse/conf_parser.h \
bootstrap/src/parse/conf_parser.cc
# custom sources
re2c_CUSTOM_PARSER = src/parse/parser.ypp
re2c_CUSTOM_HELP = doc/help.rst
re2c_CUSTOM = \
$(re2c_CUSTOM_PARSER) \
$(re2c_CUSTOM_HELP) \
src/parse/lex.re \
src/parse/lex_conf.re \
src/msg/ver_to_vernum.re \
src/options/parse_opts.re \
src/msg/ver_to_vernum.re
src/parse/lexer.re \
src/parse/parser.ypp \
src/parse/conf_lexer.re \
src/parse/conf_parser.ypp
# docs
re2c_SRC_DOC = doc/manpage.rst
# To build the list of examples for all backends, run:
# find examples -regex '.*\.re\|.*\(state\|01_basic\|definitions\)\..*' -printf '\t%p \\\n' | sort
re2c_SRC_DOC_EXT = \
doc/manual/api/interface.rst_ \
doc/manual/conditions/blocks.rst_ \
doc/manual/conditions/conditions.rst_ \
doc/manual/configurations/configurations.rst_ \
doc/manual/directives/directives.rst_ \
doc/manual/dot/dot.rst_ \
doc/manual/encodings/encodings.rst_ \
doc/manual/basics/api/api1.rst_ \
doc/manual/basics/api/api2_c.rst_ \
doc/manual/basics/api/api2_go.rst_ \
doc/manual/basics/api/api2_rust.rst_ \
doc/manual/basics/api/api3.rst_ \
doc/manual/basics/blocks.rst_ \
doc/manual/basics/directives.rst_ \
doc/manual/basics/configurations.rst_ \
doc/manual/basics/regular_expressions.rst_ \
doc/manual/basics/syntax.rst_ \
doc/manual/basics/syntax_files.rst_ \
doc/manual/basics/options/debug.rst_ \
doc/manual/basics/options/internal.rst_ \
doc/manual/basics/options/options.rst_ \
doc/manual/basics/warnings/warnings_general.rst_ \
doc/manual/basics/warnings/warnings_list.rst_ \
doc/manual/eof/01_sentinel.rst_ \
doc/manual/eof/02_bounds_checking.rst_ \
doc/manual/eof/03_eof_rule.rst_ \
doc/manual/eof/04_generic_api.rst_ \
doc/manual/eof/04_fake_sentinel.rst_ \
doc/manual/eof/eof.rst_ \
doc/manual/features/conditions/blocks.rst_ \
doc/manual/features/conditions/conditions.rst_ \
doc/manual/features/dot/dot.rst_ \
doc/manual/features/encodings/encodings.rst_ \
doc/manual/features/headers/headers.rst_ \
doc/manual/features/includes/includes.rst_ \
doc/manual/features/reuse/reuse.rst_ \
doc/manual/features/skeleton/skeleton.rst_ \
doc/manual/features/state/state.rst_ \
doc/manual/features/submatch/submatch_example_mtags.rst_ \
doc/manual/features/submatch/submatch_example_captures.rst_ \
doc/manual/features/submatch/submatch_example_stags_fill.rst_ \
doc/manual/features/submatch/submatch_example_stags.rst_ \
doc/manual/features/submatch/submatch.rst_ \
doc/manual/fill/01_fill.rst_ \
doc/manual/fill/02_fill.rst_ \
doc/manual/fill/fill.rst_ \
doc/manual/headers/headers.rst_ \
doc/manual/includes/includes.rst_ \
doc/manual/options/debug.rst_ \
doc/manual/options/internal.rst_ \
doc/manual/options/options.rst_ \
doc/manual/regexps/regular_expressions.rst_ \
doc/manual/reuse/reuse.rst_ \
doc/manual/skeleton/skeleton.rst_ \
doc/manual/state/state.rst_ \
doc/manual/submatch/submatch_example_mtags.rst_ \
doc/manual/submatch/submatch_example_posix.rst_ \
doc/manual/submatch/submatch_example_stags_fill.rst_ \
doc/manual/submatch/submatch_example_stags.rst_ \
doc/manual/submatch/submatch.rst_ \
doc/manual/authors.rst_ \
doc/manual/intro.rst_ \
doc/manual/synopsis.rst_ \
doc/manual/syntax/api1.rst_ \
doc/manual/syntax/api2_c.rst_ \
doc/manual/syntax/api2_go.rst_ \
doc/manual/syntax/api2_rust.rst_ \
doc/manual/syntax/api3.rst_ \
doc/manual/syntax/intro.rst_ \
doc/manual/syntax/syntax.rst_ \
doc/manual/warnings/warnings_general.rst_ \
doc/manual/warnings/warnings_list.rst_ \
examples/c/01_basic.re \
examples/c/01_basic.c \
examples/c/01_basic.re \
examples/c/conditions/parse_u32_blocks.re \
examples/c/conditions/parse_u32_conditions.re \
examples/c/encodings/unicode_identifier.re \
examples/c/eof/01_sentinel.re \
examples/c/eof/02_bounds_checking.re \
examples/c/eof/03_eof_rule.re \
examples/c/eof/05_generic_api_eof_rule.re \
examples/c/eof/04_fake_sentinel.re \
examples/c/eof/05_fake_sentinel_eof_rule.re \
examples/c/fill/01_fill.re \
examples/c/fill/02_fill.re \
examples/c/generic_api/ifstream.re \
examples/c/headers/header.re \
examples/c/headers/lexer/state.h \
examples/c/includes/include.re \
examples/c/includes/definitions.h \
examples/c/includes/include.re \
examples/c/real_world/cxx98.re \
examples/c/reuse/braille.re \
examples/c/reuse/reuse.re \
examples/c/reuse/usedir.re \
examples/c/state/push.re \
examples/c/submatch/01_stags_fill.re \
examples/c/submatch/01_stags.re \
examples/c/submatch/02_mtags.re \
examples/c/submatch/03_posix.re \
examples/go/01_basic.re \
examples/c/submatch/03_captures.re \
examples/c/submatch/04_posix_captures.re \
examples/c/submatch/http_rfc7230.re \
examples/c/submatch/parse_etc_passwd.re \
examples/c/submatch/parse_options.re \
examples/c/submatch/parse_records.re \
examples/c/submatch/uri_rfc3986.re \
examples/d/01_basic.d \
examples/d/01_basic.re \
examples/d/conditions/parse_u32_blocks.re \
examples/d/conditions/parse_u32_conditions.re \
examples/d/encodings/unicode_identifier.re \
examples/d/eof/01_sentinel.re \
examples/d/eof/02_bounds_checking.re \
examples/d/eof/03_eof_rule.re \
examples/d/eof/04_fake_sentinel.re \
examples/d/fill/01_fill.re \
examples/d/fill/02_fill.re \
examples/d/headers/header.re \
examples/d/headers/lexer/state.d \
examples/d/includes/definitions.d \
examples/d/includes/include.re \
examples/d/reuse/reuse.re \
examples/d/reuse/usedir.re \
examples/d/state/push.re \
examples/d/submatch/01_stags_fill.re \
examples/d/submatch/01_stags.re \
examples/d/submatch/02_mtags.re \
examples/d/submatch/03_captures.re \
examples/d/submatch/04_posix_captures.re \
examples/go/01_basic.go \
examples/go/01_basic.re \
examples/go/conditions/parse_u32_blocks.re \
examples/go/conditions/parse_u32_conditions.re \
examples/go/encodings/unicode_identifier.re \
examples/go/eof/01_sentinel.re \
examples/go/eof/02_bounds_checking.re \
examples/go/eof/03_eof_rule.re \
examples/go/eof/05_generic_api_eof_rule.re \
examples/go/eof/04_fake_sentinel.re \
examples/go/fill/01_fill.re \
examples/go/fill/02_fill.re \
examples/go/headers/header.re \
examples/go/headers/lexer/state.go \
examples/go/includes/include.re \
examples/go/includes/definitions.go \
examples/go/includes/include.re \
examples/go/reuse/reuse.re \
examples/go/reuse/usedir.re \
examples/go/state/push.re \
examples/go/submatch/01_stags_fill.re \
examples/go/submatch/01_stags.re \
examples/go/submatch/02_mtags.re \
examples/go/submatch/03_posix.re \
examples/go/submatch/03_captures.re \
examples/go/submatch/04_posix_captures.re \
examples/haskell/01_basic.hs \
examples/haskell/01_basic.re \
examples/haskell/conditions/parse_u32_blocks.re \
examples/haskell/conditions/parse_u32_conditions.re \
examples/haskell/encodings/unicode_identifier.re \
examples/haskell/eof/01_sentinel.re \
examples/haskell/eof/02_bounds_checking.re \
examples/haskell/eof/03_eof_rule.re \
examples/haskell/eof/04_fake_sentinel.re \
examples/haskell/fill/01_fill.re \
examples/haskell/fill/02_fill.re \
examples/haskell/headers/header.re \
examples/haskell/headers/lexer/state.hs \
examples/haskell/includes/definitions.hs \
examples/haskell/includes/include.re \
examples/haskell/reuse/reuse.re \
examples/haskell/reuse/usedir.re \
examples/haskell/state/push.re \
examples/haskell/submatch/01_stags_fill.re \
examples/haskell/submatch/01_stags.re \
examples/haskell/submatch/02_mtags.re \
examples/haskell/submatch/03_captures.re \
examples/java/01_basic.java \
examples/java/01_basic.re \
examples/java/conditions/parse_u32_blocks.re \
examples/java/conditions/parse_u32_conditions.re \
examples/java/encodings/unicode_identifier.re \
examples/java/eof/01_sentinel.re \
examples/java/eof/02_bounds_checking.re \
examples/java/eof/03_eof_rule.re \
examples/java/eof/04_fake_sentinel.re \
examples/java/fill/01_fill.re \
examples/java/fill/02_fill.re \
examples/java/headers/header.re \
examples/java/headers/lexer/state.java \
examples/java/includes/definitions.java \
examples/java/includes/include.re \
examples/java/reuse/reuse.re \
examples/java/reuse/usedir.re \
examples/java/state/push.re \
examples/java/submatch/01_stags_fill.re \
examples/java/submatch/01_stags.re \
examples/java/submatch/02_mtags.re \
examples/java/submatch/03_captures.re \
examples/java/submatch/04_posix_captures.re \
examples/js/01_basic.js \
examples/js/01_basic.re \
examples/js/conditions/parse_u32_blocks.re \
examples/js/conditions/parse_u32_conditions.re \
examples/js/encodings/unicode_identifier.re \
examples/js/eof/01_sentinel.re \
examples/js/eof/02_bounds_checking.re \
examples/js/eof/03_eof_rule.re \
examples/js/eof/04_fake_sentinel.re \
examples/js/fill/01_fill.re \
examples/js/fill/02_fill.re \
examples/js/headers/header.re \
examples/js/headers/lexer/state.js \
examples/js/includes/definitions.js \
examples/js/includes/include.re \
examples/js/reuse/reuse.re \
examples/js/reuse/usedir.re \
examples/js/state/push.re \
examples/js/submatch/01_stags_fill.re \
examples/js/submatch/01_stags.re \
examples/js/submatch/02_mtags.re \
examples/js/submatch/03_captures.re \
examples/js/submatch/04_posix_captures.re \
examples/ocaml/01_basic.ml \
examples/ocaml/01_basic.re \
examples/ocaml/conditions/parse_u32_blocks.re \
examples/ocaml/conditions/parse_u32_conditions.re \
examples/ocaml/encodings/unicode_identifier.re \
examples/ocaml/eof/01_sentinel.re \
examples/ocaml/eof/02_bounds_checking.re \
examples/ocaml/eof/03_eof_rule.re \
examples/ocaml/eof/04_fake_sentinel.re \
examples/ocaml/fill/01_fill.re \
examples/ocaml/fill/02_fill.re \
examples/ocaml/headers/header.re \
examples/ocaml/headers/lexer/state.ml \
examples/ocaml/includes/definitions.ml \
examples/ocaml/includes/include.re \
examples/ocaml/reuse/reuse.re \
examples/ocaml/reuse/usedir.re \
examples/ocaml/state/push.re \
examples/ocaml/submatch/01_stags_fill.re \
examples/ocaml/submatch/01_stags.re \
examples/ocaml/submatch/02_mtags.re \
examples/ocaml/submatch/03_captures.re \
examples/ocaml/submatch/04_posix_captures.re \
examples/python/01_basic.py \
examples/python/01_basic.re \
examples/python/conditions/parse_u32_blocks.re \
examples/python/conditions/parse_u32_conditions.re \
examples/python/encodings/unicode_identifier.re \
examples/python/eof/01_sentinel.re \
examples/python/eof/02_bounds_checking.re \
examples/python/eof/03_eof_rule.re \
examples/python/eof/04_fake_sentinel.re \
examples/python/fill/01_fill.re \
examples/python/fill/02_fill.re \
examples/python/headers/header.re \
examples/python/headers/lexer/state.py \
examples/python/includes/definitions.py \
examples/python/includes/include.re \
examples/python/reuse/reuse.re \
examples/python/reuse/usedir.re \
examples/python/state/push.re \
examples/python/submatch/01_stags_fill.re \
examples/python/submatch/01_stags.re \
examples/python/submatch/02_mtags.re \
examples/python/submatch/03_captures.re \
examples/python/submatch/04_posix_captures.re \
examples/rust/01_basic.re \
examples/rust/01_basic.rs \
examples/rust/conditions/parse_u32_blocks.re \
@@ -278,50 +461,152 @@ re2c_SRC_DOC_EXT = \
examples/rust/eof/01_sentinel.re \
examples/rust/eof/02_bounds_checking.re \
examples/rust/eof/03_eof_rule.re \
examples/rust/eof/05_generic_api_eof_rule.re \
examples/rust/eof/04_fake_sentinel.re \
examples/rust/fill/01_fill.re \
examples/rust/fill/02_fill.re \
examples/rust/headers/header.re \
examples/rust/headers/lexer/state.rs \
examples/rust/includes/include.re \
examples/rust/includes/definitions.rs \
examples/rust/includes/include.re \
examples/rust/real_world/c.re \
examples/rust/reuse/reuse.re \
examples/rust/reuse/usedir.re \
examples/rust/state/push.re \
examples/rust/submatch/01_stags_fill.re \
examples/rust/submatch/01_stags.re \
examples/rust/submatch/02_mtags.re \
examples/rust/submatch/03_posix.re
DOC_C = doc/re2c.1
DOCS = $(DOC_C)
examples/rust/submatch/03_captures.re \
examples/rust/submatch/04_posix_captures.re \
examples/v/01_basic.re \
examples/v/01_basic.v \
examples/v/conditions/parse_u32_blocks.re \
examples/v/conditions/parse_u32_conditions.re \
examples/v/encodings/unicode_identifier.re \
examples/v/eof/01_sentinel.re \
examples/v/eof/02_bounds_checking.re \
examples/v/eof/03_eof_rule.re \
examples/v/eof/04_fake_sentinel.re \
examples/v/fill/01_fill.re \
examples/v/fill/02_fill.re \
examples/v/headers/header.re \
examples/v/headers/lexer/state.v \
examples/v/includes/definitions.v \
examples/v/includes/include.re \
examples/v/reuse/reuse.re \
examples/v/reuse/usedir.re \
examples/v/state/push.re \
examples/v/submatch/01_stags_fill.re \
examples/v/submatch/01_stags.re \
examples/v/submatch/02_mtags.re \
examples/v/submatch/03_captures.re \
examples/v/submatch/04_posix_captures.re \
examples/zig/01_basic.re \
examples/zig/01_basic.zig \
examples/zig/conditions/parse_u32_blocks.re \
examples/zig/conditions/parse_u32_conditions.re \
examples/zig/encodings/unicode_identifier.re \
examples/zig/eof/01_sentinel.re \
examples/zig/eof/02_bounds_checking.re \
examples/zig/eof/03_eof_rule.re \
examples/zig/eof/04_fake_sentinel.re \
examples/zig/fill/01_fill.re \
examples/zig/fill/02_fill.re \
examples/zig/headers/header.re \
examples/zig/headers/lexer/state.zig \
examples/zig/includes/definitions.zig \
examples/zig/includes/include.re \
examples/zig/reuse/reuse.re \
examples/zig/reuse/usedir.re \
examples/zig/state/push.re \
examples/zig/submatch/01_stags_fill.re \
examples/zig/submatch/01_stags.re \
examples/zig/submatch/02_mtags.re \
examples/zig/submatch/03_captures.re \
examples/zig/submatch/04_posix_captures.re
DOCS = doc/re2c.1
HELP = src/msg/help_re2c.cc
if WITH_DLANG
DOCS += doc/re2d.1
HELP += src/msg/help_re2d.cc
endif
if WITH_GOLANG
DOC_GO = doc/re2go.1
DOCS += $(DOC_GO)
DOCS += doc/re2go.1
HELP += src/msg/help_re2go.cc
endif
if WITH_HASKELL
DOCS += doc/re2hs.1
HELP += src/msg/help_re2hs.cc
endif
if WITH_JAVA
DOCS += doc/re2java.1
HELP += src/msg/help_re2java.cc
endif
if WITH_JS
DOCS += doc/re2js.1
HELP += src/msg/help_re2js.cc
endif
if WITH_OCAML
DOCS += doc/re2ocaml.1
HELP += src/msg/help_re2ocaml.cc
endif
if WITH_PYTHON
DOCS += doc/re2py.1
HELP += src/msg/help_re2py.cc
endif
if WITH_RUST
DOC_RUST = doc/re2rust.1
DOCS += $(DOC_RUST)
DOCS += doc/re2rust.1
HELP += src/msg/help_re2rust.cc
endif
if WITH_VLANG
DOCS += doc/re2v.1
HELP += src/msg/help_re2v.cc
endif
if WITH_ZIG
DOCS += doc/re2zig.1
HELP += src/msg/help_re2zig.cc
endif
BUILT_SOURCES += $(HELP)
man_MANS = $(DOCS)
# include files (stdlib)
dist_stdlib_DATA = include/unicode_categories.re
dist_stdlib_DATA = \
include/syntax/c \
include/syntax/d \
include/syntax/go \
include/syntax/haskell \
include/syntax/java \
include/syntax/js \
include/syntax/ocaml \
include/syntax/python \
include/syntax/rust \
include/syntax/v \
include/syntax/zig \
include/unicode_categories.re
BAZELFILES := \
BUILD.bazel \
WORKSPACE \
bazel
CMAKEFILES := \
CMakeLists.txt \
CMakePresets.json \
cmake
EXTRA_DIST = \
$(re2c_BOOT) \
$(re2c_CUSTOM) \
$(re2c_SRC_DOC_EXT) \
$(BAZELFILES) \
$(CMAKEFILES) \
BUILD.md \
CHANGELOG \
CONTRIBUTING.md \
IDEAS.md \
LICENSE \
MAINTAINERS.md \
NO_WARRANTY \
README.md \
autogen.sh \
@@ -331,14 +616,31 @@ EXTRA_DIST = \
CLEANFILES = \
$(re2c_GEN) \
$(DOCS)
$(re2c_GEN_HELP) \
$(DOCS) \
$(HELP)
if REBUILD_SYNTAX
STX2CPP = $(top_srcdir)/build/stx2cpp.py
# generate C++ sources from syntax configs and update bootstrap files
.stx.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(STX2CPP) $< $@
$(AM_V_GEN)cp -f $@ $(top_srcdir)/bootstrap/$@
else
# copy bootstrap files
.stx.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $(@D)
$(AM_V_at)echo "Reconfigure with --enable-syntax to regenerate $@"
endif
if REBUILD_LEXERS
# generate lexer and update bootstrap files
.re.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(RE2C_FOR_BUILD) $(RE2CFLAGS) -o $@ $<
$(AM_V_GEN)cp $(@:cc=[ch]*) $(top_srcdir)/bootstrap/$(@D);
$(AM_V_GEN)cp $(@:cc=[ch]*) $(top_srcdir)/bootstrap/$(@D)
else
# copy bootstrap files
.re.cc:
@@ -352,17 +654,18 @@ if REBUILD_PARSERS
.ypp.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(BISON) --warnings --output=$@ --defines=$(@:cc=h) $<
$(AM_V_GEN)cp $@ $(@:cc=h) $(top_srcdir)/bootstrap/$(@D);
$(AM_V_GEN)cp $@ $(@:cc=h) $(top_srcdir)/bootstrap/$(@D)
else
# copy bootstrap files
.ypp.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D);
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D)
$(AM_V_at)echo "Reconfigure with --enable-parsers to regenerate $@"
endif
# lexer depends on bison-generated header
$(re2c_GEN_LEX): $(re2c_GEN_PARSER)
# re2c-generated lexer depends on bison-generated parser header (generated by the parser rule)
src/parse/lexer.cc : src/parse/parser.cc
src/parse/conf_lexer.cc : src/parse/conf_parser.cc
# rebuild all re2c sources using newly built re2c
.PHONY: bootstrap
@@ -372,55 +675,33 @@ bootstrap: all
.PHONY: docs
if REBUILD_DOCS
docs: $(DOCS) $(re2c_GEN_HELP)
RST2TXT = $(top_srcdir)/build/rst2txt.py
RST2MAN = $(top_srcdir)/build/rst2man.py
SPLITMAN = $(top_srcdir)/build/split_man.py
# generate manpage for C
$(DOC_C): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
docs: $(DOCS) $(HELP) $(SPLITMAN) $(RST2MAN) $(RST2TXT)
# generate manpage
.rst.1:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).c c \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).c > $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_C) \
&& rm $(top_builddir)/$(re2c_SRC_DOC).c
# generate manpage for Go
$(DOC_GO): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).go go \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).go > $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_GO) \
&& rm $(top_builddir)/$(re2c_SRC_DOC).go
# generate manpage for Rust
$(DOC_RUST): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).rust rust \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).rust > $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_RUST) \
&& rm $(top_builddir)/$(re2c_SRC_DOC).rust
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$< $(top_builddir)/$< \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$< > $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@
# generate help
$(re2c_GEN_HELP): $(re2c_CUSTOM_HELP) $(re2c_SRC_DOC_EXT) $(RST2TXT)
.rst.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(RST2TXT) --variable-name=help $(top_builddir)/$(re2c_CUSTOM_HELP) $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_HELP)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$< $(top_builddir)/$< \
&& $(PYTHON) $(RST2TXT) --variable-name=help $(top_builddir)/$< $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@
else
docs: $(DOCS) $(re2c_GEN_HELP)
docs: $(DOCS) $(HELP)
$(AM_V_at)echo "Reconfigure with --enable-docs to rebuild docs"
# copy bootstrap manpage for C
$(DOC_C): $(re2c_BOOT_DOC_C)
# copy bootstrap manpage
.rst.1:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_C) $@
# copy bootstrap manpage for Go
$(DOC_GO): $(re2c_BOOT_DOC_GO)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_GO) $@
# copy bootstrap manpage for Rust
$(DOC_RUST): $(re2c_BOOT_DOC_RUST)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_RUST) $@
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $@
# copy bootstrap help
$(re2c_GEN_HELP): $(re2c_BOOT_HELP)
.rst.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_HELP) $@
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $@
endif
all-local: docs $(re2c_BOOT_PARSER)
@@ -437,6 +718,9 @@ vtests: all $(re2c_TESTSUITE)
wtests: all $(re2c_TESTSUITE)
$(PYTHON) $(top_builddir)/$(re2c_TESTSUITE) --wine -j1
re2c_test_list_SOURCES = \
src/test/list/test.cc
re2c_test_range_SOURCES = \
src/test/range/test-impl.h \
src/test/range/test.cc \
@@ -450,12 +734,13 @@ re2c_test_s_to_n32_unsafe_SOURCES = \
re2c_test_ver_to_vernum_SOURCES = \
src/test/ver_to_vernum/test.cc \
$(re2c_GEN_VER_TO_VERNUM)
src/msg/ver_to_vernum.cc
re2c_test_argsubst_SOURCES = \
src/test/argsubst/test.cc
check_PROGRAMS = \
re2c_test_list \
re2c_test_range \
re2c_test_s_to_n32_unsafe \
re2c_test_ver_to_vernum \
@@ -478,18 +763,82 @@ lib_LTLIBRARIES =
include $(top_srcdir)/Makefile.lib.am
endif
# re2d
if WITH_DLANG
bin_PROGRAMS += re2d
re2d_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::D -DRE2C_PROG=\"re2d\"
re2d_SOURCES = $(re2c_SOURCES)
nodist_re2d_SOURCES = $(re2c_GEN) src/msg/help_re2d.cc
endif
# re2go
if WITH_GOLANG
bin_PROGRAMS += re2go
re2go_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::GO
re2go_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::GO -DRE2C_PROG=\"re2go\"
re2go_SOURCES = $(re2c_SOURCES)
nodist_re2go_SOURCES = $(nodist_re2c_SOURCES)
nodist_re2go_SOURCES = $(re2c_GEN) src/msg/help_re2go.cc
endif
# re2hs
if WITH_HASKELL
bin_PROGRAMS += re2hs
re2hs_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::HASKELL -DRE2C_PROG=\"re2hs\"
re2hs_SOURCES = $(re2c_SOURCES)
nodist_re2hs_SOURCES = $(re2c_GEN) src/msg/help_re2hs.cc
endif
# re2java
if WITH_JAVA
bin_PROGRAMS += re2java
re2java_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::JAVA -DRE2C_PROG=\"re2java\"
re2java_SOURCES = $(re2c_SOURCES)
nodist_re2java_SOURCES = $(re2c_GEN) src/msg/help_re2java.cc
endif
# re2js
if WITH_JS
bin_PROGRAMS += re2js
re2js_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::JS -DRE2C_PROG=\"re2js\"
re2js_SOURCES = $(re2c_SOURCES)
nodist_re2js_SOURCES = $(re2c_GEN) src/msg/help_re2js.cc
endif
# re2ocaml
if WITH_OCAML
bin_PROGRAMS += re2ocaml
re2ocaml_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::OCAML -DRE2C_PROG=\"re2ocaml\"
re2ocaml_SOURCES = $(re2c_SOURCES)
nodist_re2ocaml_SOURCES = $(re2c_GEN) src/msg/help_re2ocaml.cc
endif
# re2py
if WITH_PYTHON
bin_PROGRAMS += re2py
re2py_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::PYTHON -DRE2C_PROG=\"re2py\"
re2py_SOURCES = $(re2c_SOURCES)
nodist_re2py_SOURCES = $(re2c_GEN) src/msg/help_re2py.cc
endif
# re2rust
if WITH_RUST
bin_PROGRAMS += re2rust
re2rust_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::RUST
re2rust_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::RUST -DRE2C_PROG=\"re2rust\"
re2rust_SOURCES = $(re2c_SOURCES)
nodist_re2rust_SOURCES = $(nodist_re2c_SOURCES)
nodist_re2rust_SOURCES = $(re2c_GEN) src/msg/help_re2rust.cc
endif
# re2v
if WITH_VLANG
bin_PROGRAMS += re2v
re2v_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::V -DRE2C_PROG=\"re2v\"
re2v_SOURCES = $(re2c_SOURCES)
nodist_re2v_SOURCES = $(re2c_GEN) src/msg/help_re2v.cc
endif
# re2zig
if WITH_ZIG
bin_PROGRAMS += re2zig
re2zig_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::ZIG -DRE2C_PROG=\"re2zig\"
re2zig_SOURCES = $(re2c_SOURCES)
nodist_re2zig_SOURCES = $(re2c_GEN) src/msg/help_re2zig.cc
endif
-1
View File
@@ -38,7 +38,6 @@ libre2c_la_HDR = \
src/regexp/regexp.h \
src/regexp/rule.h \
src/regexp/tag.h \
src/compile.h \
src/skeleton/path.h \
src/skeleton/skeleton.h \
src/parse/ast.h \
+14
View File
@@ -0,0 +1,14 @@
workspace(name = "re2c")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
],
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
+13
View File
@@ -0,0 +1,13 @@
package(default_visibility = ["//visibility:private"])
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
exports_files([
"re2c_config.h",
])
bzl_library(
name = "re2c_bzl",
srcs = ["re2c.bzl"],
visibility = ["//visibility:public"],
)
+70
View File
@@ -0,0 +1,70 @@
# re2c generator rules - assuming that re2c is available as '@re2c//:re2c'.
load("@bazel_skylib//lib:paths.bzl", "paths")
visibility("public")
# Define supported extensions as defined by:
# . https://bazel.build/reference/be/c-cpp#cc_library_args
# . https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
_C_SRC_EXT = [".c", ".cc", ".cpp", ".cxx", ".c++", ".C", ".cu", ".cl"]
_C_HDR_EXT = [".h", ".hh", ".hpp", ".ipp", ".hxx", ".h++", ".inc", ".inl", ".tlh", ".tli", ".H", ".tcc"]
_RE2C_EXT = [".re", ".re2c"]
def _re2c_impl(ctx):
srcs = ctx.files.srcs
if len(srcs) != 1:
fail("Attribute `srcs` must contain exactly 1 re2c source file ({exts}).".format(exts = ", ".join(_RE2C_EXT)))
outs = ctx.outputs.outs
if not outs or [o for o in outs if paths.split_extension(o.path)[1] not in _C_SRC_EXT + _C_HDR_EXT]:
fail("Attribute `outs` must contain at least 1 C/C++ shource or header file ({exts}).".format(exts = ", ".join(_C_SRC_EXT + _C_HDR_EXT)))
ctx.actions.run_shell(
outputs = outs,
tools = [ctx.executable._re2c_tool],
inputs = ctx.files.srcs + ctx.files.data,
command = """
"{re2c}" "{src}" -o "{out}" {re2c_args} {includes}
""".format(
re2c = ctx.executable._re2c_tool.path,
src = srcs[0].path,
out = outs[0].path,
includes = " ".join(list(dict([("-I" + f.dirname, 1) for f in ctx.files.data]))),
re2c_args = " ".join(ctx.attr.re2c_args),
),
mnemonic = "RE2C",
progress_message = "Generating re2c %{label}",
)
_re2c_attr = {
"srcs": attr.label_list(
doc = "The re2c source.",
allow_files = _RE2C_EXT,
mandatory = True,
),
"data": attr.label_list(
doc = "Other input data files (e.g. include files).",
allow_files = _C_SRC_EXT + _C_HDR_EXT,
mandatory = False,
),
"outs": attr.output_list(
doc = "The generated output source.",
mandatory = True,
),
"re2c_args": attr.string_list(
doc = "Arguments to re2c invocation.",
),
"_re2c_tool": attr.label(
doc = "The target of the 're2c' executable.",
default = Label("//:re2c"),
allow_single_file = True,
executable = True,
cfg = "exec",
),
}
re2c_gen = rule(
attrs = _re2c_attr,
doc = """Use re2c tool to create an output file (e.g. '.cc') from a '.re' input.""",
output_to_genfiles = True,
implementation = _re2c_impl,
)
+4
View File
@@ -0,0 +1,4 @@
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_FCNTL_H 1
#define HAVE_UNISTD_H 1
@@ -12,6 +12,9 @@ target_link_libraries(bench_submatch_dfa_jit benchmark::benchmark)
find_path(RE2_INCLUDE_DIRECTORY "re2/re2.h")
find_library(RE2_LIBRARY re2)
if(RE2_INCLUDE_DIRECTORY AND RE2_LIBRARY)
set_target_properties(bench_submatch_dfa_jit PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)
target_compile_definitions(bench_submatch_dfa_jit PRIVATE "HAVE_RE2_RE2_H=1")
target_include_directories(bench_submatch_dfa_jit PRIVATE "${RE2_INCLUDE_DIRECTORY}")
target_link_libraries(bench_submatch_dfa_jit "${RE2_LIBRARY}")
+3
View File
@@ -12,6 +12,9 @@ target_link_libraries(bench_submatch_nfa benchmark::benchmark)
find_path(RE2_INCLUDE_DIRECTORY "re2/re2.h")
find_library(RE2_LIBRARY re2)
if(RE2_INCLUDE_DIRECTORY AND RE2_LIBRARY)
set_target_properties(bench_submatch_nfa PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)
target_compile_definitions(bench_submatch_nfa PRIVATE "HAVE_RE2_RE2_H=1")
target_include_directories(bench_submatch_nfa PRIVATE "${RE2_INCLUDE_DIRECTORY}")
target_link_libraries(bench_submatch_nfa "${RE2_LIBRARY}")
+1953 -1209
View File
File diff suppressed because it is too large Load Diff
+4160
View File
File diff suppressed because it is too large Load Diff
+2124 -1461
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2140 -1501
View File
File diff suppressed because it is too large Load Diff
+4198
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+62 -64
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 3.0 */
/* Generated by re2c 4.0 */
#line 1 "../lib/lex.re"
#include <stdint.h>
#include <stdio.h>
@@ -20,7 +20,7 @@ static int32_t lex_cls_chr(const uint8_t*&, uint32_t&);
#line 27 "../lib/lex.re"
int lex(YYSTYPE* yylval, const uint8_t*& cur, Ast& ast) {
int lex(RE2C_LIB_STYPE* yylval, const uint8_t*& cur, Ast& ast) {
#line 26 "lib/lex.cc"
const uint8_t* yyt1;const uint8_t* yyt2;
@@ -34,39 +34,39 @@ const uint8_t* yyt1;const uint8_t* yyt2;
#line 35 "lib/lex.cc"
{
uint8_t yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
static const unsigned char yybm[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
yych = *cur;
if (yych <= '>') {
@@ -152,9 +152,7 @@ yy9:
#line 153 "lib/lex.cc"
yy10:
yych = *++cur;
if (yybm[0+yych] & 128) {
goto yy10;
}
if (yybm[0+yych] & 128) goto yy10;
if (yych == ',') goto yy12;
if (yych == '}') goto yy13;
yy11:
@@ -178,7 +176,7 @@ yy13:
yylval->bounds.max = yylval->bounds.min;
return TOKEN_COUNT;
}
#line 182 "lib/lex.cc"
#line 180 "lib/lex.cc"
yy14:
yych = *++cur;
if (yych <= '/') goto yy11;
@@ -194,7 +192,7 @@ yy15:
yylval->bounds.max = Ast::MANY;
return TOKEN_COUNT;
}
#line 198 "lib/lex.cc"
#line 196 "lib/lex.cc"
yy16:
++cur;
x = yyt1;
@@ -205,7 +203,7 @@ yy16:
|| !s_to_u32_unsafe(y, cur - 1, yylval->bounds.max)) goto err_cnt;
return TOKEN_COUNT;
}
#line 209 "lib/lex.cc"
#line 207 "lib/lex.cc"
}
#line 78 "../lib/lex.re"
@@ -213,7 +211,7 @@ yy16:
cls:
if (lex_cls_chr(cur, l) != 0) goto err;
#line 217 "lib/lex.cc"
#line 215 "lib/lex.cc"
{
uint8_t yych;
yych = *(mar = cur);
@@ -221,7 +219,7 @@ cls:
yy18:
#line 83 "../lib/lex.re"
{ u = l; goto add; }
#line 225 "lib/lex.cc"
#line 223 "lib/lex.cc"
yy19:
yych = *++cur;
if (yych != ']') goto yy20;
@@ -232,7 +230,7 @@ yy20:
cur -= 1;
#line 84 "../lib/lex.re"
{ if (lex_cls_chr(cur, u) != 0) goto err; goto add; }
#line 236 "lib/lex.cc"
#line 234 "lib/lex.cc"
}
#line 85 "../lib/lex.re"
@@ -240,14 +238,14 @@ add:
if (l > u) goto err;
ast.temp_ranges.push_back(AstRange(l, u, NOWHERE));
#line 244 "lib/lex.cc"
#line 242 "lib/lex.cc"
{
uint8_t yych;
yych = *cur;
if (yych == ']') goto yy22;
#line 90 "../lib/lex.re"
{ goto cls; }
#line 251 "lib/lex.cc"
#line 249 "lib/lex.cc"
yy22:
++cur;
#line 91 "../lib/lex.re"
@@ -255,7 +253,7 @@ yy22:
yylval->regexp = ast.cls(NOWHERE, neg);
return TOKEN_REGEXP;
}
#line 259 "lib/lex.cc"
#line 257 "lib/lex.cc"
}
#line 95 "../lib/lex.re"
@@ -272,7 +270,7 @@ err_cnt:
int32_t lex_cls_chr(const uint8_t*& cur, uint32_t& c) {
const uint8_t* mar, *p = cur;
#line 276 "lib/lex.cc"
#line 274 "lib/lex.cc"
{
uint8_t yych;
yych = *cur;
@@ -285,13 +283,13 @@ yy24:
++cur;
#line 109 "../lib/lex.re"
{ return 1; }
#line 289 "lib/lex.cc"
#line 287 "lib/lex.cc"
yy25:
++cur;
yy26:
#line 127 "../lib/lex.re"
{ c = cur[-1]; return 0; }
#line 295 "lib/lex.cc"
#line 293 "lib/lex.cc"
yy27:
yych = *++cur;
if (yych <= '9') {
@@ -320,67 +318,67 @@ yy28:
yy29:
#line 116 "../lib/lex.re"
{ c = '\\'_u8; return 0; }
#line 324 "lib/lex.cc"
#line 322 "lib/lex.cc"
yy30:
++cur;
#line 110 "../lib/lex.re"
{ error("collating characters not supported"); return 1; }
#line 329 "lib/lex.cc"
#line 327 "lib/lex.cc"
yy31:
++cur;
#line 111 "../lib/lex.re"
{ error("character classes not supported"); return 1; }
#line 334 "lib/lex.cc"
#line 332 "lib/lex.cc"
yy32:
++cur;
#line 112 "../lib/lex.re"
{ error("equivalence classes not supported"); return 1; }
#line 339 "lib/lex.cc"
#line 337 "lib/lex.cc"
yy33:
++cur;
#line 124 "../lib/lex.re"
{ c = '\\'_u8; return 0; }
#line 344 "lib/lex.cc"
#line 342 "lib/lex.cc"
yy34:
++cur;
#line 125 "../lib/lex.re"
{ c = ']'_u8; return 0; }
#line 349 "lib/lex.cc"
#line 347 "lib/lex.cc"
yy35:
++cur;
#line 117 "../lib/lex.re"
{ c = '\a'_u8; return 0; }
#line 354 "lib/lex.cc"
#line 352 "lib/lex.cc"
yy36:
++cur;
#line 118 "../lib/lex.re"
{ c = '\b'_u8; return 0; }
#line 359 "lib/lex.cc"
#line 357 "lib/lex.cc"
yy37:
++cur;
#line 119 "../lib/lex.re"
{ c = '\f'_u8; return 0; }
#line 364 "lib/lex.cc"
#line 362 "lib/lex.cc"
yy38:
++cur;
#line 120 "../lib/lex.re"
{ c = '\n'_u8; return 0; }
#line 369 "lib/lex.cc"
#line 367 "lib/lex.cc"
yy39:
++cur;
#line 121 "../lib/lex.re"
{ c = '\r'_u8; return 0; }
#line 374 "lib/lex.cc"
#line 372 "lib/lex.cc"
yy40:
++cur;
#line 122 "../lib/lex.re"
{ c = '\t'_u8; return 0; }
#line 379 "lib/lex.cc"
#line 377 "lib/lex.cc"
yy41:
++cur;
#line 123 "../lib/lex.re"
{ c = '\v'_u8; return 0; }
#line 384 "lib/lex.cc"
#line 382 "lib/lex.cc"
yy42:
yych = *++cur;
if (yych <= '@') {
@@ -408,7 +406,7 @@ yy45:
++cur;
#line 114 "../lib/lex.re"
{ c = unesc_hex(p, cur); return 0; }
#line 412 "lib/lex.cc"
#line 410 "lib/lex.cc"
}
#line 128 "../lib/lex.re"
+61 -55
View File
@@ -63,8 +63,14 @@
/* Pull parsers. */
#define YYPULL 1
/* Substitute the type names. */
#define YYSTYPE RE2C_LIB_STYPE
/* Substitute the variable and function names. */
#define yyparse re2c_lib_parse
#define yylex re2c_lib_lex
#define yyerror re2c_lib_error
#define yydebug re2c_lib_debug
#define yynerrs re2c_lib_nerrs
/* First part of user prologue. */
#line 9 "../lib/parse.ypp"
@@ -83,7 +89,7 @@
using namespace re2c;
#line 87 "lib/parse.cc"
#line 93 "lib/parse.cc"
# ifndef YY_CAST
# ifdef __cplusplus
@@ -134,7 +140,7 @@ typedef enum yysymbol_kind_t yysymbol_kind_t;
/* Second part of user prologue. */
#line 38 "../lib/parse.ypp"
#line 39 "../lib/parse.ypp"
extern "C" {
static int yylex(YYSTYPE* yylval, const uint8_t*& pattern, Ast& ast);
@@ -142,7 +148,7 @@ extern "C" {
}
#line 146 "lib/parse.cc"
#line 152 "lib/parse.cc"
#ifdef short
@@ -405,7 +411,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|| (defined RE2C_LIB_STYPE_IS_TRIVIAL && RE2C_LIB_STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -521,19 +527,19 @@ static const yytype_int8 yytranslate[] =
5
};
#if YYDEBUG
#if RE2C_LIB_DEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int8 yyrline[] =
{
0, 55, 55, 58, 59, 63, 64, 68, 69, 70,
71, 72, 76, 77, 78
0, 56, 56, 59, 60, 64, 65, 69, 70, 71,
72, 73, 77, 78, 79
};
#endif
/** Accessing symbol of state STATE. */
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
#if YYDEBUG || 0
#if RE2C_LIB_DEBUG || 0
/* The user-facing name of the symbol whose (internal) number is
YYSYMBOL. No bounds checking. */
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
@@ -634,7 +640,7 @@ static const yytype_int8 yyr2[] =
enum { YYENOMEM = -2 };
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define yyclearin (yychar = RE2C_LIB_EMPTY)
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
@@ -646,7 +652,7 @@ enum { YYENOMEM = -2 };
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
if (yychar == RE2C_LIB_EMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
@@ -662,12 +668,12 @@ enum { YYENOMEM = -2 };
while (0)
/* Backward compatibility with an undocumented macro.
Use YYerror or YYUNDEF. */
#define YYERRCODE YYUNDEF
Use RE2C_LIB_error or RE2C_LIB_UNDEF. */
#define YYERRCODE RE2C_LIB_UNDEF
/* Enable debugging if requested. */
#if YYDEBUG
#if RE2C_LIB_DEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
@@ -787,12 +793,12 @@ do { \
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
#else /* !RE2C_LIB_DEBUG */
# define YYDPRINTF(Args) ((void) 0)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
#endif /* !RE2C_LIB_DEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
@@ -900,7 +906,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
YYDPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY; /* Cause a token to be read. */
yychar = RE2C_LIB_EMPTY; /* Cause a token to be read. */
goto yysetstate;
@@ -1010,25 +1016,25 @@ yybackup:
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
if (yychar == YYEMPTY)
if (yychar == RE2C_LIB_EMPTY)
{
YYDPRINTF ((stderr, "Reading a token\n"));
yychar = yylex (&yylval, pattern, ast);
}
if (yychar <= YYEOF)
if (yychar <= RE2C_LIB_EOF)
{
yychar = YYEOF;
yychar = RE2C_LIB_EOF;
yytoken = YYSYMBOL_YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else if (yychar == YYerror)
else if (yychar == RE2C_LIB_error)
{
/* The scanner already issued an error message, process directly
to error recovery. But do not keep the error token as
lookahead, it is too special and may lead us to an endless
loop in error recovery. */
yychar = YYUNDEF;
yychar = RE2C_LIB_UNDEF;
yytoken = YYSYMBOL_YYerror;
goto yyerrlab1;
}
@@ -1065,7 +1071,7 @@ yybackup:
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Discard the shifted token. */
yychar = YYEMPTY;
yychar = RE2C_LIB_EMPTY;
goto yynewstate;
@@ -1101,61 +1107,61 @@ yyreduce:
switch (yyn)
{
case 2: /* regexp: expr */
#line 55 "../lib/parse.ypp"
#line 56 "../lib/parse.ypp"
{ regexp = (yyval.regexp); }
#line 1107 "lib/parse.cc"
break;
case 4: /* expr: expr '|' term */
#line 59 "../lib/parse.ypp"
{ (yyval.regexp) = ast.alt((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
#line 1113 "lib/parse.cc"
break;
case 6: /* term: factor term */
#line 64 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cat((yyvsp[-1].regexp), (yyvsp[0].regexp)); }
case 4: /* expr: expr '|' term */
#line 60 "../lib/parse.ypp"
{ (yyval.regexp) = ast.alt((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
#line 1119 "lib/parse.cc"
break;
case 8: /* factor: primary '*' */
#line 69 "../lib/parse.ypp"
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), 0, Ast::MANY); }
case 6: /* term: factor term */
#line 65 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cat((yyvsp[-1].regexp), (yyvsp[0].regexp)); }
#line 1125 "lib/parse.cc"
break;
case 9: /* factor: primary '+' */
case 8: /* factor: primary '*' */
#line 70 "../lib/parse.ypp"
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), 1, Ast::MANY); }
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), 0, Ast::MANY); }
#line 1131 "lib/parse.cc"
break;
case 10: /* factor: primary '?' */
case 9: /* factor: primary '+' */
#line 71 "../lib/parse.ypp"
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), 0, 1); }
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), 1, Ast::MANY); }
#line 1137 "lib/parse.cc"
break;
case 11: /* factor: primary TOKEN_COUNT */
case 10: /* factor: primary '?' */
#line 72 "../lib/parse.ypp"
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max); }
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), 0, 1); }
#line 1143 "lib/parse.cc"
break;
case 13: /* primary: '(' ')' */
#line 77 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE)); }
case 11: /* factor: primary TOKEN_COUNT */
#line 73 "../lib/parse.ypp"
{ (yyval.regexp) = ast.iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max); }
#line 1149 "lib/parse.cc"
break;
case 14: /* primary: '(' expr ')' */
case 13: /* primary: '(' ')' */
#line 78 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp)); }
{ (yyval.regexp) = ast.cap(ast.nil(NOWHERE), CAPTURE); }
#line 1155 "lib/parse.cc"
break;
case 14: /* primary: '(' expr ')' */
#line 79 "../lib/parse.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), CAPTURE); }
#line 1161 "lib/parse.cc"
break;
#line 1159 "lib/parse.cc"
#line 1165 "lib/parse.cc"
default: break;
}
@@ -1197,7 +1203,7 @@ yyreduce:
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
yytoken = yychar == RE2C_LIB_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
@@ -1210,17 +1216,17 @@ yyerrlab:
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
if (yychar <= RE2C_LIB_EOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
if (yychar == RE2C_LIB_EOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, pattern, ast);
yychar = YYEMPTY;
yychar = RE2C_LIB_EMPTY;
}
}
@@ -1322,7 +1328,7 @@ yyexhaustedlab:
| yyreturnlab -- parsing is finished, clean up and return. |
`----------------------------------------------------------*/
yyreturnlab:
if (yychar != YYEMPTY)
if (yychar != RE2C_LIB_EMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
@@ -1348,7 +1354,7 @@ yyreturnlab:
return yyresult;
}
#line 81 "../lib/parse.ypp"
#line 82 "../lib/parse.ypp"
#pragma GCC diagnostic pop
+33 -25
View File
@@ -35,14 +35,22 @@
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_LIB_PARSE_H_INCLUDED
# define YY_YY_LIB_PARSE_H_INCLUDED
#ifndef YY_RE2C_LIB_LIB_PARSE_H_INCLUDED
# define YY_RE2C_LIB_LIB_PARSE_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#ifndef RE2C_LIB_DEBUG
# if defined YYDEBUG
#if YYDEBUG
extern int yydebug;
# define RE2C_LIB_DEBUG 1
# else
# define RE2C_LIB_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define RE2C_LIB_DEBUG 0
# endif /* ! defined YYDEBUG */
#endif /* ! defined RE2C_LIB_DEBUG */
#if RE2C_LIB_DEBUG
extern int re2c_lib_debug;
#endif
/* "%code requires" blocks. */
#line 1 "../lib/parse.ypp"
@@ -51,47 +59,47 @@ extern int yydebug;
#include "src/parse/ast.h"
namespace re2c {
struct AstNode;
};
}
#line 57 "lib/parse.h"
#line 65 "lib/parse.h"
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
#ifndef RE2C_LIB_TOKENTYPE
# define RE2C_LIB_TOKENTYPE
enum re2c_lib_tokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
RE2C_LIB_EMPTY = -2,
RE2C_LIB_EOF = 0, /* "end of file" */
RE2C_LIB_error = 256, /* error */
RE2C_LIB_UNDEF = 257, /* "invalid token" */
TOKEN_COUNT = 258, /* TOKEN_COUNT */
TOKEN_ERROR = 259, /* TOKEN_ERROR */
TOKEN_REGEXP = 260 /* TOKEN_REGEXP */
};
typedef enum yytokentype yytoken_kind_t;
typedef enum re2c_lib_tokentype re2c_lib_token_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
#if ! defined RE2C_LIB_STYPE && ! defined RE2C_LIB_STYPE_IS_DECLARED
union RE2C_LIB_STYPE
{
#line 33 "../lib/parse.ypp"
#line 34 "../lib/parse.ypp"
const re2c::AstNode* regexp;
re2c::AstBounds bounds;
#line 84 "lib/parse.h"
#line 92 "lib/parse.h"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
typedef union RE2C_LIB_STYPE RE2C_LIB_STYPE;
# define RE2C_LIB_STYPE_IS_TRIVIAL 1
# define RE2C_LIB_STYPE_IS_DECLARED 1
#endif
int yyparse (const uint8_t*& pattern, re2c::Ast& ast);
int re2c_lib_parse (const uint8_t*& pattern, re2c::Ast& ast);
#endif /* !YY_YY_LIB_PARSE_H_INCLUDED */
#endif /* !YY_RE2C_LIB_LIB_PARSE_H_INCLUDED */
+39 -39
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 3.0 */
/* Generated by re2c 4.0 */
#line 1 "../lib/test_helper.re"
#include "lib/test_helper.h"
@@ -30,39 +30,39 @@ loop:
#line 31 "lib/test_helper.cc"
{
char yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
static const unsigned char yybm[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
yych = *YYCURSOR;
if (yych <= '(') {
@@ -100,9 +100,7 @@ yy5:
#line 101 "lib/test_helper.cc"
yy6:
yych = *++YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy6;
}
if (yybm[0+yych] & 128) goto yy6;
if (yych == ',') goto yy9;
yy7:
YYCURSOR = YYMARKER;
@@ -137,8 +135,10 @@ yy13:
++YYCURSOR;
n1 = yyt1;
m1 = yyt2;
n2 = yyt2 - 1;
m2 = YYCURSOR - 1;
n2 = yyt2;
n2 -= 1;
m2 = YYCURSOR;
m2 -= 1;
#line 38 "../lib/test_helper.re"
{
v->push_back(parse_offset(n1, n2));
+444
View File
@@ -0,0 +1,444 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_C =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"functions\", \"free-form\"];\n"
"supported_code_models = [\"goto-label\", \"loop-switch\", \"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\", \"skeleton\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"computed-gotos\", \"case-ranges\",\n"
" \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 1;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 1;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = goto-label;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 1;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = functions;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = char-or-hex;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = (.code_model.recursive_functions ? 1 : 0); // `abort()` requires include\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"yyc\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = (.code_model.recursive_functions ? 1 : 0); // `abort()` requires include\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \"\\t\";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\";\n"
"re2c:label:yyfill = \"yyFillLabel\";\n"
"re2c:label:yyloop = \"\";\n"
"re2c:label:yyNext = \"yyNext\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"YYBACKUP\";\n"
"re2c:YYBACKUPCTX = \"YYBACKUPCTX\";\n"
"re2c:YYCONDTYPE = \"YYCONDTYPE\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \"->yyctxmarker\" : \"YYCTXMARKER\");\n"
"re2c:YYCTYPE = \"YYCTYPE\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \"->yycursor\" : \"YYCURSOR\");\n"
"re2c:YYDEBUG = \"YYDEBUG\";\n"
"re2c:YYFILL = \"YYFILL\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"YYGETCONDITION\"; // historic default\n"
"re2c:YYGETSTATE = \"YYGETSTATE\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \"->yyinput\" : \"YYINPUT\");\n"
"re2c:YYLESSTHAN = \"YYLESSTHAN\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \"->yylimit\" : \"YYLIMIT\");\n"
"re2c:YYMARKER = (.api.record ? yyrecord \"->yymarker\" : \"YYMARKER\");\n"
"re2c:YYMAXFILL = \"YYMAXFILL\";\n"
"re2c:YYMAXNMATCH = \"YYMAXNMATCH\";\n"
"re2c:YYMTAGN = \"YYMTAGN\";\n"
"re2c:YYMTAGP = \"YYMTAGP\";\n"
"re2c:YYPEEK = \"YYPEEK\";\n"
"re2c:YYRESTORE = \"YYRESTORE\";\n"
"re2c:YYRESTORECTX = \"YYRESTORECTX\";\n"
"re2c:YYRESTORETAG = \"YYRESTORETAG\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val};\";\n"
"re2c:YYSETCOND = \"YYSETCONDITION\"; // historic default\n"
"re2c:YYSETSTATE = \"YYSETSTATE\";\n"
"re2c:YYSHIFT = \"YYSHIFT\";\n"
"re2c:YYSHIFTSTAG = \"YYSHIFTSTAG\";\n"
"re2c:YYSHIFTMTAG = \"YYSHIFTMTAG\";\n"
"re2c:YYSKIP = \"YYSKIP\";\n"
"re2c:YYSTAGN = \"YYSTAGN\";\n"
"re2c:YYSTAGP = \"YYSTAGP\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \"->\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"NULL\");\n"
"re2c:cond:divider = \"/* *********************************** */\";\n"
"re2c:cond:goto = \"goto \" sigil \";\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent type \" \" name (.init ? \" = \" init) \";\" nl;\n"
"code:var_global = code:var_local;\n"
"\n"
"code:const_local = topindent type \" \" name \" = \" init \";\" nl;\n"
"code:const_global = topindent \"#define \" name \" \" init nl;\n"
"\n"
"code:array_local =\n"
" topindent type \" \" name \"[\" size \"] = {\" nl indent\n"
" [row{0:-2}: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" [row{-1}: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem] nl]\n"
" dedent topindent \"};\" nl;\n"
"\n"
"code:array_global = code:array_local;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum =\n"
" \"enum \" type \" {\" nl indent\n"
" [elem{0:-2}: topindent elem (.init ? \" = \" init) \",\" nl]\n"
" [elem{-1}: topindent elem (.init ? \" = \" init) nl]\n"
" dedent \"};\" nl;\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs \";\" nl;\n"
"\n"
"code:type_int = \"int\";\n"
"code:type_uint = \"unsigned int\";\n"
"code:type_yybm = \"static const unsigned char\";\n"
"code:type_yytarget = \"static const void*\";\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if (\" cond \") \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline =\n"
" [branch{0}: topindent \"if (\" cond \") \" [stmt: stmt] nl]\n"
" [branch{1:-1}: topindent \"else \" (.cond ? \"if (\" cond \") \") [stmt: stmt] nl];\n"
"\n"
"code:switch =\n"
" topindent \"switch (\" expr \") {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case: case nl]\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:switch_cases_oneline =\n"
" [case{0:-2}: case nl]\n"
" [case{-1}: case \" \" [stmt: stmt] nl];\n"
"\n"
"code:switch_case_range = (.case_ranges\n"
" ? topindent \"case \" [val{0}: val] (.many ? \" ... \" [val{-1}: val]) \":\"\n"
" : [val{0:-2}: topindent \"case \" val \":\" nl]\n"
" [val{-1}: topindent \"case \" val \":\"]);\n"
"\n"
"code:switch_case_default =\n"
" topindent \"default:\";\n"
"\n"
"code:loop =\n"
" topindent \"for (;;) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue;\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
"code:fndecl =\n"
" topindent type \" \" name \"(\"\n"
" [arg{0:-2}: argtype \" \" argname \", \"]\n"
" [arg{-1}: argtype \" \" argname]\n"
" \");\" nl;\n"
"\n"
"code:fndef =\n"
" topindent type \" \" name \"(\"\n"
" [arg{0:-2}: argtype \" \" argname \", \"]\n"
" [arg{-1}: argtype \" \" argname]\n"
" \") {\" nl\n"
" indent [stmt: stmt] dedent\n"
" \"}\" nl;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? retval \" = \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \");\" nl;\n"
"\n"
"code:tailcall =\n"
" topindent (.retval ? \"return \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \");\" nl;\n"
"\n"
"code:recursive_functions =\n"
" [fn: fndecl] nl\n"
" [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"/* Generated by re2c\" (.version ? \" \" version) (.date ? \" on \" date) \" */\" nl;\n"
"\n"
"code:line_info = \"#line \" line \" \\\"\" file \"\\\"\" nl;\n"
"\n"
"code:abort = topindent \"abort();\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG (.api_style.functions ? \"();\")\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \");\"\n"
" : YYDEBUG \"(\" state \", \" yych \");\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \" (.api.generic\n"
" ? YYPEEK (.api_style.functions ? \"()\")\n"
" : (.cast ? \"(\" YYCTYPE \")\") \"*\" YYCURSOR\n"
" ) \";\" nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP (.api_style.functions ? \"();\")\n"
" : \"++\" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP (.api_style.functions ? \"();\")\n"
" : YYMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX (.api_style.functions ? \"();\")\n"
" : YYCTXMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"(\" YYCTYPE \")\") \"*++\" YYCURSOR \";\" nl;\n"
"\n"
"code:yypeek_yyskip =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"(\" YYCTYPE \")\") \"*\" YYCURSOR \"++;\" nl;\n"
"\n"
"code:yyskip_yybackup =\n"
" topindent YYMARKER \" = ++\" YYCURSOR \";\" nl;\n"
"\n"
"code:yybackup_yyskip =\n"
" topindent YYMARKER \" = \" YYCURSOR \"++;\" nl;\n"
"\n"
"code:yybackup_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"(\" YYCTYPE \")\") \"*(\" YYMARKER \" = \" YYCURSOR \");\" nl;\n"
"\n"
"code:yyskip_yybackup_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"(\" YYCTYPE \")\") \"*(\" YYMARKER \" = ++\" YYCURSOR \");\" nl;\n"
"\n"
"code:yybackup_yypeek_yyskip =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"(\" YYCTYPE \")\") \"*(\" YYMARKER \" = \" YYCURSOR \"++);\" nl;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE (.api_style.functions ? \"();\")\n"
" : YYCURSOR \" = \" YYMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX (.api_style.functions ? \"();\")\n"
" : YYCURSOR \" = \" YYCTXMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG (.api_style.functions ? \"(\" tag \");\")\n"
" : YYCURSOR \" = \" tag \";\"\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT (.api_style.functions ? \"(-\" offset \");\")\n"
" : YYCURSOR \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if (\" tag \" != \" neg \") \") (.api.generic\n"
" ? YYSHIFTSTAG (.api_style.functions ? \"(\" tag \", -\" offset \");\")\n"
" : tag \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG (.api_style.functions ? \"(\" tag \", -\" offset \");\") nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP (.api_style.functions ? \"(\" tag \");\")\n"
" : tag \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP (.api_style.functions ? \"(\" tag \");\") nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN (.api_style.functions ? \"(\" tag \");\")\n"
" : tag \" = \" neg \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN (.api_style.functions ? \"(\" tag \");\") nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG // function style is not supported, as there's no sensible default\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG // function style is not supported, as there's no sensible default\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT // function style is not supported, as there's no sensible default\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \"->\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT // function style is not supported, as there's no sensible default\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \"->\")\n"
" var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"// Historically simple API did not provide default definition for YYGETCOND.\n"
"// Changing it would break backwards compatibility, as there may be a macro definition\n"
"// not based on `yycond` that re2c is unable to see, e.g. included from a header file.\n"
"code:yygetcond =\n"
" (.api.generic | .api.simple\n"
" ? YYGETCOND (.api_style.functions ? \"()\")\n"
" : yyrecord \"->\" var);\n"
"\n"
"// Historically simple API did not provide default definition for YYSETCOND.\n"
"// Changing it would break backwards compatibility, as there may be a macro definition\n"
"// not based on `yycond` that re2c is unable to see, e.g. included from a header file.\n"
"code:yysetcond =\n"
" topindent (.api.generic | .api.simple\n"
" ? YYSETCOND (.api_style.functions ? \"(\" val \");\")\n"
" : yyrecord \"->\" var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"// Historically simple API did not provide default definition for YYGETSTATE.\n"
"// Changing it would break backwards compatibility, as there may be a macro definition\n"
"// not based on `yystate` that re2c is unable to see, e.g. included from a header file.\n"
"code:yygetstate =\n"
" (.api.generic | .api.simple\n"
" ? YYGETSTATE (.api_style.functions ? \"()\")\n"
" : yyrecord \"->\" var);\n"
"\n"
"// Historically simple API did not provide default definition for YYSETSTATE.\n"
"// Changing it would break backwards compatibility, as there may be a macro definition\n"
"// not based on `yystate` that re2c is unable to see, e.g. included from a header file.\n"
"code:yysetstate =\n"
" topindent (.api.generic | .api.simple\n"
" ? YYSETSTATE (.api_style.functions ? \"(\" val \");\")\n"
" : yyrecord \"->\" var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN (.api_style.functions ? \"(\" need \")\")\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = yybm \"[\" offset \"+\" yych \"] & \" mask;\n"
;
+424
View File
@@ -0,0 +1,424 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_D =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"goto-label\", \"loop-switch\", \"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"case-ranges\",\n"
" \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 1;\n"
"backtick_quoted_strings = 1;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 1;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = goto-label;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 1;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = char-or-hex;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 1;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"yyc\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\";\n"
"re2c:label:yyfill = \"yyFillLabel\";\n"
"re2c:label:yyloop = \"yyl\";\n"
"re2c:label:yyNext = \"yyNext\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"YYCond\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCTYPE = \"YYChar\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"YYMaxFill\";\n"
"re2c:YYMAXNMATCH = \"YYMaxNMatch\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = \"yypeek\";\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val};\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"null\");\n"
"re2c:cond:divider = \"/* *********************************** */\";\n"
"re2c:cond:goto = \"goto \" sigil \";\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent type \" \" name (.init ? \" = \" init) \";\" nl;\n"
"code:var_global = code:var_local;\n"
"\n"
"code:const_local = topindent \"enum \" name \" = \" init \";\" nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent type \"[\" size \"] \" name \" = [\" nl indent\n"
" [row{0:-2}: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" [row{-1}: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem] nl]\n"
" dedent topindent \"];\" nl;\n"
"\n"
"code:array_global = code:array_local;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum =\n"
" \"enum \" type \" {\" nl indent\n"
" [elem{0:-2}: topindent elem (.init ? \" = \" init) \",\" nl]\n"
" [elem{-1}: topindent elem (.init ? \" = \" init) nl]\n"
" dedent \"};\" nl;\n"
"\n"
"code:enum_elem = type \".\" name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs \";\" nl;\n"
"\n"
"code:type_int = \"int\";\n"
"code:type_uint = \"uint\";\n"
"code:type_yybm = \"immutable char\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if (\" cond \") \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline =\n"
" [branch{0}: topindent \"if (\" cond \") \" [stmt: stmt] nl]\n"
" [branch{1:-1}: topindent \"else \" (.cond ? \"if (\" cond \") \") [stmt: stmt] nl];\n"
"\n"
"code:switch =\n"
" topindent \"switch (\" expr \") {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case: case nl]\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:switch_cases_oneline =\n"
" [case{0:-2}: case nl]\n"
" [case{-1}: case \" \" [stmt: stmt] nl];\n"
"\n"
"code:switch_case_range =\n"
" topindent \"case \" [val{0}: val] (.many ? \": .. case \" [val{-1}: val]) \":\";\n"
"\n"
"code:switch_case_default =\n"
" topindent \"default:\";\n"
"\n"
"code:loop =\n"
" topindent (.loop_label ? label \": \") \"while (true) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" \" label) \";\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" topindent type \" \" name \"(\"\n"
" [arg{0:-2}: argtype \" \" argname \", \"]\n"
" [arg{-1}: argtype \" \" argname]\n"
" \") {\" nl\n"
" indent [stmt: stmt] dedent\n"
" \"}\" nl;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? retval \" = \" name) \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \");\" nl;\n"
"\n"
"code:tailcall =\n"
" topindent (.retval ? \"return \" name) \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \");\" nl;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"/* Generated by re2d\" (.version ? \" \" version) (.date ? \" on \" date) \" */\" nl;\n"
"\n"
"code:line_info = \"#line \" line \" \\\"\" file \"\\\"\" nl;\n"
"\n"
"code:abort = topindent \"assert(false);\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \");\"\n"
" : YYDEBUG \"(\" state \", \" yych \");\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \" (.api.generic\n"
" ? YYPEEK\n"
" : (.cast ? \"cast(\" YYCTYPE \")\") \"*\" YYCURSOR\n"
" ) \";\" nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : \"++\" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"cast(\" YYCTYPE \")\") \"*++\" YYCURSOR \";\" nl;\n"
"\n"
"code:yypeek_yyskip =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"cast(\" YYCTYPE \")\") \"*\" YYCURSOR \"++;\" nl;\n"
"\n"
"code:yyskip_yybackup =\n"
" topindent YYMARKER \" = ++\" YYCURSOR \";\" nl;\n"
"\n"
"code:yybackup_yyskip =\n"
" topindent YYMARKER \" = \" YYCURSOR \"++;\" nl;\n"
"\n"
"code:yybackup_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"cast(\" YYCTYPE \")\") \"*(\" YYMARKER \" = \" YYCURSOR \");\" nl;\n"
"\n"
"code:yyskip_yybackup_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"cast(\" YYCTYPE \")\") \"*(\" YYMARKER \" = ++\" YYCURSOR \");\" nl;\n"
"\n"
"code:yybackup_yypeek_yyskip =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"cast(\" YYCTYPE \")\") \"*(\" YYMARKER \" = \" YYCURSOR \"++);\" nl;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag \";\"\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if (\" tag \" != \" neg \") \") (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\")\n"
" var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\" var) \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
;
+406
View File
@@ -0,0 +1,406 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_GO =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\", \"functions\"];\n"
"supported_code_models = [\"goto-label\", \"loop-switch\", \"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 0;\n"
"backtick_quoted_strings = 1;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 1;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = goto-label;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 1;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = generic;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = char-or-hex;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 1;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"yyc\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = (.code_model.goto_label ? 0 : 1); // historically disabled for goto/label\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \"\\t\";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\";\n"
"re2c:label:yyfill = \"yyFillLabel\";\n"
"re2c:label:yyloop = \"yyl\";\n"
"re2c:label:yyNext = \"yyNext\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"YYBACKUP\";\n"
"re2c:YYBACKUPCTX = \"YYBACKUPCTX\";\n"
"re2c:YYCONDTYPE = \"YYCONDTYPE\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCTYPE = \"YYCTYPE\";\n"
"re2c:YYCTXMARKER = (.api.generic ? \"YYCTXMARKER\" : (.api.record ? yyrecord \".\") \"yyctxmarker\");\n"
"re2c:YYCURSOR = (.api.generic ? \"YYCURSOR\" : (.api.record ? yyrecord \".\") \"yycursor\");\n"
"re2c:YYDEBUG = \"YYDEBUG\";\n"
"re2c:YYFILL = \"YYFILL\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"YYGETCONDITION\"; // historic default\n"
"re2c:YYGETSTATE = \"YYGETSTATE\";\n"
"re2c:YYINPUT = (.api.generic ? \"YYINPUT\" : (.api.record ? yyrecord \".\") \"yyinput\");\n"
"re2c:YYLESSTHAN = \"YYLESSTHAN\";\n"
"re2c:YYLIMIT = (.api.generic ? \"YYLIMIT\" : (.api.record ? yyrecord \".\") \"yylimit\");\n"
"re2c:YYMARKER = (.api.generic ? \"YYMARKER\" : (.api.record ? yyrecord \".\") \"yymarker\");\n"
"re2c:YYMAXFILL = \"YYMAXFILL\";\n"
"re2c:YYMAXNMATCH = \"YYMAXNMATCH\";\n"
"re2c:YYMTAGN = \"YYMTAGN\";\n"
"re2c:YYMTAGP = \"YYMTAGP\";\n"
"re2c:YYPEEK = \"YYPEEK\";\n"
"re2c:YYRESTORE = \"YYRESTORE\";\n"
"re2c:YYRESTORECTX = \"YYRESTORECTX\";\n"
"re2c:YYRESTORETAG = \"YYRESTORETAG\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val}\";\n"
"re2c:YYSETCOND = \"YYSETCONDITION\"; // historic default\n"
"re2c:YYSETSTATE = \"YYSETSTATE\";\n"
"re2c:YYSHIFT = \"YYSHIFT\";\n"
"re2c:YYSHIFTSTAG = \"YYSHIFTSTAG\";\n"
"re2c:YYSHIFTMTAG = \"YYSHIFTMTAG\";\n"
"re2c:YYSKIP = \"YYSKIP\";\n"
"re2c:YYSTAGN = \"YYSTAGN\";\n"
"re2c:YYSTAGP = \"YYSTAGP\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"-1\");\n"
"re2c:cond:divider = \"/* *********************************** */\";\n"
"re2c:cond:goto = \"goto \" sigil;\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent (.init ? name \" := \" init : \"var \" name \" \" type) nl;\n"
"code:var_global = topindent \"var \" name \" \" type (.init ? \" = \" init) nl;\n"
"\n"
"code:const_local = topindent \"const \" name \" = \" init nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent name \" := [\" size \"]\" type \"{\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"}\" nl;\n"
"\n"
"code:array_global =\n"
" topindent \"var \" name \" = {\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"}\" nl;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum =\n"
" \"const (\" nl indent\n"
" [elem{0}: topindent elem \" = \" (.init ? init : \"iota\") nl]\n"
" [elem{1:-1}: topindent elem (.init ? \" = \" init) nl]\n"
" dedent \")\" nl;\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs nl;\n"
"\n"
"code:type_int = \"int\";\n"
"code:type_uint = \"uint\";\n"
"code:type_yybm = \"byte\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if (\" cond \") \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline = <undefined>;\n"
"\n"
"code:switch =\n"
" topindent \"switch (\" expr \") {\" nl\n"
" [case: case]\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case{0:-2}: topindent case nl\n"
" indent topindent \"fallthrough\" dedent nl]\n"
" [case{-1}: topindent case nl]\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:switch_cases_oneline = <undefined>;\n"
"\n"
"code:switch_case_range = \"case \" [val{0}: val] [val{1:-1}: \",\" val] \":\";\n"
"\n"
"code:switch_case_default = \"default:\";\n"
"\n"
"code:loop =\n"
" (.loop_label ? label \":\" nl)\n"
" topindent \"for {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" \" label) nl;\n"
"\n"
"code:goto = topindent \"goto \" label nl;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" topindent \"func \" name \"(\"\n"
" [arg{0:-2}: argname \" \" argtype \", \"]\n"
" [arg{-1}: argname \" \" argtype]\n"
" \")\" (.type ? \" \" type) \" {\" nl\n"
" indent [stmt: stmt] dedent\n"
" \"}\" nl;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? retval \" = \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:tailcall =\n"
" topindent (.retval ? \"return \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"// Code generated by re2go\" (.version ? \" \" version) (.date ? \" on \" date) \", DO NOT EDIT.\" nl;\n"
"\n"
"code:line_info = \"//line \\\"\" file \"\\\":\" line nl;\n"
"\n"
"code:abort = topindent \"panic(\\\"internal lexer error\\\")\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG (.api_style.functions ? \"()\")\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \")\"\n"
" : YYDEBUG \"(\" state \", \" yych \")\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent yych (.code_model.recursive_functions ? \" := \" : \" = \") (.api.generic\n"
" ? YYPEEK (.api_style.functions ? \"()\")\n"
" : (.cast ? YYCTYPE \"(\") YYINPUT \"[\" YYCURSOR \"]\" (.cast ? \")\")\n"
" ) nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP (.api_style.functions ? \"()\")\n"
" : YYCURSOR \" += 1\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP (.api_style.functions ? \"()\")\n"
" : YYMARKER \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX (.api_style.functions ? \"()\")\n"
" : YYCTXMARKER \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE (.api_style.functions ? \"()\")\n"
" : YYCURSOR \" = \" YYMARKER\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX (.api_style.functions ? \"()\")\n"
" : YYCURSOR \" = \" YYCTXMARKER\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG (.api_style.functions ? \"(\" tag \")\")\n"
" : YYCURSOR \" = \" tag\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT (.api_style.functions ? \"(-\" offset \")\")\n"
" : YYCURSOR \" -= \" offset\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" (.nested ? topindent \"if (\" tag \" != \" neg \") {\" nl indent)\n"
" topindent (.api.generic\n"
" ? YYSHIFTSTAG (.api_style.functions ? \"(\" tag \", -\" offset \")\")\n"
" : tag \" -= \" offset\n"
" ) nl\n"
" (.nested ? dedent topindent \"}\" nl);\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG (.api_style.functions ? \"(\" tag \", -\" offset \")\") nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP (.api_style.functions ? \"(\" tag \")\")\n"
" : tag \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP (.api_style.functions ? \"(\" tag \")\") nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN (.api_style.functions ? \"(\" tag \")\")\n"
" : tag \" = \" neg\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN (.api_style.functions ? \"(\" tag \")\") nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG // function style is not supported, as there's no sensible default\n"
" : lhs \" = \" rhs\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG // function style is not supported, as there's no sensible default\n"
" : lhs \" = \" rhs\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT // function style is not supported, as there's no sensible default\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT // function style is not supported, as there's no sensible default\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\")\n"
" var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND (.api_style.functions ? \"()\")\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND (.api_style.functions ? \"(\" val \")\")\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE (.api_style.functions ? \"()\")\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE (.api_style.functions ? \"(\" val \")\")\n"
" : (.api.record ? yyrecord \".\") var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN (.api_style.functions ? \"(\" need \")\")\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
;
+418
View File
@@ -0,0 +1,418 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_HASKELL =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"record\", \"generic\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"monadic\", \"tags\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 0;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 1;\n"
"wrap_blocks_in_braces = 0;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = recursive-functions;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 1;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = record;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"_yycond\";\n"
"re2c:yyctable = \"\"; // unused\n"
"re2c:yyaccept = \"_yyaccept\";\n"
"re2c:yytarget = \"\"; // unused\n"
"re2c:yystate = \"_yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"yyfill\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"_yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 1;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"YYC_\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\"; // used for generating function names\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"YYCONDTYPE\";\n"
"re2c:YYCOPYMTAG = \"yycopymtag\";\n"
"re2c:YYCOPYSTAG = \"yycopystag\";\n"
"re2c:YYCTYPE = \"YYCTYPE\";\n"
"re2c:YYCTXMARKER = \"_yyctxmarker\";\n"
"re2c:YYCURSOR = \"_yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = \"yygetaccept\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = \"_yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = \"_yylimit\";\n"
"re2c:YYMARKER = \"_yymarker\";\n"
"re2c:YYMAXFILL = \"yymaxfill\";\n"
"re2c:YYMAXNMATCH = \"yymaxnmatch\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = (.api.record ? \"index\" : \"yypeek\");\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = \"yysetaccept\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"(-1)\");\n"
"re2c:cond:divider = \"\";\n"
"re2c:cond:goto = \"\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent \"let \" name \" = \" init \" in\" nl;\n"
"code:var_global = topindent \"let \" name \" = \" init nl;\n"
"\n"
"code:const_local = topindent \"let \" name \" = \" init \" in\" nl;\n"
"code:const_global = topindent name \" = \" init nl;\n"
"\n"
"code:array_local = <undefined>;\n"
"\n"
"code:array_global =\n"
" topindent name \" :: Array Int \" type nl\n"
" topindent name \" = array (0, \" size \" - 1) $ Prelude.zip [0 .. \" size \" - 1] [\" nl indent\n"
" [row{0:-2}: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" [row{-1}: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \"]\"] nl];\n"
"\n"
"code:array_elem = array \" ! \" index;\n"
"\n"
"code:enum =\n"
" \"data \" type \" = \"\n"
" [elem{0:-2}: elem \" | \"]\n"
" [elem{-1}: elem] \" deriving (Eq, Show)\"\n"
" nl;\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = <undefined>;\n"
"\n"
"code:type_int = <undefined>;\n"
"code:type_uint = <undefined>;\n"
"code:type_yybm = \"Word8\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"/=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent (.many ? \"if \" cond \" then\" : \"when (\" cond \") $\") (.monadic ? \" do\") nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"else\" (.cond ? \" if \" cond \" then\") (.monadic ? \" do\") nl\n"
" indent [stmt: stmt] dedent];\n"
"\n"
"code:if_then_else_oneline =\n"
" [branch{0}: topindent (.many ? \"if \" cond \" then \" : \"when (\" cond \") $ \") [stmt: stmt] nl]\n"
" [branch{1:-1}: topindent \"else \" (.cond ? \"if \" cond \" then \") [stmt: stmt] nl];\n"
"\n"
"code:switch =\n"
" topindent \"case \" expr \" of\" nl\n"
" indent [case: case] dedent;\n"
"\n"
"code:switch_cases = topindent \"_c | \"\n"
" [case{0:-2}: case \" || \"]\n"
" [case{-1}: case \" ->\" (.monadic ? \" do\") nl\n"
" indent [stmt: stmt] dedent\n"
" ];\n"
"\n"
"code:switch_cases_oneline = <undefined>;\n"
"\n"
"code:switch_case_range = (.many\n"
" ? [val{0}: val] \" <= _c && _c <= \" [val{-1}: val]\n"
" : [val{0}: val] \" == _c\");\n"
"\n"
"code:switch_case_default = \"True\";\n"
"\n"
"code:loop = <undefined>;\n"
"\n"
"code:continue = <undefined>;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" name \" :: \" [arg: argtype \" -> \"] type nl\n"
" name [arg: \" \" argname] \" =\" (.monadic ? \" do\") nl\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? \"let \" retval \" = \")\n"
" name (.args ? [arg: \" \" arg] : \" ()\") nl;\n"
"\n"
"code:tailcall = topindent name (.args ? [arg: \" \" arg] : \" ()\") nl;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"-- Generated by re2hs\" (.version ? \" \" version) (.date ? \" on \" date) nl\n"
" (.api.record ? \"{-# LANGUAGE RecordWildCards #-}\" nl);\n"
"\n"
"code:line_info = \"#\" line \" \\\"\" file \"\\\"\" nl;\n"
"\n"
"code:abort = topindent \"error \\\"internal lexer error\\\"\" nl;\n"
"\n"
"code:yydebug = topindent YYDEBUG nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? yych \" <- return $ \" YYPEEK \" \" YYINPUT \" \" YYCURSOR\n"
" : \"let \" yych \" = \" YYPEEK \" \" YYINPUT \" \" YYCURSOR \" in\")\n"
" : (.monadic\n"
" ? yych \" <- \" YYPEEK\n"
" : \"let \" yych \" = \" YYPEEK \" in\")\n"
" ) nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? YYCURSOR \" <- return $ \" YYCURSOR \" + 1\"\n"
" : \"let __ = \" YYCURSOR \" + 1 in let \" YYCURSOR \" = __ in\")\n"
" : YYSKIP\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" YYMARKER \" = \" YYCURSOR\n"
" : \"let \" YYMARKER \" = \" YYCURSOR \" in\")\n"
" : YYBACKUP\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" YYCTXMARKER \" = \" YYCURSOR\n"
" : \"let \" YYCTXMARKER \" = \" YYCURSOR \" in\")\n"
" : YYBACKUPCTX\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" YYCURSOR \" = \" YYMARKER\n"
" : \"let \" YYCURSOR \" = \" YYMARKER \" in\")\n"
" : YYRESTORE\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" YYCURSOR \" = \" YYCTXMARKER\n"
" : \"let \" YYCURSOR \" = \" YYCTXMARKER \" in\")\n"
" : YYRESTORECTX\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" YYCURSOR \" = \" tag\n"
" : \"let \" YYCURSOR \" = \" tag \" in\")\n"
" : YYRESTORETAG\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? YYCURSOR \" <- return $ \" YYCURSOR \" - \" offset\n"
" : \"let __ = \" YYCURSOR \" - \" offset \" in let \" YYCURSOR \" = __ in\")\n"
" : YYSHIFT\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? tag \" <- return $ if \" tag \" == \" neg \" then \" neg \" else \" tag \" - \" offset\n"
" : \"let __ = if \" tag \" == \" neg \" then \" neg \" else \" tag \" - \" offset\n"
" \" in let \" tag \" = __ in\")\n"
" : YYSHIFTSTAG\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" tag \" = \" YYCURSOR\n"
" : \"let \" tag \" = \" YYCURSOR \" in\")\n"
" : YYSTAGP\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" tag \" = \" neg\n"
" : \"let \" tag \" = \" neg \" in\")\n"
" : YYSTAGN\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" lhs \" = \" rhs\n"
" : \"let \" lhs \" = \" rhs \" in\")\n"
" : YYCOPYSTAG\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" lhs \" = \" rhs\n"
" : \"let \" lhs \" = \" rhs \" in\")\n"
" : YYCOPYMTAG\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.record ? var : YYGETACCEPT);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" var \" = \" val\n"
" : \"let \" var \" = \" val \" in\")\n"
" : YYSETACCEPT\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.record ? var : YYGETCOND);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" var \" = \" val\n"
" : \"let \" var \" = \" val \" in\")\n"
" : YYSETCOND\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.record ? var : YYGETSTATE);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.record\n"
" ? (.monadic\n"
" ? \"let \" var \" = \" val\n"
" : \"let \" var \" = \" val \" in\")\n"
" : YYSETSTATE\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.record\n"
" ? YYCURSOR \" >= \" YYLIMIT // YYFILL check can only be used with EOF rule $\n"
" : YYLESSTHAN);\n"
"\n"
"code:yybm_filter = \"(\" yych \" .&. complement 0xFF) /= 0\";\n"
"\n"
"code:yybm_match = \"(\" yybm \" ! (\" offset \" + fromIntegral \" yych \") .&. \" mask \") /= 0\";\n"
;
+382
View File
@@ -0,0 +1,382 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_JAVA =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"loop-switch\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 1;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 1;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = loop-switch;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 0;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex;\n"
"re2c:yych:emit = 1;\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 0;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"YYC_\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"\";\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"yyl\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"int\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCTYPE = \"YYChar\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"YYMAXFILL\";\n"
"re2c:YYMAXNMATCH = \"YYMAXNMATCH\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = \"yypeek\";\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val};\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"-1\");\n"
"re2c:cond:divider = \"\";\n"
"re2c:cond:goto = \"\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent type \" \" name \" = \" init \";\" nl;\n"
"code:var_global = code:var_local;\n"
"\n"
"code:const_local = topindent \"static final \" type \" \" name \" = \" init \";\" nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent type \"[] \" name \" = new \" type \"[]{\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"};\" nl;\n"
"\n"
"code:array_global = <undefined>;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum = [elem: topindent \"public static final \" type \" \" elem \" = \" init \";\" nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs \";\" nl;\n"
"\n"
"code:type_int = \"int\";\n"
"code:type_uint = \"int\";\n"
"code:type_yybm = \"int\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if (\" cond \") \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline = <undefined>;\n"
"\n"
"code:switch =\n"
" topindent \"switch (\" expr \") {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case: case nl]\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:switch_cases_oneline = <undefined>;\n"
"\n"
"code:switch_case_range =\n"
" [val{0:-2}: topindent \"case \" val \":\" nl]\n"
" [val{-1}: topindent \"case \" val \":\"];\n"
"\n"
"code:switch_case_default =\n"
" topindent \"default:\";\n"
"\n"
"code:loop =\n"
" topindent (.loop_label ? label \": \") \"while (true) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" \" label) \";\" nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"code:fndef = <undefined>;\n"
"code:fncall = <undefined>;\n"
"code:tailcall = <undefined>;\n"
"code:recursive_functions = <undefined>;\n"
"\n"
"code:line_info = <undefined>;\n"
"\n"
"code:fingerprint =\n"
" \"// Generated by re2java\" (.version ? \" \" version) (.date ? \" on \" date) nl;\n"
"\n"
"code:abort = topindent \"throw new IllegalStateException(\\\"internal lexer error\\\");\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \");\"\n"
" : YYDEBUG \"(\" state \", \" yych \");\"\n"
" )) nl;\n"
"\n"
"// No YYFILL specialization for default/record API,\n"
"// as there's no uniform syntax for strings and arrays.\n"
"code:yypeek = topindent yych \" = \" YYPEEK \";\" nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : YYCURSOR \" += 1;\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag \";\"\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if (\" tag \" != \" neg \") \") (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & .storable_state ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & .storable_state ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
;
+384
View File
@@ -0,0 +1,384 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_JS =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"loop-switch\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 0;\n"
"backtick_quoted_strings = 1;\n"
"single_quoted_strings = 1;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 1;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = loop-switch;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 0;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex;\n"
"re2c:yych:emit = 1;\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 0;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"YYC_\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"\";\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"yyl\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"YYCond\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCTYPE = \"YYChar\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"YYMAXFILL\";\n"
"re2c:YYMAXNMATCH = \"YYMAXNMATCH\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = (.api.generic ? \"yypeek\" : \"charCodeAt\");\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val}\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"-1\");\n"
"re2c:cond:divider = \"\";\n"
"re2c:cond:goto = \"\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent \"let \" name \" = \" init nl;\n"
"code:var_global = code:var_local;\n"
"\n"
"code:const_local = topindent \"const \" name \" = \" init nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent \"const \" name \" = [\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"]\" nl;\n"
"\n"
"code:array_global = <undefined>;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum = [elem: topindent \"const \" elem \" = \" init nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs nl;\n"
"\n"
"code:type_int = <undefined>;\n"
"code:type_uint = <undefined>;\n"
"code:type_yybm = <undefined>;\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"===\";\n"
"code:cmp_ne = \"!==\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if (\" cond \") \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline = <undefined>;\n"
"\n"
"code:switch =\n"
" topindent \"switch (\" expr \") {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case: case nl]\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:switch_cases_oneline = <undefined>;\n"
"\n"
"code:switch_case_range =\n"
" [val{0:-2}: topindent \"case \" val \":\" nl]\n"
" [val{-1}: topindent \"case \" val \":\"];\n"
"\n"
"code:switch_case_default =\n"
" topindent \"default:\";\n"
"\n"
"code:loop =\n"
" topindent (.loop_label ? label \": \") \"while (true) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" \" label) nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"code:fndef = <undefined>;\n"
"code:fncall = <undefined>;\n"
"code:tailcall = <undefined>;\n"
"code:recursive_functions = <undefined>;\n"
"\n"
"code:line_info = <undefined>;\n"
"\n"
"code:fingerprint =\n"
" \"// Generated by re2js\" (.version ? \" \" version) (.date ? \" on \" date) nl;\n"
"\n"
"code:abort = topindent \"throw \\\"internal lexer error\\\"\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \");\"\n"
" : YYDEBUG \"(\" state \", \" yych \");\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \" (.api.generic\n"
" ? YYPEEK\n"
" : YYINPUT \".\" YYPEEK \"(\" YYCURSOR \")\"\n"
" ) nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : YYCURSOR \" += 1;\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag \";\"\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if (\" tag \" != \" neg \") \") (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & .storable_state ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & .storable_state ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") !== 0\";\n"
;
+397
View File
@@ -0,0 +1,397 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_OCAML =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"record\", \"generic\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"case-ranges\",\n"
" \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 0;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 0;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = recursive-functions;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 1;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = record;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = char;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 0; // default case causes [redundant-case] warnings\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"YYC_\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 1;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\"; // used for generating function names\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"yycondtype\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} <- \" sigil \"{rhs};\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} <- \" sigil \"{rhs};\";\n"
"re2c:YYCTYPE = \"char\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylesthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"yymaxfill\";\n"
"re2c:YYMAXNMATCH = \"yymaxnmatch\";\n"
"re2c:YYMTAGN = \"yymatgn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = (.api.record ? \"get\" : \"yypeek\");\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} <- \" sigil \"{val};\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"-1\");\n"
"re2c:cond:divider = \"\";\n"
"re2c:cond:goto = \"\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent \"let \" name \" = \" init \" in\" nl;\n"
"code:var_global = topindent \"let \" name \" = \" init nl;\n"
"\n"
"code:const_local = topindent \"let \" name \" = \" init \" in\" nl;\n"
"code:const_global = topindent \"let \" name \" = \" init nl;\n"
"\n"
"code:array_local =\n"
" topindent \"and \" name \" = [|\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \"; \"] [elem{-1}: elem \";\"] nl]\n"
" dedent topindent \"|]\" nl;\n"
"\n"
"code:array_global = code:array_local;\n"
"\n"
"code:array_elem = array \".(\" index \")\";\n"
"\n"
"code:enum =\n"
" \"type \" type \" = \"\n"
" [elem{0}: elem]\n"
" [elem{1:-1}: \" | \" elem]\n"
" nl;\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" <- \" rhs \";\" nl;\n"
"\n"
"code:type_int = \"int\";\n"
"code:type_uint = \"uint\";\n"
"code:type_yybm = \"int\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\"; // physical equality, as this is used to compare primitive values\n"
"code:cmp_ne = \"!=\"; // physical inequality, as this is used to compare primitive values\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") then (\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \") else \" (.cond ? \"if (\" cond \") then \") \"(\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \")\" nl;\n"
"\n"
"code:if_then_else_oneline =\n"
" [branch{0}: topindent \"if (\" cond \") then \" [stmt: stmt] nl]\n"
" [branch{1:-1}: topindent \"else \" (.cond ? \"if (\" cond \") then \") [stmt: stmt] nl];\n"
"\n"
"code:switch =\n"
" topindent \"match \" expr \" with\" nl\n"
" indent [case: case] dedent;\n"
"\n"
"code:switch_cases =\n"
" [case{0:-2}: topindent \"| \" case nl]\n"
" [case{-1}: topindent \"| \" case \" ->\" nl\n"
" indent [stmt: stmt] dedent\n"
" ];\n"
"\n"
"code:switch_cases_oneline =\n"
" [case{0:-2}: topindent \"| \" case nl]\n"
" [case{-1}: topindent \"| \" case \" -> \" [stmt: stmt] nl];\n"
"\n"
"// In OCaml only literals of type `char` support case ranges.\n"
"// For `int`, we have to exlicitly list all range values. We cannot use\n"
"// `\"c when \" [val{0}: val] \" <= c && c <= \" [val{-1}: val]`\n"
"// as it causes error when there are multiple cases:\n"
"// `Error: Variable c must occur on both sides of this | pattern`.\n"
"code:switch_case_range = (.char_literals\n"
" ? [val{0}: val] (.many ? \"..\" [val{-1}: val])\n"
" : [val{0}: val] [val{1:-1}: \"|\" val]);\n"
"\n"
"code:switch_case_default = \"_\";\n"
"\n"
"code:loop = <undefined>;\n"
"\n"
"code:continue = <undefined>;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" name [arg: \" (\" argname \" : \" argtype \")\"] \" : \" type \" =\" nl\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? \"let \" retval \" = \")\n"
" \"(\" name \" [@tailcall])\" (.args ? [arg: \" \" arg] : \" ()\") nl;\n"
"\n"
"code:tailcall = topindent \"(\" name \" [@tailcall])\" (.args ? [arg: \" \" arg] : \" ()\") nl;\n"
"\n"
"code:recursive_functions =\n"
" [fn{0}: \"let rec \" fndef nl]\n"
" [fn{1:-1}: \"and \" fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"(* Generated by re2ocaml\" (.version ? \" \" version) (.date ? \" on \" date) \" *)\" nl;\n"
"\n"
"code:line_info = \"#\" line \" \\\"\" file \"\\\"\" nl;\n"
"\n"
"code:abort = topindent \"raise (Failure \\\"internal lexer error\\\")\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.record\n"
" ? YYDEBUG \" \" yyrecord\n"
" : YYDEBUG\n"
" ) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.api.record\n"
" ? \"let \" yych \" = \" YYPEEK \" \" YYINPUT \" \" YYCURSOR \" in\"\n"
" : \"let \" yych \" = \" YYPEEK \" in\"\n"
" ) nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.record\n"
" ? YYCURSOR \" <- \" YYCURSOR \" + 1;\"\n"
" : YYSKIP\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.record\n"
" ? YYMARKER \" <- \" YYCURSOR \";\"\n"
" : YYBACKUP\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.record\n"
" ? YYCTXMARKER \" <- \" YYCURSOR \";\"\n"
" : YYBACKUPCTX\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.record\n"
" ? YYCURSOR \" <- \" YYMARKER \";\"\n"
" : YYRESTORE\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.record\n"
" ? YYCURSOR \" <- \" YYCTXMARKER \";\"\n"
" : YYRESTORECTX\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.record\n"
" ? YYCURSOR \" <- \" tag \";\"\n"
" : YYRESTORETAG\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.record\n"
" ? YYCURSOR \" <- \" YYCURSOR \" - \" offset \";\"\n"
" : YYSHIFT\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if \" tag \" <> \" neg \" then \") (.api.record\n"
" ? tag \" <- \" tag \" - \" offset \";\"\n"
" : YYSHIFTSTAG\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.record\n"
" ? tag \" <- \" YYCURSOR \";\"\n"
" : YYSTAGP\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.record\n"
" ? tag \" <- \" neg \";\"\n"
" : YYSTAGN\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.record\n"
" ? lhs \" <- \" rhs \";\"\n"
" : YYCOPYSTAG\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.record\n"
" ? lhs \" <- \" rhs \";\"\n"
" : YYCOPYMTAG\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.record ? yyrecord \".\" var : YYGETACCEPT);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.record\n"
" ? yyrecord \".\" var \" <- \" val \";\"\n"
" : YYSETACCEPT\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.record ? yyrecord \".\" var : YYGETCOND);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.record\n"
" ? yyrecord \".\" var \" <- \" val \";\"\n"
" : YYSETCOND\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.record ? yyrecord \".\" var : YYGETSTATE);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.record\n"
" ? yyrecord \".\" var \" <- \" val \";\"\n"
" : YYSETSTATE\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.record\n"
" ? (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR)\n"
" : YYLESSTHAN);\n"
"\n"
"code:yybm_filter = yych \" land ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \".(\" offset \" + Char.code \" yych \") land \" mask \") != 0\";\n"
;
+390
View File
@@ -0,0 +1,390 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_PYTHON =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"// \"recursive_functions\" works syntactically, but causes stack overflows due to non-tail recusion\n"
"supported_code_models = [\"loop-switch\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 0;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 1;\n"
"indentation_sensitive = 1;\n"
"wrap_blocks_in_braces = 0;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = loop-switch;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 0;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex;\n"
"re2c:yych:emit = 0;\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 0; // default case causes [redundant-case] warnings\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"YYC_\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 1;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 0;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"\";\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"yycondtype\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCTYPE = \"yyctype\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"YYMAXFILL\";\n"
"re2c:YYMAXNMATCH = \"YYMAXNMATCH\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = \"yypeek\";\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val}\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"-1\");\n"
"re2c:cond:divider = \"\";\n"
"re2c:cond:goto = \"\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent name (.init ? \" = \" init) nl;\n"
"code:var_global = code:var_local;\n"
"\n"
"code:const_local = topindent name \" = \" init nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent name \" = [\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"]\" nl;\n"
"\n"
"code:array_global = <undefined>;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum = [elem: elem \" = \" init nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs nl;\n"
"\n"
"code:type_int = <undefined>;\n"
"code:type_uint = <undefined>;\n"
"code:type_yybm = <undefined>;\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if \" cond \":\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent (.cond ? \"elif \" cond : \"else\") \":\" nl\n"
" indent [stmt: stmt] dedent];\n"
"\n"
"code:if_then_else_oneline = <undefined>;\n"
"\n"
"code:switch =\n"
" topindent \"match \" expr \":\" nl\n"
" indent [case: case] dedent;\n"
"\n"
"code:switch_cases = topindent \"case \"\n"
" [case{0:-2}: case \"|\"]\n"
" [case{-1}: case \":\" nl]\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:switch_cases_oneline = <undefined>;\n"
"\n"
"code:switch_case_range = (.many\n"
" ? [val{0}: val] [val{1:-1}: \"|\" val]\n"
" : [val{0}: val]);\n"
"\n"
"code:switch_case_default = \"_\";\n"
"\n"
"code:loop =\n"
" topindent \"while True:\" nl\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:continue = topindent \"continue\" nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" \"def \" name \"(\" [arg{0}: argname] [arg{1:-1}: \", \" argname] \"):\" nl\n"
" indent [stmt: stmt] dedent;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? retval \" = \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:tailcall =\n"
" topindent (.retval ? \"return \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"# Generated by re2py\" (.version ? \" \" version) (.date ? \" on \" date) nl;\n"
"\n"
"code:line_info = <undefined>;\n"
"\n"
"code:abort = topindent \"raise \\\"internal lexer error\\\"\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \")\"\n"
" : YYDEBUG \"(\" state \", \" yych \")\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.api.generic\n"
" ? yych \" = \" YYPEEK\n"
" : yych \" = \" YYINPUT \"[\" YYCURSOR \"]\"\n"
" ) nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : YYCURSOR \" += 1\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if \" tag \" != \" neg \": \") (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \" -= \" offset\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & .storable_state ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & .storable_state ? yyrecord \".\") var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\") var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
;
+408
View File
@@ -0,0 +1,408 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_RUST =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"loop-switch\", \"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"case-ranges\", \"unsafe\",\n"
" \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 1;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 1;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = loop-switch;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 0;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = generic;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 1;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"YYC_\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 1;\n"
"re2c:unsafe = 1;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\"; // used to generate function names\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"'yyl\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"YYBACKUP\";\n"
"re2c:YYBACKUPCTX = \"YYBACKUPCTX\";\n"
"re2c:YYCONDTYPE = (.storable_state ? \"isize\" : \"usize\");\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCTYPE = \"YYCTYPE\";\n"
"re2c:YYCTXMARKER = (.api.generic ? \"YYCTXMARKER\" : (.api.record ? yyrecord \".\") \"yyctxmarker\");\n"
"re2c:YYCURSOR = (.api.generic ? \"YYCURSOR\" : (.api.record ? yyrecord \".\") \"yycursor\");\n"
"re2c:YYDEBUG = \"YYDEBUG\";\n"
"re2c:YYFILL = \"YYFILL\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"YYGETCONDITION\"; // historic default\n"
"re2c:YYGETSTATE = \"YYGETSTATE\";\n"
"re2c:YYINPUT = (.api.generic ? \"YYINPUT\" : (.api.record ? yyrecord \".\") \"yyinput\");\n"
"re2c:YYLESSTHAN = \"YYLESSTHAN\";\n"
"re2c:YYLIMIT = (.api.generic ? \"YYLIMIT\" : (.api.record ? yyrecord \".\") \"yylimit\");\n"
"re2c:YYMARKER = (.api.generic ? \"YYMARKER\" : (.api.record ? yyrecord \".\") \"yymarker\");\n"
"re2c:YYMAXFILL = \"YYMAXFILL\";\n"
"re2c:YYMAXNMATCH = \"YYMAXNMATCH\";\n"
"re2c:YYMTAGN = \"YYMTAGN\";\n"
"re2c:YYMTAGP = \"YYMTAGP\";\n"
"re2c:YYPEEK = (.api.generic ? \"YYPEEK\" : \"get_unchecked\");\n"
"re2c:YYRESTORE = \"YYRESTORE\";\n"
"re2c:YYRESTORECTX = \"YYRESTORECTX\";\n"
"re2c:YYRESTORETAG = \"YYRESTORETAG\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val};\";\n"
"re2c:YYSETCOND = \"YYSETCONDITION\"; // historic default\n"
"re2c:YYSETSTATE = \"YYSETSTATE\";\n"
"re2c:YYSHIFT = \"YYSHIFT\";\n"
"re2c:YYSHIFTSTAG = \"YYSHIFTSTAG\";\n"
"re2c:YYSHIFTMTAG = \"YYSHIFTMTAG\";\n"
"re2c:YYSKIP = \"YYSKIP\";\n"
"re2c:YYSTAGN = \"YYSTAGN\";\n"
"re2c:YYSTAGP = \"YYSTAGP\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"usize::MAX\");\n"
"re2c:cond:divider = \"\";\n"
"re2c:cond:goto = \"\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local =\n"
" // In Rust uninitialized variable is an error, but if the compiler is able to see\n"
" // that all paths overwrite the initial value, it warns about unused assignments.\n"
" (!.init ? topindent \"#[allow(unused_assignments)]\" nl)\n"
" topindent \"let mut \" name \" : \" type \" = \" init \";\" nl;\n"
"code:var_global = topindent \"static mut \" name \" : \" type \" = \" init \";\" nl;\n"
"\n"
"code:const_local = topindent \"const \" name \": \" type \" = \" init \";\" nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent \"let \" name \": [\" type \"; \" size \"] = [\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"];\" nl;\n"
"\n"
"code:array_global = <undefined>;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum = [elem: topindent \"const \" elem \": \" type \" = \" init \";\" nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs \";\" nl;\n"
"\n"
"code:type_int = \"isize\";\n"
"code:type_uint = \"usize\";\n"
"code:type_yybm = \"u8\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if \" cond \" {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if \" cond \" \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline = <undefined>;\n"
"\n"
"code:switch =\n"
" topindent \"match \" expr \" {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case{0:-2}: topindent case \" |\" nl]\n"
" [case{-1}: topindent case \" => {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl];\n"
"\n"
"code:switch_cases_oneline =\n"
" [case{0:-2}: topindent case \" |\" nl]\n"
" [case{-1}: topindent case \" => \" [stmt: stmt] \",\" nl];\n"
"\n"
"code:switch_case_range = [val{0}: val] (.many ? \" ..= \" [val{-1}: val]);\n"
"\n"
"code:switch_case_default = \"_\";\n"
"\n"
"code:loop =\n"
" topindent (.loop_label ? label \": \") \"loop {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" \" label) \";\" nl;\n"
"\n"
"code:goto = <undefined>;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" topindent \"fn \" name \"(\"\n"
" [arg{0:-2}: argname \": \" argtype \", \"]\n"
" [arg{-1}: argname \": \" argtype]\n"
" \")\" (.type ? \" -> \" type) \" {\" nl\n"
" indent [stmt: stmt] dedent\n"
" \"}\" nl;\n"
"\n"
"code:fncall = topindent name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:tailcall = code:fncall;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"/* Generated by re2rust\" (.version ? \" \" version) (.date ? \" on \" date) \" */\" nl;\n"
"\n"
"// No line directives in Rust: https://github.com/rust-lang/rfcs/issues/1862.\n"
"code:line_info = <undefined>;\n"
"\n"
"code:abort = topindent \"panic!(\\\"internal lexer error\\\")\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \");\"\n"
" : YYDEBUG \"(\" state \", \" yych \");\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.code_model.recursive_functions ? \"let \") yych \" = \" (.api.generic\n"
" ? (.unsafe\n"
" ? \"unsafe {\" YYPEEK \"}\"\n"
" : YYPEEK)\n"
" : (.unsafe\n"
" ? \"unsafe {*\" YYINPUT \".\" YYPEEK \"(\" YYCURSOR \")}\"\n"
" : YYINPUT \"[\" YYCURSOR \"]\") (.cast ? \" as \" YYCTYPE)\n"
" ) \";\" nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : YYCURSOR \" += 1;\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag \";\"\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" (.nested ? topindent \"if \" tag \" != \" neg \" {\" nl indent)\n"
" topindent (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \" -= \" offset \";\"\n"
" ) nl\n"
" (.nested ? dedent topindent \"}\" nl);\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\")\n"
" var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\" var) \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \" as usize] & \" mask \") != 0\";\n"
;
+407
View File
@@ -0,0 +1,407 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_V =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"goto-label\", \"loop-switch\", \"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"case-ranges\", \"unsafe\",\n"
" \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 0;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 0;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = goto-label;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 1;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex;\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 0;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"yyc\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = (.code_model.goto_label ? 0 : 1); // historically disabled for goto/label\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 1;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\";\n"
"re2c:label:yyfill = \"yyFillLabel\";\n"
"re2c:label:yyloop = \"yyl\";\n"
"re2c:label:yyNext = \"yyNext\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"YYCONDTYPE\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs}\";\n"
"re2c:YYCTYPE = \"u8\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"yymaxfill\";\n"
"re2c:YYMAXNMATCH = \"yymaxnmatch\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = \"yypeek\";\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val}\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"-1\");\n"
"re2c:cond:divider = \"/* *********************************** */\";\n"
"re2c:cond:goto = \"unsafe { goto \" sigil \" }\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent \"mut \" name \" := \" init nl;\n"
"code:var_global = <undefined>;\n"
"\n"
"code:const_local = topindent \"const \" name \" = \" init nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent name \" := [\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"]\" nl;\n"
"\n"
"code:array_global = <undefined>;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"// Don't use enum in loop/switch mode, as conditions are assigned to `yystate`.\n"
"code:enum = (.code_model.loop_switch\n"
" ? [elem: \"const \" elem \" = \" init nl]\n"
" : \"enum \" type \" {\" nl\n"
" indent [elem: topindent elem (.init ? \" = \" init) nl] dedent\n"
" \"}\" nl);\n"
"\n"
"code:enum_elem = (!.code_model.loop_switch ? \".\") name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs nl;\n"
"\n"
"code:type_int = \"int\";\n"
"code:type_uint = \"u32\";\n"
"code:type_yybm = \"u8\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if \" cond \" {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if \" cond \" \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline = <undefined>;\n"
"\n"
"code:switch =\n"
" topindent \"match \" expr \" {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases = topindent\n"
" [case{0:-2}: case \", \"]\n"
" [case{-1}: case \" {\"] nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases_oneline = topindent\n"
" [case{0:-2}: case \", \"]\n"
" [case{-1}: case \" { \"] [stmt: stmt] \" }\" nl;\n"
"\n"
"code:switch_case_range = [val{0}: val] (.many ? \"...\" [val{-1}: val]);\n"
"\n"
"code:switch_case_default = \"else\";\n"
"\n"
"code:loop =\n"
" (.loop_label ? label \":\" nl)\n"
" topindent \"for {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" \" label) nl;\n"
"\n"
"code:goto = topindent \"unsafe { goto \" label \" }\" nl;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" topindent \"fn \" name \"(\"\n"
" [arg{0:-2}: argname \" \" argtype \", \"]\n"
" [arg{-1}: argname \" \" argtype]\n"
" \")\" (.type ? \" \" type) \" {\" nl\n"
" indent [stmt: stmt] dedent\n"
" \"}\" nl;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? retval \" = \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:tailcall =\n"
" topindent (.retval ? \"return \") name \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \")\" nl;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"// Code generated by re2v\" (.version ? \" \" version) (.date ? \" on \" date) \", DO NOT EDIT.\" nl;\n"
"\n"
"code:line_info = \"//line \\\"\" file \"\\\":\" line nl;\n"
"\n"
"code:abort = topindent \"panic(\\\"internal lexer error\\\")\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG (.api_style.functions ? \"()\")\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \")\"\n"
" : YYDEBUG \"(\" state \", \" yych \")\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent yych (.code_model.recursive_functions ? \" := \" : \" = \") (.api.generic\n"
" ? YYPEEK\n"
" : YYINPUT \"[\" YYCURSOR \"]\"\n"
" ) nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : YYCURSOR \" += 1\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek = <undefined>;\n"
"code:yypeek_yyskip = <undefined>;\n"
"code:yyskip_yybackup = <undefined>;\n"
"code:yybackup_yyskip = <undefined>;\n"
"code:yybackup_yypeek = <undefined>;\n"
"code:yyskip_yybackup_yypeek = <undefined>;\n"
"code:yybackup_yypeek_yyskip = <undefined>;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" (.nested ? topindent \"if \" tag \" != \" neg \" {\" nl indent)\n"
" topindent (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \"-= \" offset\n"
" ) nl\n"
" (.nested ? dedent topindent \"}\" nl);\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\")\n"
" var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\") var \" = \" val\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
;
+420
View File
@@ -0,0 +1,420 @@
#include "src/parse/conf_parser.h"
const char* DEFAULT_SYNTAX_ZIG =
"// supported feature lists -----------------------------------------------------\n"
"\n"
"supported_apis = [\"simple\", \"generic\", \"record\"];\n"
"supported_api_styles = [\"free-form\"];\n"
"supported_code_models = [\"loop-switch\", \"recursive-functions\"];\n"
"supported_targets = [\"code\", \"dot\"];\n"
"supported_features = [\"nested-ifs\", \"bitmaps\", \"case-ranges\",\n"
" \"tags\", \"captures\", \"captvars\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
"\n"
"semicolons = 1;\n"
"backtick_quoted_strings = 0;\n"
"single_quoted_strings = 0;\n"
"indentation_sensitive = 0;\n"
"wrap_blocks_in_braces = 0;\n"
"\n"
"\n"
"// immutable configurations (command-line only options) ------------------------\n"
"\n"
"re2c:target = code;\n"
"re2c:code-model = loop-switch;\n"
"re2c:input-encoding = ascii;\n"
"re2c:date = 1;\n"
"re2c:version = 1;\n"
"re2c:conditions = 0;\n"
"re2c:storable-state = 0;\n"
"re2c:flex-syntax = 0;\n"
"re2c:verbose = 0;\n"
"re2c:line-dirs = 0;\n"
"\n"
"\n"
"// mutable configurations ------------------------------------------------------\n"
"\n"
"re2c:api = simple;\n"
"re2c:api:style = free-form;\n"
"re2c:api:sigil = \"@@\";\n"
"re2c:YYGETCOND:naked = 0;\n"
"re2c:YYSETCOND:naked = 0;\n"
"re2c:YYSETCOND@cond = \"@@\";\n"
"re2c:YYGETSTATE:naked = 0;\n"
"re2c:YYSETSTATE:naked = 0;\n"
"re2c:YYSETSTATE@state = \"@@\";\n"
"re2c:YYFILL@len = \"@@\";\n"
"re2c:YYFILL:naked = 0;\n"
"re2c:YYFN = [\"<undefined-function-name>;<undefined-function-type>\"];\n"
"re2c:yyfn:sep = \";\";\n"
"re2c:yycond = \"yycond\";\n"
"re2c:yyctable = \"yyctable\";\n"
"re2c:yyaccept = \"yyaccept\";\n"
"re2c:yytarget = \"yytarget\";\n"
"re2c:yystate = \"yystate\";\n"
"re2c:yynmatch = \"yynmatch\";\n"
"re2c:yypmatch = \"yypmatch\";\n"
"re2c:yyrecord = \"yyrecord\";\n"
"re2c:yych = \"yych\";\n"
"re2c:yych:conversion = 0;\n"
"re2c:yych:literals = hex; // zig does not recognize '\\f' escape sequence => use hex\n"
"re2c:yych:emit = (.code_model.recursive_functions ? 0 : 1);\n"
"re2c:yybm = \"yybm\";\n"
"re2c:yybm:hex = 0;\n"
"re2c:yyfill = \"\";\n"
"re2c:yystable = \"\"; // deprecated\n"
"re2c:header = \"\";\n"
"re2c:eof = -1;\n"
"re2c:sentinel = -1;\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
"re2c:tags = 0;\n"
"re2c:tags:prefix = \"yyt\";\n"
"re2c:captures = 0;\n"
"re2c:captvars = 0;\n"
"re2c:posix-captures = 0;\n"
"re2c:posix-captvars = 0;\n"
"re2c:invert-captures = 0;\n"
"re2c:cond:abort = 1;\n"
"re2c:cond:prefix = \"yyc_\";\n"
"re2c:cond:enumprefix = \"yyc\";\n"
"re2c:cond:divider@cond = \"@@\";\n"
"re2c:cond:goto@cond = \"@@\";\n"
"re2c:state:abort = 1;\n"
"re2c:state:nextlabel = 0;\n"
"re2c:bit-vectors = 0;\n"
"re2c:debug-output = 0;\n"
"re2c:computed-gotos = 0;\n"
"re2c:computed-gotos:threshold = 9;\n"
"re2c:nested-ifs = 0;\n"
"re2c:case-insensitive = 0;\n"
"re2c:case-inverted = 0;\n"
"re2c:case-ranges = 1;\n"
"re2c:unsafe = 0;\n"
"re2c:monadic = 0;\n"
"re2c:encoding:ebcdic = 0;\n"
"re2c:encoding:utf32 = 0;\n"
"re2c:encoding:ucs2 = 0;\n"
"re2c:encoding:utf16 = 0;\n"
"re2c:encoding:utf8 = 0;\n"
"re2c:encoding-policy = ignore;\n"
"re2c:empty-class = match-empty;\n"
"re2c:indent:string = \" \";\n"
"re2c:indent:top = 0;\n"
"re2c:label:prefix = \"yy\"; // used to generate function names\n"
"re2c:label:yyfill = \"\";\n"
"re2c:label:yyloop = \"yyl\";\n"
"re2c:label:yyNext = \"\";\n"
"re2c:label:start = 0;\n"
"\n"
"\n"
"// mutable code configuration --------------------------------------------------\n"
"\n"
"re2c:YYBACKUP = \"yybackup\";\n"
"re2c:YYBACKUPCTX = \"yybackupctx\";\n"
"re2c:YYCONDTYPE = \"u32\";\n"
"re2c:YYCOPYMTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCOPYSTAG = sigil \"{lhs} = \" sigil \"{rhs};\";\n"
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCTYPE = \"u8\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
"re2c:YYGETSTATE = \"yygetstate\";\n"
"re2c:YYINPUT = (.api.record ? yyrecord \".\") \"yyinput\";\n"
"re2c:YYLESSTHAN = \"yylessthan\";\n"
"re2c:YYLIMIT = (.api.record ? yyrecord \".\") \"yylimit\";\n"
"re2c:YYMARKER = (.api.record ? yyrecord \".\") \"yymarker\";\n"
"re2c:YYMAXFILL = \"yymaxfill\";\n"
"re2c:YYMAXNMATCH = \"yymaxnmatch\";\n"
"re2c:YYMTAGN = \"yymtagn\";\n"
"re2c:YYMTAGP = \"yymtagp\";\n"
"re2c:YYPEEK = \"yypeek\";\n"
"re2c:YYRESTORE = \"yyrestore\";\n"
"re2c:YYRESTORECTX = \"yyrestorectx\";\n"
"re2c:YYRESTORETAG = \"yyrestoretag\";\n"
"re2c:YYSETACCEPT = sigil \"{var} = \" sigil \"{val};\";\n"
"re2c:YYSETCOND = \"yysetcond\";\n"
"re2c:YYSETSTATE = \"yysetstate\";\n"
"re2c:YYSHIFT = \"yyshift\";\n"
"re2c:YYSHIFTSTAG = \"yyshiftstag\";\n"
"re2c:YYSHIFTMTAG = \"yyshiftmtag\";\n"
"re2c:YYSKIP = \"yyskip\";\n"
"re2c:YYSTAGN = \"yystagn\";\n"
"re2c:YYSTAGP = \"yystagp\";\n"
"re2c:tags:expression = (.api.record ? yyrecord \".\") sigil;\n"
"re2c:tags:negative = (.api.generic ? \"@@\" : \"std.math.maxInt(usize)\");\n"
"re2c:cond:divider = \"/* *********************************** */\";\n"
"re2c:cond:goto = \"goto \" sigil \";\";\n"
"\n"
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent \"var \" name \": \" type \" = \" (.init ? init : \"0\") \";\" nl;\n"
"code:var_global = code:var_local;\n"
"\n"
"code:const_local = topindent \"const \" name \" = \" init \";\" nl;\n"
"code:const_global = code:const_local;\n"
"\n"
"code:array_local =\n"
" topindent \"const \" name \" = [\" size \"]\" type \"{\" nl indent\n"
" [row: topindent [elem{0:-2}: elem \", \"] [elem{-1}: elem \",\"] nl]\n"
" dedent topindent \"};\" nl;\n"
"\n"
"code:array_global = <undefined>;\n"
"\n"
"code:array_elem = array \"[\" index \"]\";\n"
"\n"
"code:enum = [elem: topindent \"const \" elem \": \" type \" = \" init \";\" nl];\n"
"\n"
"code:enum_elem = name;\n"
"\n"
"code:assign = topindent lhs \" = \" rhs \";\" nl;\n"
"\n"
"code:type_int = \"i32\";\n"
"code:type_uint = \"u32\";\n"
"code:type_yybm = \"u8\";\n"
"code:type_yytarget = <undefined>;\n"
"\n"
"code:cmp_eq = \"==\";\n"
"code:cmp_ne = \"!=\";\n"
"code:cmp_lt = \"<\";\n"
"code:cmp_gt = \">\";\n"
"code:cmp_le = \"<=\";\n"
"code:cmp_ge = \">=\";\n"
"\n"
"code:if_then_else =\n"
" [branch{0}: topindent \"if (\" cond \") {\" nl\n"
" indent [stmt: stmt] dedent]\n"
" [branch{1:-1}: topindent \"} else \" (.cond ? \"if (\" cond \") \") \"{\" nl\n"
" indent [stmt: stmt] dedent]\n"
" topindent \"}\" nl;\n"
"\n"
"code:if_then_else_oneline =\n"
" [branch{0}: topindent \"if (\" cond \") { \" [stmt: stmt] \" }\" nl]\n"
" [branch{1:-1}: topindent \"else \" (.cond ? \"if (\" cond \") \") \" {\" [stmt: stmt] \" }\" nl];\n"
"\n"
"code:switch =\n"
" topindent \"switch (\" expr \") {\" nl\n"
" indent [case: case] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:switch_cases =\n"
" [case{0:-2}: topindent case \",\" nl]\n"
" [case{-1}: topindent case \" => {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"},\" nl];\n"
"\n"
"code:switch_cases_oneline =\n"
" [case{0:-2}: topindent case \",\" nl]\n"
" [case{-1}: topindent case \" => { \" [stmt: stmt] \" },\" nl];\n"
"\n"
"code:switch_case_range = [val{0}: val] (.many ? \"...\" [val{-1}: val]);\n"
"\n"
"code:switch_case_default = \"else\";\n"
"\n"
"code:loop =\n"
" topindent (.loop_label ? label \": \") \"while (true) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" :\" label) \";\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
"code:fndecl = <undefined>;\n"
"\n"
"code:fndef =\n"
" topindent \"fn \" name \"(\"\n"
" [arg{0:-2}: argname \": \" argtype \", \"]\n"
" [arg{-1}: argname \": \" argtype]\n"
" \") \" type \" {\" nl\n"
" indent [stmt: stmt] dedent\n"
" \"}\" nl;\n"
"\n"
"code:fncall =\n"
" topindent (.retval ? retval \" = \" name) \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \");\" nl;\n"
"\n"
"code:tailcall =\n"
" topindent (.retval ? \"return \" name) \"(\" [arg{0:-2}: arg \", \"] [arg{-1}: arg] \");\" nl;\n"
"\n"
"code:recursive_functions = [fn: fndef nl];\n"
"\n"
"code:fingerprint =\n"
" \"// Generated by re2zig\" (.version ? \" \" version) (.date ? \" on \" date) nl;\n"
"\n"
"code:line_info = <undefined>;\n"
"\n"
"code:abort = topindent \"@panic(\\\"internal lexer error\\\");\" nl;\n"
"\n"
"code:yydebug =\n"
" topindent (.api.generic\n"
" ? YYDEBUG\n"
" : (.api.record\n"
" ? YYDEBUG \"(\" yyrecord \");\"\n"
" : YYDEBUG \"(\" state \", \" yych \");\"\n"
" )) nl;\n"
"\n"
"code:yypeek =\n"
" topindent (.code_model.recursive_functions ? \"var \" yych \": \" YYCTYPE : yych) \" = \" (.api.generic\n"
" ? YYPEEK\n"
" : (.cast ? \"@intCast(\") YYINPUT \"[\" YYCURSOR \"]\" (.cast ? \")\")\n"
" ) \";\" nl;\n"
"\n"
"code:yyskip =\n"
" topindent (.api.generic\n"
" ? YYSKIP\n"
" : YYCURSOR \" += 1;\"\n"
" ) nl;\n"
"\n"
"code:yybackup =\n"
" topindent (.api.generic\n"
" ? YYBACKUP\n"
" : YYMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yybackupctx =\n"
" topindent (.api.generic\n"
" ? YYBACKUPCTX\n"
" : YYCTXMARKER \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yyskip_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"@intCast(\") \"*++\" YYCURSOR (.cast ? \")\") \";\" nl;\n"
"\n"
"code:yypeek_yyskip =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"@intCast(\") \"*\" YYCURSOR \"++\" (.cast ? \")\") \";\" nl;\n"
"\n"
"code:yyskip_yybackup =\n"
" topindent YYMARKER \" = ++\" YYCURSOR \";\" nl;\n"
"\n"
"code:yybackup_yyskip =\n"
" topindent YYMARKER \" = \" YYCURSOR \"++;\" nl;\n"
"\n"
"code:yybackup_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"@intCast(\") \"*(\" YYMARKER \" = \" YYCURSOR \")\" (.cast ? \")\") \";\" nl;\n"
"\n"
"code:yyskip_yybackup_yypeek =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"@intCast(\") \"*(\" YYMARKER \" = ++\" YYCURSOR \")\" (.cast ? \")\") \";\" nl;\n"
"\n"
"code:yybackup_yypeek_yyskip =\n"
" topindent (.code_model.recursive_functions ? YYCTYPE \" \") yych \" = \"\n"
" (.cast ? \"@intCast(\") \"*(\" YYMARKER \" = \" YYCURSOR \"++\" (.cast ? \")\") \");\" nl;\n"
"\n"
"code:yyrestore =\n"
" topindent (.api.generic\n"
" ? YYRESTORE\n"
" : YYCURSOR \" = \" YYMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestorectx =\n"
" topindent (.api.generic\n"
" ? YYRESTORECTX\n"
" : YYCURSOR \" = \" YYCTXMARKER \";\"\n"
" ) nl;\n"
"\n"
"code:yyrestoretag =\n"
" topindent (.api.generic\n"
" ? YYRESTORETAG\n"
" : YYCURSOR \" = \" tag \";\"\n"
" ) nl;\n"
"\n"
"code:yyshift =\n"
" topindent (.api.generic\n"
" ? YYSHIFT\n"
" : YYCURSOR \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftstag =\n"
" topindent (.nested ? \"if (\" tag \" != \" neg \") \")\n"
" (.api.generic\n"
" ? YYSHIFTSTAG\n"
" : tag \" -= \" offset \";\"\n"
" ) nl;\n"
"\n"
"code:yyshiftmtag =\n"
" topindent YYSHIFTMTAG nl;\n"
"\n"
"code:yystagp =\n"
" topindent (.api.generic\n"
" ? YYSTAGP\n"
" : tag \" = \" YYCURSOR \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagp =\n"
" topindent YYMTAGP nl;\n"
"\n"
"code:yystagn =\n"
" topindent (.api.generic\n"
" ? YYSTAGN\n"
" : tag \" = \" neg \";\"\n"
" ) nl;\n"
"\n"
"code:yymtagn =\n"
" topindent YYMTAGN nl;\n"
"\n"
"code:yycopystag =\n"
" topindent (.api.generic\n"
" ? YYCOPYSTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yycopymtag =\n"
" topindent (.api.generic\n"
" ? YYCOPYMTAG\n"
" : lhs \" = \" rhs \";\"\n"
" ) nl;\n"
"\n"
"code:yygetaccept =\n"
" (.api.generic\n"
" ? YYGETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\") var);\n"
"\n"
"code:yysetaccept =\n"
" topindent (.api.generic\n"
" ? YYSETACCEPT\n"
" : (.api.record & (.storable_state | .code_model.recursive_functions) ? yyrecord \".\")\n"
" var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetcond =\n"
" (.api.generic\n"
" ? YYGETCOND\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetcond =\n"
" topindent (.api.generic\n"
" ? YYSETCOND\n"
" : (.api.record ? yyrecord \".\") var \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yygetstate =\n"
" (.api.generic\n"
" ? YYGETSTATE\n"
" : (.api.record ? yyrecord \".\") var);\n"
"\n"
"code:yysetstate =\n"
" topindent (.api.generic\n"
" ? YYSETSTATE\n"
" : (.api.record ? yyrecord \".\" var) \" = \" val \";\"\n"
" ) nl;\n"
"\n"
"code:yylessthan =\n"
" (.api.generic\n"
" ? YYLESSTHAN\n"
" : (.many\n"
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
;
@@ -2,9 +2,7 @@ extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2c [ OPTIONS ] [ WARNINGS ] INPUT\n"
" re2go [ OPTIONS ] [ WARNINGS ] INPUT\n"
" re2rust [ OPTIONS ] [ WARNINGS ] INPUT\n"
" re2c [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
@@ -14,18 +12,32 @@ const char* help =
"\n"
" Show help message.\n"
"\n"
" --api --input <default | custom>\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code: default is the API based on pointer arithmetic (the\n"
" default for C), and custom is the generic API (the default for Go and\n"
" Rust).\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
@@ -63,9 +75,9 @@ const char* help =
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include:re2c directives, so\n"
" that updating include files triggers regeneration of the output file.\n"
" This option depends on the --output option.\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
@@ -95,19 +107,31 @@ const char* help =
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified with\n"
" directives header:re2c:on and header:re2c:off. If conditions are used\n"
" the header will have a condition enum automatically appended to it\n"
" (unless there is an explicit conditions:re2c directive).\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include:re2c\n"
" directive. re2c looks for FILE in the directory of the parent file and\n"
" in the include locations specified with -I option.\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2c looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
@@ -116,10 +140,20 @@ const char* help =
" units is a sequence of standalone 1-byte characters. With utf8 re2c\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --lang <c | go | rust>\n"
" --invert-captures\n"
"\n"
" Specify the output language. Supported languages are C, Go and Rust.\n"
" The default is C for re2c, Go for re2go and Rust for re2rust.\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
@@ -129,12 +163,11 @@ const char* help =
"\n"
" --loop-switch\n"
"\n"
" Encode DFA in a form of a loop over a switch statement. Individual\n"
" states are switch cases. The current state is stored in a variable\n"
" yystate. Transitions between states update yystate to the case label of\n"
" the destination state and continue to the head of the loop. This option\n"
" is always enabled for Rust, as it has no goto statement and cannot use\n"
" the goto/label approach which is the default for C and Go backends.\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
@@ -146,8 +179,7 @@ const char* help =
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes). This option is on by default for Rust, as it\n"
" does not have line directives.\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
@@ -171,9 +203,22 @@ const char* help =
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures -P\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups.\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
@@ -198,6 +243,14 @@ const char* help =
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
@@ -394,9 +447,9 @@ const char* help =
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either the ---header option or the\n"
" conditions:re2c directive to generate a mapping of condition names to\n"
" numbers and then use the autogenerated condition names.\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
@@ -447,4 +500,13 @@ const char* help =
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+512
View File
@@ -0,0 +1,512 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2d [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2d generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2d blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2d assumes that\n"
" the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2d treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2d treats Unicode surrogates. With fail re2d aborts\n"
" with an error when a surrogate is encountered. With substitute re2d\n"
" silently replaces surrogates with the error code point 0xFFFD. With\n"
" ignore (the default) re2d treats surrogates as normal code points. The\n"
" Unicode standard says that standalone surrogates are invalid, but real-\n"
" world libraries and programs behave in different ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2d looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2d parses regular expressions. With ascii (the\n"
" default) re2d handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2d\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2d assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2d assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2d assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2d assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 4 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2d. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2d permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2d\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+512
View File
@@ -0,0 +1,512 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2go [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2go generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2go blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2go assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2go treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2go treats Unicode surrogates. With fail re2go aborts\n"
" with an error when a surrogate is encountered. With substitute re2go\n"
" silently replaces surrogates with the error code point 0xFFFD. With\n"
" ignore (the default) re2go treats surrogates as normal code points. The\n"
" Unicode standard says that standalone surrogates are invalid, but real-\n"
" world libraries and programs behave in different ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2go looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2go parses regular expressions. With ascii (the\n"
" default) re2go handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2go\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2go assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2go assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2go assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2go assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 4 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2go. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2go permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2go\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+512
View File
@@ -0,0 +1,512 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2hs [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2hs generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2hs blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2hs assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2hs treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2hs treats Unicode surrogates. With fail re2hs aborts\n"
" with an error when a surrogate is encountered. With substitute re2hs\n"
" silently replaces surrogates with the error code point 0xFFFD. With\n"
" ignore (the default) re2hs treats surrogates as normal code points. The\n"
" Unicode standard says that standalone surrogates are invalid, but real-\n"
" world libraries and programs behave in different ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2hs looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2hs parses regular expressions. With ascii (the\n"
" default) re2hs handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2hs\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2hs assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2hs assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2hs assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2hs assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 4 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2hs. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2hs permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2hs\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+514
View File
@@ -0,0 +1,514 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2java [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2java generates jump\n"
" tables only in complex cases with a lot of conditional branches.\n"
" Complexity threshold can be configured with cgoto:threshold\n"
" configuration. This option implies --bit-vectors. It is supported only\n"
" for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2java blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2java assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2java treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2java treats Unicode surrogates. With fail re2java\n"
" aborts with an error when a surrogate is encountered. With substitute\n"
" re2java silently replaces surrogates with the error code point 0xFFFD.\n"
" With ignore (the default) re2java treats surrogates as normal code\n"
" points. The Unicode standard says that standalone surrogates are\n"
" invalid, but real-world libraries and programs behave in different\n"
" ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2java looks for FILE in the directory of the parent\n"
" file and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2java parses regular expressions. With ascii (the\n"
" default) re2java handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2java\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2java assumes that\n"
" the character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2java assumes\n"
" that the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2java assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 2 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2java assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 4 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2java. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2java permits\n"
" empty character classes and treats them as empty strings. Use the\n"
" --empty-class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2java\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+512
View File
@@ -0,0 +1,512 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2js [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2js generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2js blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2js assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2js treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2js treats Unicode surrogates. With fail re2js aborts\n"
" with an error when a surrogate is encountered. With substitute re2js\n"
" silently replaces surrogates with the error code point 0xFFFD. With\n"
" ignore (the default) re2js treats surrogates as normal code points. The\n"
" Unicode standard says that standalone surrogates are invalid, but real-\n"
" world libraries and programs behave in different ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2js looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2js parses regular expressions. With ascii (the\n"
" default) re2js handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2js\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2js assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2js assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2js assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2js assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 4 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2js. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2js permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2js\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+515
View File
@@ -0,0 +1,515 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2ocaml [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2ocaml generates jump\n"
" tables only in complex cases with a lot of conditional branches.\n"
" Complexity threshold can be configured with cgoto:threshold\n"
" configuration. This option implies --bit-vectors. It is supported only\n"
" for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2ocaml blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2ocaml assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2ocaml treats empty character classes. With match-\n"
" empty (the default) empty class matches empty input (which is\n"
" illogical, but backwards-compatible). With match-none empty class\n"
" always fails to match. With error empty class raises a compilation\n"
" error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2ocaml treats Unicode surrogates. With fail re2ocaml\n"
" aborts with an error when a surrogate is encountered. With substitute\n"
" re2ocaml silently replaces surrogates with the error code point 0xFFFD.\n"
" With ignore (the default) re2ocaml treats surrogates as normal code\n"
" points. The Unicode standard says that standalone surrogates are\n"
" invalid, but real-world libraries and programs behave in different\n"
" ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2ocaml looks for FILE in the directory of the parent\n"
" file and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2ocaml parses regular expressions. With ascii (the\n"
" default) re2ocaml handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2ocaml\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2ocaml assumes that\n"
" the character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2ocaml assumes\n"
" that the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2ocaml assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 2 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2ocaml assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 4 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2ocaml. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2ocaml permits\n"
" empty character classes and treats them as empty strings. Use the\n"
" --empty-class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2ocaml\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+512
View File
@@ -0,0 +1,512 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2py [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2py generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2py blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2py assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2py treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2py treats Unicode surrogates. With fail re2py aborts\n"
" with an error when a surrogate is encountered. With substitute re2py\n"
" silently replaces surrogates with the error code point 0xFFFD. With\n"
" ignore (the default) re2py treats surrogates as normal code points. The\n"
" Unicode standard says that standalone surrogates are invalid, but real-\n"
" world libraries and programs behave in different ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2py looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2py parses regular expressions. With ascii (the\n"
" default) re2py handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2py\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2py assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2py assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2py assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2py assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 4 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2py. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2py permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2py\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+514
View File
@@ -0,0 +1,514 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2rust [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2rust generates jump\n"
" tables only in complex cases with a lot of conditional branches.\n"
" Complexity threshold can be configured with cgoto:threshold\n"
" configuration. This option implies --bit-vectors. It is supported only\n"
" for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2rust blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2rust assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2rust treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2rust treats Unicode surrogates. With fail re2rust\n"
" aborts with an error when a surrogate is encountered. With substitute\n"
" re2rust silently replaces surrogates with the error code point 0xFFFD.\n"
" With ignore (the default) re2rust treats surrogates as normal code\n"
" points. The Unicode standard says that standalone surrogates are\n"
" invalid, but real-world libraries and programs behave in different\n"
" ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2rust looks for FILE in the directory of the parent\n"
" file and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2rust parses regular expressions. With ascii (the\n"
" default) re2rust handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2rust\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2rust assumes that\n"
" the character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2rust assumes\n"
" that the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2rust assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 2 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2rust assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 4 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2rust. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2rust permits\n"
" empty character classes and treats them as empty strings. Use the\n"
" --empty-class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2rust\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+512
View File
@@ -0,0 +1,512 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2v [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2v generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2v blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2v assumes that\n"
" the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2v treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2v treats Unicode surrogates. With fail re2v aborts\n"
" with an error when a surrogate is encountered. With substitute re2v\n"
" silently replaces surrogates with the error code point 0xFFFD. With\n"
" ignore (the default) re2v treats surrogates as normal code points. The\n"
" Unicode standard says that standalone surrogates are invalid, but real-\n"
" world libraries and programs behave in different ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2v looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2v parses regular expressions. With ascii (the\n"
" default) re2v handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2v\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2v assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2v assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2v assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2v assumes that the\n"
" character range is 0 -- 0x10FFFF and character size is 4 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2v. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2v permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2v\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+513
View File
@@ -0,0 +1,513 @@
extern const char* help;
const char* help =
"USAGE\n"
"\n"
" re2zig [ OPTIONS ] [ WARNINGS ] INPUT\n"
"\n"
" Input can be either a file or - for stdin.\n"
"\n"
"OPTIONS\n"
"\n"
" -? --help -h\n"
"\n"
" Show help message.\n"
"\n"
" --api <simple | record | generic>\n"
"\n"
" Specify the API used by the generated code to interface with used-\n"
" defined code. Option simple shold be used in simple cases when there's\n"
" no need for buffer refilling and storing lexer state. Option record\n"
" should be used when lexer state needs to be stored in a record (struct,\n"
" class, etc.). Option generic should be used in complex cases when the\n"
" other two APIs are not flexible enough.\n"
"\n"
" --bit-vectors -b\n"
"\n"
" Optimize conditional jumps using bit masks. This option implies\n"
" --nested-ifs.\n"
"\n"
" --captures, --leftmost-captures\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --captvars, --leftmost-captvars\n"
"\n"
" Enable submatch extraction with leftmost greedy capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --case-insensitive\n"
"\n"
" Treat single-quoted and double-quoted strings as case-insensitive.\n"
"\n"
" --case-inverted\n"
"\n"
" Invert the meaning of single-quoted and double-quoted strings: treat\n"
" single-quoted strings as case-sensitive and double-quoted strings as\n"
" case-insensitive.\n"
"\n"
" --case-ranges\n"
"\n"
" Collapse consecutive cases in a switch statements into a range of the\n"
" form low ... high. This syntax is a C/C++ language extension that is\n"
" supported by compilers like GCC, Clang and Tcc. The main advantage over\n"
" using single cases is smaller generated code and faster generation\n"
" time, although for some compilers like Tcc it also results in smaller\n"
" binary size. This option is supported only for C.\n"
"\n"
" --computed-gotos -g\n"
"\n"
" Optimize conditional jumps using non-standard \"computed goto\" extension\n"
" (which must be supported by the compiler). re2zig generates jump tables\n"
" only in complex cases with a lot of conditional branches. Complexity\n"
" threshold can be configured with cgoto:threshold configuration. This\n"
" option implies --bit-vectors. It is supported only for C.\n"
"\n"
" --conditions --start-conditions -c\n"
"\n"
" Enable support of Flex-like \"conditions\": multiple interrelated lexers\n"
" within one block. This is an alternative to manually specifying\n"
" different re2zig blocks connected with goto or function calls.\n"
"\n"
" --depfile FILE\n"
"\n"
" Write dependency information to FILE in the form of a Makefile rule\n"
" <output-file> : <input-file> [include-file ...]. This allows one to\n"
" track build dependencies in the presence of include blocks/directives,\n"
" so that updating include files triggers regeneration of the output\n"
" file. This option depends on the --output option.\n"
"\n"
" --ebcdic --ecb -e\n"
"\n"
" Generate a lexer that reads input in EBCDIC encoding. re2zig assumes\n"
" that the character range is 0 -- 0xFF and character size is 1 byte.\n"
"\n"
" --empty-class <match-empty | match-none | error>\n"
"\n"
" Define the way re2zig treats empty character classes. With match-empty\n"
" (the default) empty class matches empty input (which is illogical, but\n"
" backwards-compatible). With match-none empty class always fails to\n"
" match. With error empty class raises a compilation error.\n"
"\n"
" --encoding-policy <fail | substitute | ignore>\n"
"\n"
" Define the way re2zig treats Unicode surrogates. With fail re2zig\n"
" aborts with an error when a surrogate is encountered. With substitute\n"
" re2zig silently replaces surrogates with the error code point 0xFFFD.\n"
" With ignore (the default) re2zig treats surrogates as normal code\n"
" points. The Unicode standard says that standalone surrogates are\n"
" invalid, but real-world libraries and programs behave in different\n"
" ways.\n"
"\n"
" --flex-syntax -F\n"
"\n"
" Partial support for Flex syntax: in this mode named definitions don't\n"
" need the equal sign and the terminating semicolon, and when used they\n"
" must be surrounded with curly braces. Names without curly braces are\n"
" treated as double-quoted strings.\n"
"\n"
" --goto-label\n"
"\n"
" Use \"goto/label\" code model: encode DFA in form of labeled code blocks\n"
" connected with goto transitions across blocks. This is only supported\n"
" for languages that have a goto statement.\n"
"\n"
" --header --type-header -t HEADER\n"
"\n"
" Generate a HEADER file. The contents of the file can be specified using\n"
" special blocks header:on and header:off. If conditions are used, the\n"
" generated header will have a condition enum automatically appended to\n"
" it (unless there is an explicit conditions block).\n"
"\n"
" -I PATH\n"
"\n"
" Add PATH to the list of locations which are used when searching for\n"
" include files. This option is useful in combination with include block\n"
" or directive. re2zig looks for FILE in the directory of the parent file\n"
" and in the include locations specified with -I option.\n"
"\n"
" --input <default | custom>\n"
"\n"
" Deprecated alias for --api. Option default corresponds to simple (it is\n"
" indeed the default for most backends, but not for all). Option custom\n"
" corresponds to generic.\n"
"\n"
" --input-encoding <ascii | utf8>\n"
"\n"
" Specify the way re2zig parses regular expressions. With ascii (the\n"
" default) re2zig handles input as ASCII-encoded: any sequence of code\n"
" units is a sequence of standalone 1-byte characters. With utf8 re2zig\n"
" handles input as UTF8-encoded and recognizes multibyte characters.\n"
"\n"
" --invert-captures\n"
"\n"
" Invert the meaning of capturing and non-capturing groups. By default\n"
" (...) is capturing and (! ...) is non-capturing. With this option (!\n"
" ...) is capturing and (...) is non-capturing.\n"
"\n"
" --lang <none | c | d | go | haskell | java | js | ocaml | python | rust | v\n"
" | zig>\n"
"\n"
" Specify the target language. Supported languages are C, D, Go, Haskell,\n"
" Java, JS, OCaml, Python, Rust, V, Zig (more languages can be added via\n"
" user-defined syntax files, see the --syntax option). Option none\n"
" disables default suntax configs, so that the target language is\n"
" undefined.\n"
"\n"
" --location-format <gnu | msvc>\n"
"\n"
" Specify location format in messages. With gnu locations are printed as\n"
" 'filename:line:column: ...'. With msvc locations are printed as\n"
" 'filename(line,column) ...'. The default is gnu.\n"
"\n"
" --loop-switch\n"
"\n"
" Use \"loop/switch\" code model: encode DFA in form of a loop over a\n"
" switch statement, where individual states are switch cases. State is\n"
" stored in a variable yystate. Transitions between states update yystate\n"
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
" jumps. This usually results in more efficient code with non-optimizing\n"
" compilers.\n"
"\n"
" --no-debug-info -i\n"
"\n"
" Do not output line directives. This may be useful when the generated\n"
" code is stored in a version control system (to avoid huge autogenerated\n"
" diffs on small changes).\n"
"\n"
" --no-generation-date\n"
"\n"
" Suppress date output in the generated file.\n"
"\n"
" --no-version\n"
"\n"
" Suppress version output in the generated file.\n"
"\n"
" --no-unsafe\n"
"\n"
" Do not generate unsafe wrapper over YYPEEK (this option is specific to\n"
" Rust). For performance reasons YYPEEK should avoid bounds-checking, as\n"
" the lexer already performs end-of-input checks in a more efficient way.\n"
" The user may choose to provide a safe YYPEEK definition, or a\n"
" definition that is unsafe only in release builds, in which case the\n"
" --no-unsafe option helps to avoid warnings about redundant unsafe\n"
" blocks.\n"
"\n"
" --output -o OUTPUT\n"
"\n"
" Specify the OUTPUT file.\n"
"\n"
" --posix-captures, -P\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into an array yybmatch of capacity 2 * YYMAXNMATCH,\n"
" and yynmatch is set to the number of groups for the matching rule.\n"
"\n"
" --posix-captvars\n"
"\n"
" Enable submatch extraction with POSIX-style capturing groups. The\n"
" result is collected into variables yytl<k>, yytr<k> for k-th capturing\n"
" group.\n"
"\n"
" --recursive-functions\n"
"\n"
" Use code model based on co-recursive functions, where each DFA state is\n"
" a separate function that may call other state-functions or itself.\n"
"\n"
" --reusable -r\n"
"\n"
" Deprecated since version 2.2 (reusable blocks are allowed by default\n"
" now).\n"
"\n"
" --skeleton -S\n"
"\n"
" Ignore user-defined interface code and generate a self-contained\n"
" \"skeleton\" program. Additionally, generate input files with strings\n"
" derived from the regular grammar and compressed match results that are\n"
" used to verify \"skeleton\" behavior on all inputs. This option is useful\n"
" for finding bugs in optimizations and code generation. This option is\n"
" supported only for C.\n"
"\n"
" --storable-state -f\n"
"\n"
" Generate a lexer which can store its inner state. This is useful in\n"
" push-model lexers which are stopped by an outer program when there is\n"
" not enough input, and then resumed when more input becomes available.\n"
" In this mode users should additionally define YYGETSTATE and YYSETSTATE\n"
" primitives, and variables yych, yyaccept and state should be part of\n"
" the stored lexer state.\n"
"\n"
" --syntax FILE\n"
"\n"
" Load configurations from the specified FILE and apply them on top of\n"
" the default syntax file. Note that FILE can define only a few\n"
" configurations (if it's used to amend the default syntax file), or it\n"
" can define a whole new language backend (in the latter case it is\n"
" recommended to use --lang none option).\n"
"\n"
" --tags -T\n"
"\n"
" Enable submatch extraction with tags.\n"
"\n"
" --ucs2 --wide-chars -w\n"
"\n"
" Generate a lexer that reads UCS2-encoded input. re2zig assumes that the\n"
" character range is 0 -- 0xFFFF and character size is 2 bytes. This\n"
" option implies --nested-ifs.\n"
"\n"
" --utf8 --utf-8 -8\n"
"\n"
" Generate a lexer that reads input in UTF-8 encoding. re2zig assumes\n"
" that the character range is 0 -- 0x10FFFF and character size is 1 byte.\n"
"\n"
" --utf16 --utf-16 -x\n"
"\n"
" Generate a lexer that reads UTF16-encoded input. re2zig assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 2 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --utf32 --unicode -u\n"
"\n"
" Generate a lexer that reads UTF32-encoded input. re2zig assumes that\n"
" the character range is 0 -- 0x10FFFF and character size is 4 bytes.\n"
" This option implies --nested-ifs.\n"
"\n"
" --verbose\n"
"\n"
" Output a short message in case of success.\n"
"\n"
" --vernum -V\n"
"\n"
" Show version information in MMmmpp format (major, minor, patch).\n"
"\n"
" --version -v\n"
"\n"
" Show version information.\n"
"\n"
" --single-pass -1\n"
"\n"
" Deprecated. Does nothing (single pass is the default now).\n"
"\n"
" --debug-output -d\n"
"\n"
" Emit YYDEBUG invocations in the generated code. This is useful to trace\n"
" lexer execution.\n"
"\n"
" --dump-adfa\n"
"\n"
" Debug option: output DFA after tunneling (in .dot format).\n"
"\n"
" --dump-cfg\n"
"\n"
" Debug option: output control flow graph of tag variables (in .dot\n"
" format).\n"
"\n"
" --dump-closure-stats\n"
"\n"
" Debug option: output statistics on the number of states in closure.\n"
"\n"
" --dump-dfa-det\n"
"\n"
" Debug option: output DFA immediately after determinization (in .dot\n"
" format).\n"
"\n"
" --dump-dfa-min\n"
"\n"
" Debug option: output DFA after minimization (in .dot format).\n"
"\n"
" --dump-dfa-tagopt\n"
"\n"
" Debug option: output DFA after tag optimizations (in .dot format).\n"
"\n"
" --dump-dfa-tree\n"
"\n"
" Debug option: output DFA under construction with states represented as\n"
" tag history trees (in .dot format).\n"
"\n"
" --dump-dfa-raw\n"
"\n"
" Debug option: output DFA under construction with expanded state-sets\n"
" (in .dot format).\n"
"\n"
" --dump-interf\n"
"\n"
" Debug option: output interference table produced by liveness analysis\n"
" of tag variables.\n"
"\n"
" --dump-nfa\n"
"\n"
" Debug option: output NFA (in .dot format).\n"
"\n"
" --emit-dot -D\n"
"\n"
" Instead of normal output generate lexer graph in .dot format. The\n"
" output can be converted to an image with the help of Graphviz (e.g.\n"
" something like dot -Tpng -odfa.png dfa.dot).\n"
"\n"
" --dfa-minimization <moore | table>\n"
"\n"
" Internal option: DFA minimization algorithm used by re2zig. The moore\n"
" option is the Moore algorithm (it is the default). The table option is\n"
" the \"table filling\" algorithm. Both algorithms should produce the same\n"
" DFA up to states relabeling; table filling is simpler and much slower\n"
" and serves as a reference implementation.\n"
"\n"
" --eager-skip\n"
"\n"
" Internal option: make the generated lexer advance the input position\n"
" eagerly -- immediately after reading the input symbol. This changes the\n"
" default behavior when the input position is advanced lazily -- after\n"
" transition to the next state.\n"
"\n"
" --no-lookahead\n"
"\n"
" Internal option, deprecated. It used to enable TDFA(0) algorithm.\n"
" Unlike TDFA(1), TDFA(0) algorithm does not use one-symbol lookahead. It\n"
" applies register operations to the incoming transitions rather than the\n"
" outgoing ones. Benchmarks showed that TDFA(0) algorithm is less\n"
" efficient than TDFA(1).\n"
"\n"
" --no-optimize-tags\n"
"\n"
" Internal option: suppress optimization of tag variables (useful for\n"
" debugging).\n"
"\n"
" --posix-closure <gor1 | gtop>\n"
"\n"
" Internal option: specify shortest-path algorithm used for the\n"
" construction of epsilon-closure with POSIX disambiguation semantics:\n"
" gor1 (the default) stands for Goldberg-Radzik algorithm, and gtop\n"
" stands for \"global topological order\" algorithm.\n"
"\n"
" --posix-prectable <complex | naive>\n"
"\n"
" Internal option: specify the algorithm used to compute POSIX precedence\n"
" table. The complex algorithm computes precedence table in one traversal\n"
" of tag history tree and has quadratic complexity in the number of TNFA\n"
" states; it is the default. The naive algorithm has worst-case cubic\n"
" complexity in the number of TNFA states, but it is much simpler than\n"
" complex and may be slightly faster in non-pathological cases.\n"
"\n"
" --stadfa\n"
"\n"
" Internal option, deprecated. It used to enable staDFA algorithm, which\n"
" differs from TDFA in that register operations are placed in states\n"
" rather than on transitions. Benchmarks showed that staDFA algorithm is\n"
" less efficient than TDFA.\n"
"\n"
" --fixed-tags <none | toplevel | all>\n"
"\n"
" Internal option: specify whether the fixed-tag optimization should be\n"
" applied to all tags (all), none of them (none), or only those in\n"
" toplevel concatenation (toplevel). The default is all. \"Fixed\" tags are\n"
" those that are located within a fixed distance to some other tag\n"
" (called \"base\"). In such cases only the base tag needs to be tracked,\n"
" and the value of the fixed tag can be computed as the value of the base\n"
" tag plus a static offset. For tags that are under alternative or\n"
" repetition it is also necessary to check if the base tag has a no-match\n"
" value (in that case fixed tag should also be set to no-match,\n"
" disregarding the offset). For tags in top-level concatenation the check\n"
" is not needed, because they always match.\n"
"\n"
"WARNINGS\n"
"\n"
" -W\n"
"\n"
" Turn on all warnings.\n"
"\n"
" -Werror\n"
"\n"
" Turn warnings into errors. Note that this option alone doesn't turn on\n"
" any warnings; it only affects those warnings that have been turned on\n"
" so far or will be turned on later.\n"
"\n"
" -W<warning>\n"
"\n"
" Turn on warning.\n"
"\n"
" -Wno-<warning>\n"
"\n"
" Turn off warning.\n"
"\n"
" -Werror-<warning>\n"
"\n"
" Turn on warning and treat it as an error (this implies -W<warning>).\n"
"\n"
" -Wno-error-<warning>\n"
"\n"
" Don't treat this particular warning as an error. This doesn't turn off\n"
" the warning itself.\n"
"\n"
" -Wcondition-order\n"
"\n"
" Warn if the generated program makes implicit assumptions about\n"
" condition numbering. One should use either --header option or\n"
" conditions block to generate a mapping of condition names to numbers\n"
" and then use the autogenerated condition names.\n"
"\n"
" -Wempty-character-class\n"
"\n"
" Warn if a regular expression contains an empty character class. Trying\n"
" to match an empty character class makes no sense: it should always\n"
" fail. However, for backwards compatibility reasons re2zig permits empty\n"
" character classes and treats them as empty strings. Use the --empty-\n"
" class option to change the default behavior.\n"
"\n"
" -Wmatch-empty-string\n"
"\n"
" Warn if a rule is nullable (matches an empty string). If the lexer runs\n"
" in a loop and the empty match is unintentional, the lexer may\n"
" unexpectedly hang in an infinite loop.\n"
"\n"
" -Wswapped-range\n"
"\n"
" Warn if the lower bound of a range is greater than its upper bound. The\n"
" default behavior is to silently swap the range bounds.\n"
"\n"
" -Wundefined-control-flow\n"
"\n"
" Warn if some input strings cause undefined control flow in the lexer\n"
" (the faulty patterns are reported). This is a dangerous and common\n"
" mistake. It can be easily fixed by adding the default rule * which has\n"
" the lowest priority, matches any code unit, and always consumes a\n"
" single code unit.\n"
"\n"
" -Wunreachable-rules\n"
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2zig\n"
" silently ignores such escapes, but this may as well indicate a typo or\n"
" an error in the escape sequence.\n"
"\n"
" -Wnondeterministic-tags\n"
"\n"
" Warn if a tag has n-th degree of nondeterminism, where n is greater\n"
" than 1.\n"
"\n"
" -Wsentinel-in-midrule\n"
"\n"
" Warn if the sentinel symbol occurs in the middle of a rule --- this may\n"
" cause reads past the end of buffer, crashes or memory corruption in the\n"
" generated lexer. This warning is only applicable if the sentinel method\n"
" of checking for the end of input is used. It is set to an error if\n"
" re2c:sentinel configuration is used.\n"
"\n"
" -Wundefined-syntax-config\n"
"\n"
" Warn if the syntax file specified with --syntax option is missing\n"
" definitions of some configurations. This helps to maintain user-defined\n"
" syntax files: if a new release adds configurations, old syntax file\n"
" will raise a warning, and the user will be notified. If some\n"
" configurations are unused and do not need a definition, they should be\n"
" explicitly set to <undefined>.\n"
;
+61 -49
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 3.0 */
/* Generated by re2c 4.0 */
#line 1 "../src/msg/ver_to_vernum.re"
#include <stddef.h>
#include <stdint.h>
@@ -32,39 +32,39 @@ const char *yyt6;
#line 33 "src/msg/ver_to_vernum.cc"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
static const unsigned char yybm[256] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
yych = *YYCURSOR;
if (yych <= '/') goto yy1;
@@ -82,13 +82,19 @@ yy3:
yych = *(YYMARKER = ++YYCURSOR);
if (yych <= '.') {
if (yych <= 0x00) {
yyt3 = yyt4 = yyt5 = yyt6 = NULL;
yyt2 = YYCURSOR;
yyt3 = NULL;
yyt4 = NULL;
yyt5 = NULL;
yyt6 = NULL;
goto yy4;
}
if (yych <= '-') goto yy2;
yyt3 = yyt4 = yyt5 = yyt6 = NULL;
yyt2 = YYCURSOR;
yyt3 = NULL;
yyt4 = NULL;
yyt5 = NULL;
yyt6 = NULL;
goto yy5;
} else {
if (yych <= '/') goto yy2;
@@ -120,7 +126,7 @@ yy4:
return std::string(buffer, SIZE);
}
#line 124 "src/msg/ver_to_vernum.cc"
#line 130 "src/msg/ver_to_vernum.cc"
yy5:
yych = *++YYCURSOR;
if (yych <= 0x00) goto yy6;
@@ -136,13 +142,19 @@ yy6:
yy7:
yych = *++YYCURSOR;
if (yych <= 0x00) {
yyt3 = yyt4 = yyt5 = yyt6 = NULL;
yyt2 = YYCURSOR;
yyt3 = NULL;
yyt4 = NULL;
yyt5 = NULL;
yyt6 = NULL;
goto yy4;
}
if (yych == '.') {
yyt3 = yyt4 = yyt5 = yyt6 = NULL;
yyt2 = YYCURSOR;
yyt3 = NULL;
yyt4 = NULL;
yyt5 = NULL;
yyt6 = NULL;
goto yy5;
}
goto yy6;
@@ -150,13 +162,15 @@ yy8:
yych = *++YYCURSOR;
if (yych <= '.') {
if (yych <= 0x00) {
yyt5 = yyt6 = NULL;
yyt4 = YYCURSOR;
yyt5 = NULL;
yyt6 = NULL;
goto yy4;
}
if (yych <= '-') goto yy6;
yyt5 = yyt6 = NULL;
yyt4 = YYCURSOR;
yyt5 = NULL;
yyt6 = NULL;
goto yy11;
} else {
if (yych <= '/') goto yy6;
@@ -166,9 +180,7 @@ yy8:
yy9:
yych = *++YYCURSOR;
yy10:
if (yybm[0+yych] & 128) {
goto yy9;
}
if (yybm[0+yych] & 128) goto yy9;
if (yych <= 0x00) goto yy4;
goto yy6;
yy11:
@@ -183,13 +195,15 @@ yy11:
yy12:
yych = *++YYCURSOR;
if (yych <= 0x00) {
yyt5 = yyt6 = NULL;
yyt4 = YYCURSOR;
yyt5 = NULL;
yyt6 = NULL;
goto yy4;
}
if (yych == '.') {
yyt5 = yyt6 = NULL;
yyt4 = YYCURSOR;
yyt5 = NULL;
yyt6 = NULL;
goto yy11;
}
goto yy6;
@@ -209,9 +223,7 @@ yy13:
}
yy14:
yych = *++YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy9;
}
if (yybm[0+yych] & 128) goto yy9;
if (yych <= '/') goto yy6;
if (yych <= '9') goto yy16;
goto yy6;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+130
View File
@@ -0,0 +1,130 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_CONF_SRC_PARSE_CONF_PARSER_H_INCLUDED
# define YY_CONF_SRC_PARSE_CONF_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef CONF_DEBUG
# if defined YYDEBUG
#if YYDEBUG
# define CONF_DEBUG 1
# else
# define CONF_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define CONF_DEBUG 0
# endif /* ! defined YYDEBUG */
#endif /* ! defined CONF_DEBUG */
#if CONF_DEBUG
extern int conf_debug;
#endif
/* "%code requires" blocks. */
#line 1 "../src/parse/conf_parser.ypp"
#include "src/constants.h"
#include "src/options/opt.h"
extern const char* DEFAULT_SYNTAX_C;
extern const char* DEFAULT_SYNTAX_D;
extern const char* DEFAULT_SYNTAX_GO;
extern const char* DEFAULT_SYNTAX_HASKELL;
extern const char* DEFAULT_SYNTAX_JAVA;
extern const char* DEFAULT_SYNTAX_JS;
extern const char* DEFAULT_SYNTAX_OCAML;
extern const char* DEFAULT_SYNTAX_PYTHON;
extern const char* DEFAULT_SYNTAX_RUST;
extern const char* DEFAULT_SYNTAX_V;
extern const char* DEFAULT_SYNTAX_ZIG;
#line 76 "src/parse/conf_parser.h"
/* Token kinds. */
#ifndef CONF_TOKENTYPE
# define CONF_TOKENTYPE
enum conf_tokentype
{
CONF_EMPTY = -2,
CONF_EOF = 0, /* "end of file" */
CONF_error = 256, /* error */
CONF_UNDEF = 257, /* "invalid token" */
CONF_NUMBER = 258, /* CONF_NUMBER */
CONF_STRING = 259, /* CONF_STRING */
CONF_COND = 260, /* CONF_COND */
CONF_VAR = 261, /* CONF_VAR */
CONF_CODE = 262, /* CONF_CODE */
CONF_GOPT = 263, /* CONF_GOPT */
CONF_LOPT = 264, /* CONF_LOPT */
CONF_UD = 265 /* CONF_UD */
};
typedef enum conf_tokentype conf_token_kind_t;
#endif
/* Value type. */
#if ! defined CONF_STYPE && ! defined CONF_STYPE_IS_DECLARED
union CONF_STYPE
{
#line 48 "../src/parse/conf_parser.ypp"
const char* str;
int32_t num;
bool cond;
std::vector<std::string>* list;
re2c::StxVarId var;
re2c::StxCode* code;
re2c::StxCodes* codes;
const re2c::StxCodes** codeptr;
re2c::StxOpt* opt;
re2c::StxGOpt gopt;
re2c::StxLOpt lopt;
#line 117 "src/parse/conf_parser.h"
};
typedef union CONF_STYPE CONF_STYPE;
# define CONF_STYPE_IS_TRIVIAL 1
# define CONF_STYPE_IS_DECLARED 1
#endif
int conf_parse (re2c::Input& in, re2c::Opt& opts);
#endif /* !YY_CONF_SRC_PARSE_CONF_PARSER_H_INCLUDED */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,4 +1,4 @@
/* Generated by re2c 3.0 */
/* Generated by re2c 4.0 */
#ifndef _RE2C_PARSE_LEX_
#define _RE2C_PARSE_LEX_
@@ -9,11 +9,6 @@
namespace re2c {
#line 13 "src/parse/lex.h"
#define YYMAXFILL 18
#line 68 "../src/parse/lex.re"
struct LexerState {
enum class LexMode: uint32_t { NORMAL, FLEX_NAME };
@@ -21,15 +16,15 @@ struct LexerState {
size_t BSIZE;
uint8_t* bot, *lim, *cur, *mar, *ctx, *tok, *ptr, *pos, *eof;
#line 25 "src/parse/lex.h"
#line 20 "src/parse/lexer.h"
uint8_t* yyt1;uint8_t* yyt2;uint8_t* yyt3;
#line 76 "../src/parse/lex.re"
#line 78 "../src/parse/lexer.re"
inline LexerState()
: mode(LexMode::NORMAL),
BSIZE(8192),
bot(new uint8_t[BSIZE + YYMAXFILL]),
bot(new uint8_t[BSIZE + maxfill()]),
lim(bot + BSIZE),
cur(lim),
mar(lim),
@@ -39,17 +34,24 @@ uint8_t* yyt1;uint8_t* yyt2;uint8_t* yyt3;
pos(lim),
eof(nullptr)
#line 43 "src/parse/lex.h"
#line 38 "src/parse/lexer.h"
, yyt1(lim), yyt2(lim), yyt3(lim)
#line 90 "../src/parse/lex.re"
#line 92 "../src/parse/lexer.re"
{
memset(lim, 0, YYMAXFILL);
memset(lim, 0, maxfill());
}
inline ~LexerState() {
delete[] bot;
}
inline void reset_ptrs() {
// reset lexer back to its initial state
cur = mar = ctx = tok = ptr = pos = lim = bot + BSIZE;
memset(lim, 0, maxfill());
eof = nullptr;
}
inline void shift_ptrs(ptrdiff_t offs) {
lim += offs;
cur += offs;
@@ -59,12 +61,20 @@ uint8_t* yyt1;uint8_t* yyt2;uint8_t* yyt3;
ptr += offs;
pos += offs;
#line 63 "src/parse/lex.h"
#line 65 "src/parse/lexer.h"
if (yyt1) { yyt1 += offs; }if (yyt2) { yyt2 += offs; }if (yyt3) { yyt3 += offs; }
#line 106 "../src/parse/lex.re"
#line 115 "../src/parse/lexer.re"
}
static size_t maxfill() {
return std::max(maxfill_main(), maxfill_conf());
}
private:
static size_t maxfill_main();
static size_t maxfill_conf();
FORBID_COPY(LexerState);
};
+165 -157
View File
@@ -63,8 +63,14 @@
/* Pull parsers. */
#define YYPULL 1
/* Substitute the type names. */
#define YYSTYPE RE2C_STYPE
/* Substitute the variable and function names. */
#define yyparse re2c_parse
#define yylex re2c_lex
#define yyerror re2c_error
#define yydebug re2c_debug
#define yynerrs re2c_nerrs
/* First part of user prologue. */
#line 10 "../src/parse/parser.ypp"
@@ -87,7 +93,7 @@ extern "C" {
}
#line 91 "src/parse/parser.cc"
#line 97 "src/parse/parser.cc"
# ifndef YY_CAST
# ifdef __cplusplus
@@ -144,21 +150,22 @@ enum yysymbol_kind_t
YYSYMBOL_26_ = 26, /* '?' */
YYSYMBOL_27_ = 27, /* '(' */
YYSYMBOL_28_ = 28, /* ')' */
YYSYMBOL_YYACCEPT = 29, /* $accept */
YYSYMBOL_spec = 30, /* spec */
YYSYMBOL_def = 31, /* def */
YYSYMBOL_name = 32, /* name */
YYSYMBOL_enddef = 33, /* enddef */
YYSYMBOL_rule = 34, /* rule */
YYSYMBOL_ccode = 35, /* ccode */
YYSYMBOL_trailexpr = 36, /* trailexpr */
YYSYMBOL_expr = 37, /* expr */
YYSYMBOL_diff = 38, /* diff */
YYSYMBOL_term = 39, /* term */
YYSYMBOL_factor = 40, /* factor */
YYSYMBOL_closes = 41, /* closes */
YYSYMBOL_close = 42, /* close */
YYSYMBOL_primary = 43 /* primary */
YYSYMBOL_29_ = 29, /* '!' */
YYSYMBOL_YYACCEPT = 30, /* $accept */
YYSYMBOL_spec = 31, /* spec */
YYSYMBOL_def = 32, /* def */
YYSYMBOL_name = 33, /* name */
YYSYMBOL_enddef = 34, /* enddef */
YYSYMBOL_rule = 35, /* rule */
YYSYMBOL_ccode = 36, /* ccode */
YYSYMBOL_trailexpr = 37, /* trailexpr */
YYSYMBOL_expr = 38, /* expr */
YYSYMBOL_diff = 39, /* diff */
YYSYMBOL_term = 40, /* term */
YYSYMBOL_factor = 41, /* factor */
YYSYMBOL_closes = 42, /* closes */
YYSYMBOL_close = 43, /* close */
YYSYMBOL_primary = 44 /* primary */
};
typedef enum yysymbol_kind_t yysymbol_kind_t;
@@ -425,7 +432,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|| (defined RE2C_STYPE_IS_TRIVIAL && RE2C_STYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -486,10 +493,10 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 2
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 64
#define YYLAST 67
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 29
#define YYNTOKENS 30
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 15
/* YYNRULES -- Number of rules. */
@@ -515,7 +522,7 @@ static const yytype_int8 yytranslate[] =
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 22, 2, 2, 2,
2, 2, 2, 29, 2, 2, 22, 2, 2, 2,
27, 28, 21, 25, 2, 2, 2, 18, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 20,
2, 19, 2, 26, 2, 2, 2, 2, 2, 2,
@@ -542,22 +549,22 @@ static const yytype_int8 yytranslate[] =
15, 16, 17
};
#if YYDEBUG
#if RE2C_DEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
0, 76, 76, 77, 81, 85, 86, 87, 91, 94,
100, 101, 104, 104, 107, 110, 113, 116, 122, 128,
134, 140, 147, 148, 153, 158, 159, 164, 165, 169,
170, 174, 176, 180, 181, 194, 200, 201, 205, 206,
207, 211, 212, 221, 222
0, 77, 77, 78, 82, 86, 87, 88, 92, 95,
101, 102, 105, 105, 108, 111, 114, 117, 123, 129,
135, 141, 148, 149, 154, 159, 160, 166, 167, 171,
172, 176, 178, 182, 183, 196, 202, 203, 207, 208,
209, 213, 214, 223, 224
};
#endif
/** Accessing symbol of state STATE. */
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
#if YYDEBUG || 0
#if RE2C_DEBUG || 0
/* The user-facing name of the symbol whose (internal) number is
YYSYMBOL. No bounds checking. */
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
@@ -571,8 +578,8 @@ static const char *const yytname[] =
"TOKEN_CLOSESIZE", "TOKEN_CODE", "TOKEN_CONF", "TOKEN_ID", "TOKEN_FID",
"TOKEN_FID_END", "TOKEN_LINE_INFO", "TOKEN_REGEXP", "TOKEN_BLOCK",
"TOKEN_ERROR", "'/'", "'='", "';'", "'*'", "'$'", "'|'", "'\\\\'", "'+'",
"'?'", "'('", "')'", "$accept", "spec", "def", "name", "enddef", "rule",
"ccode", "trailexpr", "expr", "diff", "term", "factor", "closes",
"'?'", "'('", "')'", "'!'", "$accept", "spec", "def", "name", "enddef",
"rule", "ccode", "trailexpr", "expr", "diff", "term", "factor", "closes",
"close", "primary", YY_NULLPTR
};
@@ -597,13 +604,13 @@ yysymbol_name (yysymbol_kind_t yysymbol)
STATE-NUM. */
static const yytype_int8 yypact[] =
{
-20, 0, -20, 14, -1, 36, -20, -18, -20, -20,
-20, -20, 11, 45, 22, -20, 23, -20, 52, 24,
-15, -20, 23, 5, -20, 36, 36, 36, -20, -20,
53, -20, -20, -20, -20, -20, 23, 29, 33, -20,
23, 23, 23, -20, -20, -20, -20, -20, 34, -20,
-20, -20, -20, -20, 35, -20, -20, -20, -20, -20,
9, -15, -20, -20, -20
-20, 0, -20, 19, -8, 46, -20, -11, -20, -20,
-20, -20, 9, 17, 2, -20, 24, -20, 33, 35,
-15, -20, 24, 11, -20, 46, 46, 46, -20, -20,
38, -20, -20, -20, -20, -20, 24, -3, 25, -20,
24, 24, 24, -20, -20, -20, -20, -20, 31, -20,
-20, -20, -20, -20, 36, -20, -20, -20, -20, -20,
10, -15, -20, -20, -20
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -623,8 +630,8 @@ static const yytype_int8 yydefact[] =
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-20, -20, -20, -20, -20, -20, -8, 40, -12, 3,
-19, -20, -20, 16, -20
-20, -20, -20, -20, -20, -20, 40, 41, -12, 13,
-19, -20, -20, 12, -20
};
/* YYDEFGOTO[NTERM-NUM]. */
@@ -639,47 +646,47 @@ static const yytype_int8 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int8 yytable[] =
{
2, 33, 37, 43, 38, 3, 4, 5, 28, 42,
6, 7, 8, 44, 9, 10, 11, 50, 51, 52,
34, 12, 13, 62, 54, 24, 45, 14, 60, 10,
46, 47, 41, 24, 24, 25, 26, 10, 10, 29,
30, 14, 40, 27, 61, 31, 56, 41, 36, 14,
14, 57, 41, 58, 35, 45, 41, 55, 41, 46,
47, 39, 53, 64, 63
2, 28, 37, 43, 38, 3, 4, 5, 33, 42,
6, 7, 8, 24, 9, 10, 11, 10, 34, 44,
41, 12, 13, 62, 54, 55, 35, 14, 60, 14,
24, 36, 45, 41, 10, 24, 46, 47, 56, 10,
25, 26, 39, 57, 27, 58, 14, 53, 41, 29,
30, 14, 45, 40, 61, 31, 46, 47, 41, 41,
63, 0, 0, 0, 64, 50, 51, 52
};
static const yytype_int8 yycheck[] =
{
0, 19, 14, 22, 16, 5, 6, 7, 9, 24,
10, 11, 12, 8, 14, 15, 16, 25, 26, 27,
9, 21, 22, 42, 36, 11, 21, 27, 40, 15,
25, 26, 23, 11, 11, 21, 22, 15, 15, 3,
4, 27, 18, 3, 41, 9, 13, 23, 26, 27,
27, 18, 23, 20, 9, 21, 23, 28, 23, 25,
26, 9, 9, 28, 48
0, 9, 14, 22, 16, 5, 6, 7, 19, 24,
10, 11, 12, 11, 14, 15, 16, 15, 9, 8,
23, 21, 22, 42, 36, 28, 9, 27, 40, 27,
11, 29, 21, 23, 15, 11, 25, 26, 13, 15,
21, 22, 9, 18, 3, 20, 27, 9, 23, 3,
4, 27, 21, 18, 41, 9, 25, 26, 23, 23,
48, -1, -1, -1, 28, 25, 26, 27
};
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
state STATE-NUM. */
static const yytype_int8 yystos[] =
{
0, 30, 0, 5, 6, 7, 10, 11, 12, 14,
15, 16, 21, 22, 27, 31, 32, 34, 36, 37,
38, 39, 40, 43, 11, 21, 22, 36, 9, 3,
4, 9, 35, 19, 9, 9, 26, 37, 37, 9,
18, 23, 24, 39, 8, 21, 25, 26, 41, 42,
35, 35, 35, 9, 37, 28, 13, 18, 20, 33,
37, 38, 39, 42, 28
0, 31, 0, 5, 6, 7, 10, 11, 12, 14,
15, 16, 21, 22, 27, 32, 33, 35, 37, 38,
39, 40, 41, 44, 11, 21, 22, 37, 9, 3,
4, 9, 36, 19, 9, 9, 29, 38, 38, 9,
18, 23, 24, 40, 8, 21, 25, 26, 42, 43,
36, 36, 36, 9, 38, 28, 13, 18, 20, 34,
38, 39, 40, 43, 28
};
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
static const yytype_int8 yyr1[] =
{
0, 29, 30, 30, 30, 30, 30, 30, 31, 31,
32, 32, 33, 33, 34, 34, 34, 34, 34, 34,
34, 34, 35, 35, 35, 36, 36, 37, 37, 38,
38, 39, 39, 40, 40, 40, 41, 41, 42, 42,
42, 43, 43, 43, 43
0, 30, 31, 31, 31, 31, 31, 31, 32, 32,
33, 33, 34, 34, 35, 35, 35, 35, 35, 35,
35, 35, 36, 36, 36, 37, 37, 38, 38, 39,
39, 40, 40, 41, 41, 41, 42, 42, 43, 43,
43, 44, 44, 44, 44
};
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
@@ -696,7 +703,7 @@ static const yytype_int8 yyr2[] =
enum { YYENOMEM = -2 };
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define yyclearin (yychar = RE2C_EMPTY)
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
@@ -708,7 +715,7 @@ enum { YYENOMEM = -2 };
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
if (yychar == RE2C_EMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
@@ -724,12 +731,12 @@ enum { YYENOMEM = -2 };
while (0)
/* Backward compatibility with an undocumented macro.
Use YYerror or YYUNDEF. */
#define YYERRCODE YYUNDEF
Use RE2C_error or RE2C_UNDEF. */
#define YYERRCODE RE2C_UNDEF
/* Enable debugging if requested. */
#if YYDEBUG
#if RE2C_DEBUG
# ifndef YYFPRINTF
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
@@ -851,12 +858,12 @@ do { \
/* Nonzero means print parse trace. It is left uninitialized so that
multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
#else /* !RE2C_DEBUG */
# define YYDPRINTF(Args) ((void) 0)
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
#endif /* !RE2C_DEBUG */
/* YYINITDEPTH -- initial size of the parser's stacks. */
@@ -966,7 +973,7 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
YYDPRINTF ((stderr, "Starting parse\n"));
yychar = YYEMPTY; /* Cause a token to be read. */
yychar = RE2C_EMPTY; /* Cause a token to be read. */
goto yysetstate;
@@ -1076,25 +1083,25 @@ yybackup:
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
if (yychar == YYEMPTY)
if (yychar == RE2C_EMPTY)
{
YYDPRINTF ((stderr, "Reading a token\n"));
yychar = yylex (&yylval, input, ast, opts, grams);
}
if (yychar <= YYEOF)
if (yychar <= RE2C_EOF)
{
yychar = YYEOF;
yychar = RE2C_EOF;
yytoken = YYSYMBOL_YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else if (yychar == YYerror)
else if (yychar == RE2C_error)
{
/* The scanner already issued an error message, process directly
to error recovery. But do not keep the error token as
lookahead, it is too special and may lead us to an endless
loop in error recovery. */
yychar = YYUNDEF;
yychar = RE2C_UNDEF;
yytoken = YYSYMBOL_YYerror;
goto yyerrlab1;
}
@@ -1131,7 +1138,7 @@ yybackup:
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Discard the shifted token. */
yychar = YYEMPTY;
yychar = RE2C_EMPTY;
goto yynewstate;
@@ -1167,176 +1174,177 @@ yyreduce:
switch (yyn)
{
case 3: /* spec: spec TOKEN_BLOCK */
#line 77 "../src/parse/parser.ypp"
#line 78 "../src/parse/parser.ypp"
{
if (use_block(input, ast, opts, grams, ast.temp_blockname) != Ret::OK) YYABORT;
ast.temp_blockname.clear();
}
#line 1176 "src/parse/parser.cc"
#line 1183 "src/parse/parser.cc"
break;
case 4: /* spec: spec TOKEN_CONF */
#line 81 "../src/parse/parser.ypp"
#line 82 "../src/parse/parser.ypp"
{
// Handled here, as the main lexer should not get access to opts under construction.
if (input.lex_conf(opts) != Ret::OK) YYABORT;
}
#line 1185 "src/parse/parser.cc"
#line 1192 "src/parse/parser.cc"
break;
case 8: /* def: name expr enddef */
#line 91 "../src/parse/parser.ypp"
#line 92 "../src/parse/parser.ypp"
{
if (add_named_def(opts.symtab, (yyvsp[-2].cstr), (yyvsp[-1].regexp), input) != Ret::OK) YYABORT;
}
#line 1193 "src/parse/parser.cc"
#line 1200 "src/parse/parser.cc"
break;
case 9: /* def: name expr '/' */
#line 94 "../src/parse/parser.ypp"
#line 95 "../src/parse/parser.ypp"
{
input.error_at_tok("trailing contexts are not allowed in named definitions");
YYABORT;
}
#line 1202 "src/parse/parser.cc"
#line 1209 "src/parse/parser.cc"
break;
case 10: /* name: TOKEN_ID '=' */
#line 100 "../src/parse/parser.ypp"
#line 101 "../src/parse/parser.ypp"
{ (yyval.cstr) = (yyvsp[-1].cstr); }
#line 1208 "src/parse/parser.cc"
#line 1215 "src/parse/parser.cc"
break;
case 14: /* rule: trailexpr TOKEN_CODE */
#line 107 "../src/parse/parser.ypp"
#line 108 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").rules.push_back(AstRule((yyvsp[-1].regexp), (yyvsp[0].semact)));
}
#line 1216 "src/parse/parser.cc"
#line 1223 "src/parse/parser.cc"
break;
case 15: /* rule: '*' TOKEN_CODE */
#line 110 "../src/parse/parser.ypp"
#line 111 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").defs.push_back((yyvsp[0].semact));
}
#line 1224 "src/parse/parser.cc"
#line 1231 "src/parse/parser.cc"
break;
case 16: /* rule: '$' TOKEN_CODE */
#line 113 "../src/parse/parser.ypp"
#line 114 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").eofs.push_back((yyvsp[0].semact));
}
#line 1232 "src/parse/parser.cc"
#line 1239 "src/parse/parser.cc"
break;
case 17: /* rule: TOKEN_CLIST trailexpr ccode */
#line 116 "../src/parse/parser.ypp"
#line 117 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).rules.push_back(AstRule((yyvsp[-1].regexp), (yyvsp[0].semact)));
}
ast.temp_condlist.clear();
}
#line 1243 "src/parse/parser.cc"
#line 1250 "src/parse/parser.cc"
break;
case 18: /* rule: TOKEN_CLIST '*' ccode */
#line 122 "../src/parse/parser.ypp"
#line 123 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).defs.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1254 "src/parse/parser.cc"
#line 1261 "src/parse/parser.cc"
break;
case 19: /* rule: TOKEN_CLIST '$' ccode */
#line 128 "../src/parse/parser.ypp"
#line 129 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).eofs.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1265 "src/parse/parser.cc"
#line 1272 "src/parse/parser.cc"
break;
case 20: /* rule: TOKEN_CSETUP TOKEN_CODE */
#line 134 "../src/parse/parser.ypp"
#line 135 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).setup.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1276 "src/parse/parser.cc"
#line 1283 "src/parse/parser.cc"
break;
case 21: /* rule: TOKEN_CZERO ccode */
#line 140 "../src/parse/parser.ypp"
#line 141 "../src/parse/parser.ypp"
{
const AstNode* r = ast.nil(input.tok_loc());
find_or_add_gram(grams, "0").rules.push_back(AstRule(r, (yyvsp[0].semact)));
ast.temp_condlist.clear();
}
#line 1286 "src/parse/parser.cc"
#line 1293 "src/parse/parser.cc"
break;
case 23: /* ccode: TOKEN_CNEXT TOKEN_CODE */
#line 148 "../src/parse/parser.ypp"
#line 149 "../src/parse/parser.ypp"
{
(yyval.semact) = (yyvsp[0].semact);
// parser needs to to update condition, but for the rest of the code actions are immutable
const_cast<SemAct*>((yyval.semact))->cond = (yyvsp[-1].cstr);
}
#line 1296 "src/parse/parser.cc"
#line 1303 "src/parse/parser.cc"
break;
case 24: /* ccode: TOKEN_CJUMP */
#line 153 "../src/parse/parser.ypp"
#line 154 "../src/parse/parser.ypp"
{
(yyval.semact) = ast.sem_act(input.tok_loc(), nullptr, (yyvsp[0].cstr), true);
}
#line 1304 "src/parse/parser.cc"
#line 1311 "src/parse/parser.cc"
break;
case 25: /* trailexpr: expr */
#line 158 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[0].regexp)); }
#line 1310 "src/parse/parser.cc"
#line 159 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[0].regexp), CAPTURE_IF_NOT_INVERTED); }
#line 1317 "src/parse/parser.cc"
break;
case 26: /* trailexpr: expr '/' expr */
#line 159 "../src/parse/parser.ypp"
#line 160 "../src/parse/parser.ypp"
{
(yyval.regexp) = ast.cat(ast.cap((yyvsp[-2].regexp)), ast.cat(ast.tag(input.tok_loc(), nullptr, false), (yyvsp[0].regexp)));
(yyval.regexp) = ast.cat(ast.cap((yyvsp[-2].regexp), CAPTURE_IF_NOT_INVERTED),
ast.cat(ast.tag(input.tok_loc(), nullptr, false), (yyvsp[0].regexp)));
}
#line 1318 "src/parse/parser.cc"
#line 1326 "src/parse/parser.cc"
break;
case 28: /* expr: expr '|' diff */
#line 165 "../src/parse/parser.ypp"
#line 167 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.alt((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
#line 1324 "src/parse/parser.cc"
#line 1332 "src/parse/parser.cc"
break;
case 30: /* diff: diff '\\' term */
#line 170 "../src/parse/parser.ypp"
#line 172 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.diff((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
#line 1330 "src/parse/parser.cc"
#line 1338 "src/parse/parser.cc"
break;
case 32: /* term: factor term */
#line 176 "../src/parse/parser.ypp"
#line 178 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cat((yyvsp[-1].regexp), (yyvsp[0].regexp)); }
#line 1336 "src/parse/parser.cc"
#line 1344 "src/parse/parser.cc"
break;
case 34: /* factor: primary closes */
#line 181 "../src/parse/parser.ypp"
#line 183 "../src/parse/parser.ypp"
{
switch((yyvsp[0].op)) {
case '*':
@@ -1350,69 +1358,69 @@ yyreduce:
break;
}
}
#line 1354 "src/parse/parser.cc"
break;
case 35: /* factor: primary TOKEN_CLOSESIZE */
#line 194 "../src/parse/parser.ypp"
{
(yyval.regexp) = ast.iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max);
}
#line 1362 "src/parse/parser.cc"
break;
case 35: /* factor: primary TOKEN_CLOSESIZE */
#line 196 "../src/parse/parser.ypp"
{
(yyval.regexp) = ast.iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max);
}
#line 1370 "src/parse/parser.cc"
break;
case 37: /* closes: closes close */
#line 201 "../src/parse/parser.ypp"
#line 203 "../src/parse/parser.ypp"
{ (yyval.op) = ((yyvsp[-1].op) == (yyvsp[0].op)) ? (yyvsp[-1].op) : '*'; }
#line 1368 "src/parse/parser.cc"
#line 1376 "src/parse/parser.cc"
break;
case 38: /* close: '*' */
#line 205 "../src/parse/parser.ypp"
#line 207 "../src/parse/parser.ypp"
{ (yyval.op) = '*'; }
#line 1374 "src/parse/parser.cc"
#line 1382 "src/parse/parser.cc"
break;
case 39: /* close: '+' */
#line 206 "../src/parse/parser.ypp"
#line 208 "../src/parse/parser.ypp"
{ (yyval.op) = '+'; }
#line 1380 "src/parse/parser.cc"
#line 1388 "src/parse/parser.cc"
break;
case 40: /* close: '?' */
#line 207 "../src/parse/parser.ypp"
#line 209 "../src/parse/parser.ypp"
{ (yyval.op) = '?'; }
#line 1386 "src/parse/parser.cc"
#line 1394 "src/parse/parser.cc"
break;
case 42: /* primary: TOKEN_ID */
#line 212 "../src/parse/parser.ypp"
#line 214 "../src/parse/parser.ypp"
{
(yyval.regexp) = find_def(opts.symtab, (yyvsp[0].cstr));
if ((yyval.regexp) == nullptr) {
input.error_at_tok("undefined symbol '%s'", (yyvsp[0].cstr));
YYABORT;
} else if (Ast::needs_wrap((yyval.regexp))) {
(yyval.regexp) = ast.ref((yyval.regexp));
(yyval.regexp) = ast.cap((yyval.regexp), NO_CAPTURE);
}
}
#line 1400 "src/parse/parser.cc"
#line 1408 "src/parse/parser.cc"
break;
case 43: /* primary: '(' expr ')' */
#line 221 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp)); }
#line 1406 "src/parse/parser.cc"
#line 223 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), CAPTURE_IF_NOT_INVERTED); }
#line 1414 "src/parse/parser.cc"
break;
case 44: /* primary: '(' '?' expr ')' */
#line 222 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.ref((yyvsp[-1].regexp)); }
#line 1412 "src/parse/parser.cc"
case 44: /* primary: '(' '!' expr ')' */
#line 224 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), CAPTURE_IF_INVERTED); }
#line 1420 "src/parse/parser.cc"
break;
#line 1416 "src/parse/parser.cc"
#line 1424 "src/parse/parser.cc"
default: break;
}
@@ -1454,7 +1462,7 @@ yyreduce:
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
yytoken = yychar == RE2C_EMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
@@ -1467,17 +1475,17 @@ yyerrlab:
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
if (yychar <= RE2C_EOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
if (yychar == RE2C_EOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, input, ast, opts, grams);
yychar = YYEMPTY;
yychar = RE2C_EMPTY;
}
}
@@ -1579,7 +1587,7 @@ yyexhaustedlab:
| yyreturnlab -- parsing is finished, clean up and return. |
`----------------------------------------------------------*/
yyreturnlab:
if (yychar != YYEMPTY)
if (yychar != RE2C_EMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
@@ -1605,14 +1613,14 @@ yyreturnlab:
return yyresult;
}
#line 225 "../src/parse/parser.ypp"
#line 227 "../src/parse/parser.ypp"
#pragma GCC diagnostic pop
extern "C" {
static void yyerror(Input& input, Ast&, Opt&, AstGrams&, const char* s) {
input.error_at_tok("%s", s);
input.error_at_cur("%s", s);
}
static int yylex(YYSTYPE* yylval, Input& input, Ast& ast, Opt&, AstGrams&) {
+33 -25
View File
@@ -35,14 +35,22 @@
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_SRC_PARSE_PARSER_H_INCLUDED
# define YY_YY_SRC_PARSE_PARSER_H_INCLUDED
#ifndef YY_RE2C_SRC_PARSE_PARSER_H_INCLUDED
# define YY_RE2C_SRC_PARSE_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#ifndef RE2C_DEBUG
# if defined YYDEBUG
#if YYDEBUG
extern int yydebug;
# define RE2C_DEBUG 1
# else
# define RE2C_DEBUG 0
# endif
# else /* ! defined YYDEBUG */
# define RE2C_DEBUG 0
# endif /* ! defined YYDEBUG */
#endif /* ! defined RE2C_DEBUG */
#if RE2C_DEBUG
extern int re2c_debug;
#endif
/* "%code requires" blocks. */
#line 1 "../src/parse/parser.ypp"
@@ -52,19 +60,19 @@ extern int yydebug;
namespace re2c {
struct AstNode;
struct SemAct;
};
}
#line 58 "src/parse/parser.h"
#line 66 "src/parse/parser.h"
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
#ifndef RE2C_TOKENTYPE
# define RE2C_TOKENTYPE
enum re2c_tokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
RE2C_EMPTY = -2,
RE2C_EOF = 0, /* "end of file" */
RE2C_error = 256, /* error */
RE2C_UNDEF = 257, /* "invalid token" */
TOKEN_CJUMP = 258, /* TOKEN_CJUMP */
TOKEN_CNEXT = 259, /* TOKEN_CNEXT */
TOKEN_CLIST = 260, /* TOKEN_CLIST */
@@ -81,14 +89,14 @@ namespace re2c {
TOKEN_BLOCK = 271, /* TOKEN_BLOCK */
TOKEN_ERROR = 272 /* TOKEN_ERROR */
};
typedef enum yytokentype yytoken_kind_t;
typedef enum re2c_tokentype re2c_token_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
#if ! defined RE2C_STYPE && ! defined RE2C_STYPE_IS_DECLARED
union RE2C_STYPE
{
#line 42 "../src/parse/parser.ypp"
#line 43 "../src/parse/parser.ypp"
const re2c::AstNode* regexp;
const re2c::SemAct* semact;
@@ -97,18 +105,18 @@ union YYSTYPE
const char* cstr;
std::string* str;
#line 101 "src/parse/parser.h"
#line 109 "src/parse/parser.h"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
typedef union RE2C_STYPE RE2C_STYPE;
# define RE2C_STYPE_IS_TRIVIAL 1
# define RE2C_STYPE_IS_DECLARED 1
#endif
int yyparse (re2c::Input& input, re2c::Ast& ast, re2c::Opt& opts, re2c::AstGrams& grams);
int re2c_parse (re2c::Input& input, re2c::Ast& ast, re2c::Opt& opts, re2c::AstGrams& grams);
#endif /* !YY_YY_SRC_PARSE_PARSER_H_INCLUDED */
#endif /* !YY_RE2C_SRC_PARSE_PARSER_H_INCLUDED */
+2 -1
View File
@@ -12,5 +12,6 @@ cd $builddir
--enable-debug \
--enable-libs \
--host i686-w64-mingw32 \
&& make -j$(nproc)
&& make -j$(nproc) \
&& ../build/copy_wine_libs_on_nixos.sh
cd ..
+2 -1
View File
@@ -16,5 +16,6 @@ cd $builddir
--enable-debug \
--enable-libs \
--host i686-w64-mingw32 \
&& make -j$(nproc) LIBTOOL="slibtool"
&& make -j$(nproc) LIBTOOL="slibtool" \
&& ../build/copy_wine_libs_on_nixos.sh
cd ..
+2 -1
View File
@@ -12,5 +12,6 @@ cmake .. \
-DBUILD_SHARED_LIBS=no \
-DCMAKE_EXE_LINKER_FLAGS="-static -static-libstdc++ -static-libgcc" \
-DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-cross-mingw32-linux.cmake \
&& cmake --build . -j$(nproc)
&& cmake --build . -j$(nproc) \
&& ../build/copy_wine_libs_on_nixos.sh
cd ..
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
# On NixOS, Wine cannot find DLLs by their absolute paths in /nix/store,
# so find and copy them in the same directory with re2c.exe.
uname -a | grep -q NixOS || exit 0
test -e re2c.exe || \
{ echo "$0 must be ran from the build directory containing re2c.exe"; exit 1; }
nix_wine="$(nix-build --no-link '<nixpkgs>' -A wine)"
nix_mcfgthreads="$(nix-build --no-link '<nixpkgs>' -A pkgsCross.mingw32.windows.mcfgthreads)"
uname -a | grep -q NixOS && (
cp -f "$nix_mcfgthreads/bin/mcfgthread"*".dll" .
cp -f "$nix_wine/lib/wine/i386-windows/win32u.dll" .
cp -f "$nix_wine/lib/wine/i386-windows/user32.dll" .
cp -f "$nix_wine/lib/wine/i386-windows/gdi32.dll" .
)
+40 -8
View File
@@ -5,40 +5,72 @@ Generates language-specific manpages by replacing placeholder tokens in the
input manpage.
"""
import os
import re
import sys
if len(sys.argv) != 4:
print('usage:', sys.argv[0], '<input> <output> <lang>')
if len(sys.argv) != 3:
print('usage:', sys.argv[0], '<input> <output>')
exit(1)
input = sys.argv[1]
output = sys.argv[2]
lang = sys.argv[3].lower().encode('utf-8')
# Extract language name from the output filename.
lang = re.search('re2([a-z]+)', os.path.basename(output)).group(1).encode('utf-8')
prog = b're2' + lang
hdr_ext = None
disclaimer = b''
if lang == b'c':
src_ext = b'c'
hdr_ext = b'h'
lang_name = b'C'
lang_name = b'C/C++'
disclaimer = b'Note: examples are in C++ (but can be easily adapted to C).'
elif lang == b'd':
src_ext = b'd'
lang_name = b'D'
elif lang == b'go':
src_ext = b'go'
hdr_ext = b'go'
lang_name = b'Go'
disclaimer = b'Note: This manual is for Go, but it refers to re2c as the general program.'
elif lang == b'hs':
lang = b'haskell'
src_ext = b'hs'
lang_name = b'Haskell'
elif lang == b'java':
src_ext = b'java'
lang_name = b'Java'
elif lang == b'js':
src_ext = b'js'
lang_name = b'JavaScript'
elif lang == b'ocaml':
src_ext = b'ml'
lang_name = b'OCaml'
elif lang == b'py':
lang = b'python'
src_ext = b'py'
lang_name = b'Python'
elif lang == b'rust':
src_ext = b'rs'
hdr_ext = b'rs'
lang_name = b'Rust'
disclaimer = b'Note: This manual is for Rust, but it refers to re2c as the general program.'
elif lang == b'v':
src_ext = b'v'
lang_name = b'V'
elif lang == b'zig':
src_ext = b'zig'
lang_name = b'Zig'
else:
print('***', sys.argv[0], ': unknown lang:', lang)
exit(1)
if hdr_ext == None:
hdr_ext = src_ext
with open(input, 'rb') as input_file:
file_bytes = input_file.read()
file_bytes = file_bytes.replace(b'RE2C_LANG_NAME', lang_name)
file_bytes = file_bytes.replace(b'RE2C_LANG', lang)
file_bytes = file_bytes.replace(b'RE2C_PROG', prog)
file_bytes = file_bytes.replace(b'RE2C_SOURCE_EXT', src_ext)
file_bytes = file_bytes.replace(b'RE2C_HEADER_EXT', hdr_ext)
file_bytes = file_bytes.replace(b'RE2C_DISCLAIMER', disclaimer)
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env python3
"""
Encodes the contents of a syntax file as C++ source code.
"""
import os
import sys
if len(sys.argv) != 3:
print('usage:', sys.argv[0], '<input> <output>')
exit(1)
input = sys.argv[1]
output = sys.argv[2]
with open(output, 'w') as output_file:
name = os.path.splitext(os.path.basename(input))[0].upper()
output_file.write("#include \"src/parse/conf_parser.h\"\n")
output_file.write("const char* " + name + " =\n")
# write input file line by line as a string, escaping characters as needed
with open(input, 'r') as input_file:
for l in input_file:
l_out = l[:-1].translate(str.maketrans({
'\\': '\\\\',
'"': '\\"'
}))
output_file.write(' "' + l_out + '\\n"\n')
output_file.write(" ;\n")
+20
View File
@@ -0,0 +1,20 @@
function(re2c_bootstrap_syntax source target)
set(bootstrap "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/${target}")
if(RE2C_REBUILD_SYNTAX)
get_filename_component(targetdir "${target}" DIRECTORY)
add_custom_command(
OUTPUT "${target}"
COMMAND "${CMAKE_COMMAND}" -E make_directory ${targetdir}
COMMAND "${PYTHON}" "${re2c_stx2cpp}" "${CMAKE_CURRENT_SOURCE_DIR}/${source}" "${target}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${target}" "${bootstrap}"
DEPENDS "${source}" "${re2c_stx2cpp}"
)
else()
add_custom_command(
OUTPUT "${target}"
COMMAND "${CMAKE_COMMAND}" -E copy "${bootstrap}" "${target}"
DEPENDS "${bootstrap}"
COMMENT "Copying bootstrap syntax file, reconfigure with RE2C_REBUILD_PARSERS to regenerate"
)
endif()
endfunction()
+5
View File
@@ -53,6 +53,11 @@ if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# re2c uses C++11, not C++98
"-Wno-c++98-compat"
"-Wno-c++98-compat-pedantic"
"-Wno-unsafe-pointer-arithmetic"
"-Wno-unsafe-buffer-usage"
# re2c is single-threaded => no danger of race conditions
"-Wno-exit-time-destructors"
"-Wno-switch-enum"
)
try_cxxflag("-fdiagnostics-color=always")
+14 -27
View File
@@ -1,19 +1,21 @@
function(re2c_gen_manpage source target bootstrap lang)
function(re2c_gen_docs source target tool args)
file(RELATIVE_PATH relative_target "${CMAKE_CURRENT_BINARY_DIR}" "${target}")
set(bootstrap "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/${relative_target}")
if(RE2C_REBUILD_DOCS)
get_filename_component(targetdir "${target}" DIRECTORY)
set(source_l "${source}.${lang}")
set(split_source "${target}.rst")
add_custom_command(
OUTPUT "${target}"
COMMAND "${CMAKE_COMMAND}" -E make_directory ${targetdir}
COMMAND "${PYTHON}" "${re2c_splitman}" "${source}" "${source_l}" "${lang}"
COMMAND "${PYTHON}" "${re2c_rst2man}" --tab-width=4 "${source_l}" "${target}"
COMMAND "${PYTHON}" "${re2c_splitman}" "${source}" "${split_source}"
COMMAND "${PYTHON}" "${tool}" ${args} "${split_source}" "${target}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${target}" "${bootstrap}"
DEPENDS
"${source}"
"${tool}"
"${re2c_splitman}"
"${re2c_rst2man}"
"${re2c_docs_sources}"
BYPRODUCTS "${source_l}"
BYPRODUCTS "${split_source}"
)
else()
add_custom_command(
@@ -24,25 +26,10 @@ function(re2c_gen_manpage source target bootstrap lang)
endif()
endfunction()
function(re2c_gen_help source target bootstrap)
if(RE2C_REBUILD_DOCS)
get_filename_component(targetdir "${target}" DIRECTORY)
add_custom_command(
OUTPUT "${target}"
COMMAND "${CMAKE_COMMAND}" -E make_directory ${targetdir}
COMMAND "${PYTHON}" "${re2c_rst2txt}" --variable-name=help "${source}" "${target}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${target}" "${bootstrap}"
DEPENDS
"${source}"
"${re2c_rst2txt}"
"${re2c_docs_sources}"
BYPRODUCTS "${target}.1"
)
else()
add_custom_command(
OUTPUT "${target}"
COMMAND "${CMAKE_COMMAND}" -E copy "${bootstrap}" "${target}"
DEPENDS "${bootstrap}"
)
endif()
function(re2c_gen_manpage source target)
re2c_gen_docs("${source}" "${target}" "${re2c_rst2man}" "--tab-width=4")
endfunction()
function(re2c_gen_help source target)
re2c_gen_docs("${source}" "${target}" "${re2c_rst2txt}" "--variable-name=help")
endfunction()
+89 -11
View File
@@ -1,4 +1,4 @@
AC_INIT([re2c],[3.0],[re2c-general@lists.sourceforge.net])
AC_INIT([re2c],[4.0],[re2c-general@lists.sourceforge.net])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz dist-lzip no-dist-gzip])
AM_SILENT_RULES([yes])
@@ -15,7 +15,8 @@ AC_SUBST(PACKAGE_RELEASE, ${PACKAGE_RELEASE:-1})
AM_PATH_PYTHON([3.7])
# without this, --std=c++98 disables POSIX functions on Cygwin
# without this, --std=c++11 disables POSIX functions on Cygwin and NetBSD
# (alternatively we could use -std=gnu++11, as CMake does)
AC_USE_SYSTEM_EXTENSIONS
@@ -35,6 +36,11 @@ AM_COND_IF([REBUILD_DOCS], [
])
# --enable-syntax
AC_ARG_ENABLE([syntax], [AS_HELP_STRING([--enable-syntax], [regenerate syntax files])])
AM_CONDITIONAL([REBUILD_SYNTAX], [test "x$enable_syntax" = "xyes"])
# --enable-lexers
AC_ARG_ENABLE([lexers], [AS_HELP_STRING([--enable-lexers], [regenerate lexers])])
AM_CONDITIONAL([REBUILD_LEXERS], [test "x$enable_lexers" = "xyes"])
@@ -68,14 +74,36 @@ AM_COND_IF([WITH_LIBS], [
])
# --enable-dlang
AC_ARG_ENABLE([dlang], [AS_HELP_STRING([--enable-dlang], [build re2d executable])])
AM_CONDITIONAL([WITH_DLANG], [test "x$enable_dlang" != "xno"])
# --enable-golang
AC_ARG_ENABLE([golang], [AS_HELP_STRING([--enable-golang], [build re2go executable])])
AM_CONDITIONAL([WITH_GOLANG], [test "x$enable_golang" != "xno"])
# --enable-haskell
AC_ARG_ENABLE([haskell], [AS_HELP_STRING([--enable-haskell], [build re2hs executable])])
AM_CONDITIONAL([WITH_HASKELL], [test "x$enable_haskell" != "xno"])
# --enable-java
AC_ARG_ENABLE([java], [AS_HELP_STRING([--enable-java], [build re2java executable])])
AM_CONDITIONAL([WITH_JAVA], [test "x$enable_java" != "xno"])
# --enable-js
AC_ARG_ENABLE([js], [AS_HELP_STRING([--enable-js], [build re2js executable])])
AM_CONDITIONAL([WITH_JS], [test "x$enable_js" != "xno"])
# --enable-ocaml
AC_ARG_ENABLE([ocaml], [AS_HELP_STRING([--enable-ocaml], [build re2ocaml executable])])
AM_CONDITIONAL([WITH_OCAML], [test "x$enable_ocaml" != "xno"])
# --enable-python
AC_ARG_ENABLE([python], [AS_HELP_STRING([--enable-python], [build re2py executable])])
AM_CONDITIONAL([WITH_PYTHON], [test "x$enable_python" != "xno"])
# --enable-rust
AC_ARG_ENABLE([rust], [AS_HELP_STRING([--enable-rust], [build re2rust executable])])
AM_CONDITIONAL([WITH_RUST], [test "x$enable_rust" != "xno"])
# --enable-vlang
AC_ARG_ENABLE([vlang], [AS_HELP_STRING([--enable-vlang], [build re2v executable])])
AM_CONDITIONAL([WITH_VLANG], [test "x$enable_vlang" != "xno"])
# --enable-zig
AC_ARG_ENABLE([zig], [AS_HELP_STRING([--enable-zig], [build re2zig executable])])
AM_CONDITIONAL([WITH_ZIG], [test "x$enable_zig" != "xno"])
# --enable-benchmarks
@@ -123,13 +151,18 @@ AC_DEFUN([TRY_CXXFLAG], [
AS_VAR_SET([TRY_CXXFLAG_RESULT], [yes])
AS_VAR_SET([CXXFLAGSDEFAULT], ["$CXXFLAGSDEFAULT $1 $2"])
],
[AS_VAR_SET([TRY_CXXFLAG_RESULT], [no])]
[
AS_VAR_SET([TRY_CXXFLAG_RESULT], [no])
AS_IF([test "x$3" = "xrequired"], [
AC_MSG_ERROR([C++ compiler flag $1 is required to build re2c])
])
]
)
AC_LANG_POP([C++])
AS_VAR_SET([CXXFLAGS], ["$CXXFLAGS_BACKUP"])
AC_MSG_RESULT([$TRY_CXXFLAG_RESULT])
])
TRY_CXXFLAG([-std=c++11])
TRY_CXXFLAG([-std=c++11], [], [required])
TRY_CXXFLAG([-W])
TRY_CXXFLAG([-Wall])
TRY_CXXFLAG([-Wextra])
@@ -152,7 +185,11 @@ TRY_CXXFLAG([-Weverything], m4_join([ ],
[-Wno-shadow-field-in-constructor] dnl using same names in ctor seems more like a feature
[-Wno-undefined-func-template] dnl explicit specialization to reduce build dependencies
[-Wno-c++98-compat], dnl allow using C++11 features like `nullptr`
[-Wno-c++98-compat-pedantic]))
[-Wno-c++98-compat-pedantic],
[-Wno-unsafe-pointer-arithmetic],
[-Wno-unsafe-buffer-usage],
[-Wno-exit-time-destructors], dnl re2c is single-threaded => no danger of race conditions
[-Wno-switch-enum]))
# needed for POSIX file API
@@ -169,8 +206,6 @@ AC_CONFIG_FILES([
benchmarks/submatch_dfa_aot/Makefile
benchmarks/submatch_dfa_jit/Makefile
benchmarks/submatch_java/Makefile
doc/manpage.rst
doc/help.rst
])
AC_CONFIG_FILES([run_tests.py],
[chmod +x run_tests.py])
@@ -178,9 +213,52 @@ AC_CONFIG_FILES([benchmarks/submatch_dfa_aot/run.py],
[chmod +x benchmarks/submatch_dfa_aot/run.py])
AC_CONFIG_FILES([benchmarks/submatch_java/run.py],
[chmod +x benchmarks/submatch_java/run.py])
# Custom names are needed to accommodate POSIX Make suffix rules (bmake in
# particular) instead of the more generic and flexible GNU Make pattern rules.
# Copies are needed to patch them in-place with build/split_man.py.
AC_CONFIG_FILES([
src/msg/help_re2c.rst:doc/help.rst.in
src/msg/help_re2d.rst:doc/help.rst.in
src/msg/help_re2go.rst:doc/help.rst.in
src/msg/help_re2hs.rst:doc/help.rst.in
src/msg/help_re2java.rst:doc/help.rst.in
src/msg/help_re2js.rst:doc/help.rst.in
src/msg/help_re2ocaml.rst:doc/help.rst.in
src/msg/help_re2py.rst:doc/help.rst.in
src/msg/help_re2rust.rst:doc/help.rst.in
src/msg/help_re2v.rst:doc/help.rst.in
src/msg/help_re2zig.rst:doc/help.rst.in
AC_CONFIG_LINKS([benchmarks/submatch_java/chart.js:benchmarks/submatch_java/chart.js])
doc/re2c.rst:doc/manpage.rst.in
doc/re2d.rst:doc/manpage.rst.in
doc/re2go.rst:doc/manpage.rst.in
doc/re2hs.rst:doc/manpage.rst.in
doc/re2java.rst:doc/manpage.rst.in
doc/re2js.rst:doc/manpage.rst.in
doc/re2ocaml.rst:doc/manpage.rst.in
doc/re2py.rst:doc/manpage.rst.in
doc/re2rust.rst:doc/manpage.rst.in
doc/re2v.rst:doc/manpage.rst.in
doc/re2zig.rst:doc/manpage.rst.in
])
# Custom names are needed to accommodate POSIX Make suffix rules (bmake in
# particular) instead of the more generic and flexible GNU Make pattern rules.
AC_CONFIG_LINKS([
src/default_syntax_c.stx:include/syntax/c
src/default_syntax_d.stx:include/syntax/d
src/default_syntax_go.stx:include/syntax/go
src/default_syntax_haskell.stx:include/syntax/haskell
src/default_syntax_java.stx:include/syntax/java
src/default_syntax_js.stx:include/syntax/js
src/default_syntax_ocaml.stx:include/syntax/ocaml
src/default_syntax_python.stx:include/syntax/python
src/default_syntax_rust.stx:include/syntax/rust
src/default_syntax_v.stx:include/syntax/v
src/default_syntax_zig.stx:include/syntax/zig
])
AC_CONFIG_LINKS([
benchmarks/submatch_java/chart.js:benchmarks/submatch_java/chart.js
])
LT_INIT([dlopen win32-dll])
+1 -1
View File
@@ -6,5 +6,5 @@ the 'gh-pages-gen' branch; the files with '.rst_' extension (which constitute
the manpage) are pulled from the 'master' branch to 'gh-pages-gen' branch and
used together with other docs in the generation of https://re2c.org website.
Normally the general descriptio of each feature is in an '.rst_' file on
Normally the general description of each feature is in an '.rst_' file on
'master' branch, and examples are in '.rst' files on 'gh-pages-gen' branch.
+7 -5
View File
@@ -1,17 +1,19 @@
Usage
=====
.. |re2c| replace:: RE2C_PROG
.. include:: @top_srcdir@/doc/manual/synopsis.rst_
OPTIONS
=======
.. include:: @top_srcdir@/doc/manual/options/options.rst_
.. include:: @top_srcdir@/doc/manual/options/debug.rst_
.. include:: @top_srcdir@/doc/manual/options/internal.rst_
.. include:: @top_srcdir@/doc/manual/basics/options/options.rst_
.. include:: @top_srcdir@/doc/manual/basics/options/debug.rst_
.. include:: @top_srcdir@/doc/manual/basics/options/internal.rst_
WARNINGS
========
.. include:: @top_srcdir@/doc/manual/warnings/warnings_general.rst_
.. include:: @top_srcdir@/doc/manual/warnings/warnings_list.rst_
.. include:: @top_srcdir@/doc/manual/basics/warnings/warnings_general.rst_
.. include:: @top_srcdir@/doc/manual/basics/warnings/warnings_list.rst_
+80 -75
View File
@@ -1,13 +1,16 @@
++++
re2c
++++
+++++++++
RE2C_PROG
+++++++++
======================================================
generate fast lexical analyzers for C/C++, Go and Rust
======================================================
==================================================
generate fast lexical analyzers for RE2C_LANG_NAME
==================================================
:Manual section: 1
.. |re2c| replace:: RE2C_PROG
.. |lang_name| replace:: RE2C_LANG_NAME
SYNOPSIS
========
@@ -18,7 +21,7 @@ RE2C_DISCLAIMER
Introduction
============
.. include:: @top_srcdir@/doc/manual/syntax/intro.rst_
.. include:: @top_srcdir@/doc/manual/intro.rst_
Here is an example of a small program that checks if a given string contains a
decimal number:
@@ -27,60 +30,61 @@ decimal number:
:literal:
:code: RE2C_LANG
In the output everything between ``/*!re2c`` and ``*/`` has been replaced with
the generated code:
In the output |re2c| replaced the block in the middle with the generated code:
.. include:: @top_srcdir@/examples/RE2C_LANG/01_basic.RE2C_SOURCE_EXT
:literal:
:code: RE2C_LANG
Syntax
Basics
======
.. include:: @top_srcdir@/doc/manual/basics/syntax.rst_
.. include:: @top_srcdir@/doc/manual/syntax/syntax.rst_
Blocks
------
.. include:: @top_srcdir@/doc/manual/basics/blocks.rst_
Directives
----------
.. include:: @top_srcdir@/doc/manual/basics/directives.rst_
Regular expressions
-------------------
.. include:: @top_srcdir@/doc/manual/basics/regular_expressions.rst_
Configurations
--------------
.. include:: @top_srcdir@/doc/manual/basics/configurations.rst_
Program interface
=================
.. include:: @top_srcdir@/doc/manual/syntax/api1.rst_
.. include:: @top_srcdir@/doc/manual/syntax/api2_RE2C_LANG.rst_
.. include:: @top_srcdir@/doc/manual/syntax/api3.rst_
-----------------
.. include:: @top_srcdir@/doc/manual/basics/api/api1.rst_
.. include:: @top_srcdir@/doc/manual/basics/api/api2_RE2C_LANG.rst_
.. include:: @top_srcdir@/doc/manual/basics/api/api3.rst_
Options
=======
-------
Some of the options have corresponding `configurations`_,
others are global and cannot be changed after re2c starts reading the input file.
Debug options generally require building re2c in debug configuration.
Internal options are useful for experimenting with the algorithms used in re2c.
.. include:: @top_srcdir@/doc/manual/options/options.rst_
.. include:: @top_srcdir@/doc/manual/options/debug.rst_
.. include:: @top_srcdir@/doc/manual/options/internal.rst_
.. include:: @top_srcdir@/doc/manual/basics/options/options.rst_
.. include:: @top_srcdir@/doc/manual/basics/options/debug.rst_
.. include:: @top_srcdir@/doc/manual/basics/options/internal.rst_
Warnings
========
--------
Warnings can be invividually enabled, disabled and turned into an error.
.. include:: @top_srcdir@/doc/manual/warnings/warnings_general.rst_
.. include:: @top_srcdir@/doc/manual/warnings/warnings_list.rst_
.. include:: @top_srcdir@/doc/manual/basics/warnings/warnings_general.rst_
.. include:: @top_srcdir@/doc/manual/basics/warnings/warnings_list.rst_
Blocks and directives
=====================
.. include:: @top_srcdir@/doc/manual/directives/directives.rst_
API primitives
==============
.. include:: @top_srcdir@/doc/manual/api/interface.rst_
Configurations
==============
.. include:: @top_srcdir@/doc/manual/configurations/configurations.rst_
Regular expressions
===================
.. include:: @top_srcdir@/doc/manual/regexps/regular_expressions.rst_
Syntax files
------------
.. include:: @top_srcdir@/doc/manual/basics/syntax_files.rst_
Handling the end of input
=========================
@@ -97,8 +101,8 @@ Handling the end of input
.. include:: @top_srcdir@/examples/RE2C_LANG/eof/02_bounds_checking.re
:literal:
:code: RE2C_LANG
.. include:: @top_srcdir@/doc/manual/eof/04_generic_api.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/eof/05_generic_api_eof_rule.re
.. include:: @top_srcdir@/doc/manual/eof/04_fake_sentinel.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/eof/04_fake_sentinel.re
:literal:
:code: RE2C_LANG
@@ -114,115 +118,118 @@ Buffer refilling
:literal:
:code: RE2C_LANG
Features
========
Multiple blocks
===============
.. include:: @top_srcdir@/doc/manual/conditions/blocks.rst_
---------------
.. include:: @top_srcdir@/doc/manual/features/conditions/blocks.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/conditions/parse_u32_blocks.re
:literal:
:code: RE2C_LANG
Start conditions
================
.. include:: @top_srcdir@/doc/manual/conditions/conditions.rst_
----------------
.. include:: @top_srcdir@/doc/manual/features/conditions/conditions.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/conditions/parse_u32_conditions.re
:literal:
:code: RE2C_LANG
Storable state
==============
.. include:: @top_srcdir@/doc/manual/state/state.rst_
--------------
.. include:: @top_srcdir@/doc/manual/features/state/state.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/state/push.re
:literal:
:code: RE2C_LANG
Reusable blocks
===============
.. include:: @top_srcdir@/doc/manual/reuse/reuse.rst_
---------------
.. include:: @top_srcdir@/doc/manual/features/reuse/reuse.rst_
Example of a ``!use`` directive
-------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/reuse/usedir.re
:literal:
:code: RE2C_LANG
Example of a ``/*!use:re2c ... */`` block
-----------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/reuse/reuse.re
:literal:
:code: RE2C_LANG
Submatch extraction
===================
.. include:: @top_srcdir@/doc/manual/submatch/submatch.rst_
.. include:: @top_srcdir@/doc/manual/submatch/submatch_example_stags.rst_
-------------------
.. include:: @top_srcdir@/doc/manual/features/submatch/submatch.rst_
.. include:: @top_srcdir@/doc/manual/features/submatch/submatch_example_stags.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/submatch/01_stags.re
:literal:
:code: RE2C_LANG
.. include:: @top_srcdir@/doc/manual/submatch/submatch_example_stags_fill.rst_
.. include:: @top_srcdir@/doc/manual/features/submatch/submatch_example_stags_fill.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/submatch/01_stags_fill.re
:literal:
:code: RE2C_LANG
.. include:: @top_srcdir@/doc/manual/submatch/submatch_example_posix.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/submatch/03_posix.re
.. include:: @top_srcdir@/doc/manual/features/submatch/submatch_example_captures.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/submatch/03_captures.re
:literal:
:code: RE2C_LANG
.. include:: @top_srcdir@/doc/manual/submatch/submatch_example_mtags.rst_
.. include:: @top_srcdir@/doc/manual/features/submatch/submatch_example_mtags.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/submatch/02_mtags.re
:literal:
:code: RE2C_LANG
Encoding support
================
.. include:: @top_srcdir@/doc/manual/encodings/encodings.rst_
----------------
.. include:: @top_srcdir@/doc/manual/features/encodings/encodings.rst_
.. include:: @top_srcdir@/examples/RE2C_LANG/encodings/unicode_identifier.re
:literal:
:code: RE2C_LANG
Include files
=============
.. include:: @top_srcdir@/doc/manual/includes/includes.rst_
-------------
.. include:: @top_srcdir@/doc/manual/features/includes/includes.rst_
Include file 1 (definitions.RE2C_HEADER_EXT)
------------------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/includes/definitions.RE2C_HEADER_EXT
:literal:
:code: RE2C_LANG
Include file 2 (extra_rules.re.inc)
-----------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/includes/extra_rules.re.inc
:literal:
:code: RE2C_LANG
Input file
----------
~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/includes/include.re
:literal:
:code: RE2C_LANG
Header files
============
.. include:: @top_srcdir@/doc/manual/headers/headers.rst_
------------
.. include:: @top_srcdir@/doc/manual/features/headers/headers.rst_
Input file
----------
~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/headers/header.re
:literal:
:code: RE2C_LANG
Header file
-----------
~~~~~~~~~~~
.. include:: @top_srcdir@/examples/RE2C_LANG/headers/lexer/state.RE2C_HEADER_EXT
:literal:
:code: RE2C_LANG
Skeleton programs
=================
.. include:: @top_srcdir@/doc/manual/skeleton/skeleton.rst_
-----------------
.. include:: @top_srcdir@/doc/manual/features/skeleton/skeleton.rst_
Visualization and debug
=======================
.. include:: @top_srcdir@/doc/manual/dot/dot.rst_
-----------------------
.. include:: @top_srcdir@/doc/manual/features/dot/dot.rst_
SEE ALSO
========
@@ -231,6 +238,4 @@ Similar programs are flex(1), lex(1), quex(http://quex.sourceforge.net).
AUTHORS
=======
re2c was originaly written by Peter Bumbulis in 1993.
Since then it has been developed and maintained by multiple volunteers;
mots notably, Brain Young, Marcus Boerger, Dan Nuffer and Ulya Trofimovich.
.. include:: @top_srcdir@/doc/manual/authors.rst_
-230
View File
@@ -1,230 +0,0 @@
Here is a list of API primitives that may be used by the generated
code in order to interface with the outer program.
Which primitives are needed depends on multiple factors, including
the complexity of regular expressions, input representation,
buffering, the use of various features and so on.
All the necessary primitives should be defined by the user in the form
of macros, functions, variables, free-form pieces of code, or any other
suitable form.
re2c does not (and cannot) check the definitions, so if anything is
missing or defined incorrectly the generated code will not compile.
``YYCTYPE``
The type of the input characters (code units).
For ASCII, EBCDIC and UTF-8 encodings it should be 1-byte unsigned integer.
For UTF-16 or UCS-2 it should be 2-byte unsigned integer. For UTF-32 it
should be 4-byte unsigned integer.
``YYCURSOR``
A pointer-like l-value that stores the current input position (usually a
pointer of type ``YYCTYPE*``). Initially ``YYCURSOR`` should point to the
first input character. It is advanced by the generated code.
When a rule matches, ``YYCURSOR`` points to the position after the
last matched character. It is used only in C pointer API.
``YYLIMIT``
A pointer-like r-value that stores the end of input position (usually a
pointer of type ``YYCTYPE*``). Initially ``YYLIMIT`` should point to the
position after the last available input character. It is not changed by the
generated code. The lexer compares ``YYCURSOR`` to ``YYLIMIT``
in order to determine if there are enough input characters left.
``YYLIMIT`` is used only in C pointer API.
``YYMARKER``
A pointer-like l-value (usually a pointer of type ``YYCTYPE*``)
that stores the position of the latest matched rule. It is used to
restore the ``YYCURSOR`` position if the longer match fails and
the lexer needs to rollback. Initialization is not
needed. ``YYMARKER`` is used only in C pointer API.
``YYCTXMARKER``
A pointer-like l-value that stores the position of the trailing context
(usually a pointer of type ``YYCTYPE*``). No initialization is needed.
It is used only in C pointer API, and only with the lookahead operator
``/``.
``YYFILL``
A generic API primitive with one argument ``len``.
``YYFILL`` should provide at least ``len`` more input characters or fail.
If ``re2c:eof`` is used, then ``len`` is always ``1`` and ``YYFILL`` should
always return to the calling function; zero return value indicates success.
If ``re2c:eof`` is not used, then ``YYFILL`` return value is ignored and it
should not return on failure. The maximum value of ``len`` is ``YYMAXFILL``.
The definition of ``YYFILL`` can be either function-like or free-form
depending on the API style (see ``re2c:api:style`` and
``re2c:define:YYFILL:naked``).
``YYMAXFILL``
An integral constant equal to the maximum value of the argument to
``YYFILL``. It can be generated with ``/*!max:re2c*/`` directive.
``YYLESSTHAN``
A generic API primitive with one argument ``len``.
It should be defined as an r-value of boolean type that equals ``true`` if
and only if there are less than ``len`` input characters left.
The definition can be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYPEEK``
A generic API primitive with no arguments.
It should be defined as an r-value of type ``YYCTYPE`` that is equal to the
character at the current input position. The definition can be either
function-like or free-form depending on the API style (see
``re2c:api:style``).
``YYSKIP``
A generic API primitive with no arguments.
``YYSKIP`` should advance the current input position by one
character. The definition can be either function-like or free-form
depending on the API style (see ``re2c:api:style``).
``YYBACKUP``
A generic API primitive with no arguments.
``YYBACKUP`` should save the current input position, which is
later restored with ``YYRESTORE``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYRESTORE``
A generic API primitive with no arguments.
``YYRESTORE`` should restore the current input position to the
value saved by ``YYBACKUP``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYBACKUPCTX``
A generic API primitive with zero arguments.
``YYBACKUPCTX`` should save the current input position as the
position of the trailing context, which is later restored by
``YYRESTORECTX``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYRESTORECTX``
A generic API primitive with no arguments.
``YYRESTORECTX`` should restore the trailing context position
saved with ``YYBACKUPCTX``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYRESTORETAG``
A generic API primitive with one argument ``tag``.
``YYRESTORETAG`` should restore the trailing context position
to the value of ``tag``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYSTAGP``
A generic API primitive with one argument ``tag``, where ``tag`` can be a
pointer or an offset (see submatch extraction section for details).
``YYSTAGP`` should set ``tag`` to the current input position.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYSTAGN``
A generic API primitive with one argument ``tag``, where ``tag`` can be a
pointer or an offset (see submatch extraction section for details).
``YYSTAGN`` should to set ``tag`` to a value that represents non-existent
input position.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYMTAGP``
A generic API primitive with one argument ``tag``.
``YYMTAGP`` should append the current position to the submatch history of
``tag`` (see the submatch extraction section for details.)
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYMTAGN``
A generic API primitive with one argument ``tag``.
``YYMTAGN`` should append a value that represents non-existent input
position position to the submatch history of ``tag`` (see the submatch
extraction section for details.)
The definition can be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYSHIFT``
A generic API primitive with one argument ``shift``.
``YYSHIFT`` should shift the current input position by
``shift`` characters (the shift value may be negative). The definition
can be either function-like or free-form depending on the API style
(see ``re2c:api:style``).
``YYSHIFTSTAG``
A generic API primitive with two arguments, ``tag`` and ``shift``.
``YYSHIFTSTAG`` should shift ``tag`` by ``shift`` characters
(the shift value may be negative).
The definition can be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYSHIFTMTAG``
A generic API primitive with two arguments, ``tag`` and ``shift``.
``YYSHIFTMTAG`` should shift the latest value in the history
of ``tag`` by ``shift`` characters (the shift value may be negative).
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style``).
``YYMAXNMATCH``
An integral constant equal to the maximal number of POSIX capturing groups
in a rule. It is generated with ``/*!maxnmatch:re2c*/`` directive.
``YYCONDTYPE``
The type of the condition enum.
It should be generated either with the ``/*!types:re2c*/``
directive or the ``-t`` ``--type-header`` option.
``YYGETCONDITION``
An API primitive with zero arguments.
It should be defined as an r-value of type ``YYCONDTYPE`` that is equal to
the current condition identifier. The definition can be either function-like
or free-form depending on the API style (see ``re2c:api:style`` and
``re2c:define:YYGETCONDITION:naked``).
``YYSETCONDITION``
An API primitive with one argument ``cond``.
The meaning of ``YYSETCONDITION`` is to set the current condition
identifier to ``cond``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style`` and ``re2c:define:YYSETCONDITION@cond``).
``YYGETSTATE``
An API primitive with zero arguments.
It should be defined as an r-value of integer type that is equal to the
current lexer state. Should be initialized to ``-1``. The definition can be
either function-like or free-form depending on the API style (see
``re2c:api:style`` and ``re2c:define:YYGETSTATE:naked``).
``YYSETSTATE``
An API primitive with one argument ``state``.
The meaning of ``YYSETSTATE`` is to set the current lexer state to
``state``.
The definition should be either function-like or free-form depending on the
API style (see ``re2c:api:style`` and ``re2c:define:YYSETSTATE@state``).
``YYDEBUG``
A debug API primitive with two arguments. It can be used to debug the
generated code (with ``-d`` ``--debug-output`` option). ``YYDEBUG`` should
return no value and accept two arguments: ``state`` (either a DFA state
index or ``-1``) and ``symbol`` (the current input symbol).
``yych``
An l-value of type ``YYCTYPE`` that stores the current input character.
User definition is necessary only with ``-f`` ``--storable-state`` option.
``yyaccept``
An l-value of unsigned integral type that stores the number of the latest
matched rule.
User definition is necessary only with ``-f`` ``--storable-state`` option.
``yynmatch``
An l-value of unsigned integral type that stores the number of POSIX
capturing groups in the matched rule.
Used only with ``-P`` ``--posix-captures`` option.
``yypmatch``
An array of l-values that are used to hold the tag values corresponding
to the capturing parentheses in the matching rule. Array length must be
at least ``yynmatch * 2`` (usually ``YYMAXNMATCH * 2`` is a good choice).
Used only with ``-P`` ``--posix-captures`` option.
+13
View File
@@ -0,0 +1,13 @@
|re2c| was originally written by Peter Bumbulis (peter@csg.uwaterloo.ca) in 1993.
Marcus Boerger and Dan Nuffer spent several years to turn the original idea into
a production ready code generator. Since then it has been maintained and
developed by multiple volunteers, most notably,
Brian Young (bayoung@acm.org),
`Marcus Boerger <https://github.com/helly25>`_,
Dan Nuffer (nuffer@users.sourceforge.net),
`Ulya Trofimovich <https://github.com/skvadrik>`_ (skvadrik@gmail.com),
`Serghei Iakovlev <https://github.com/sergeyklay>`_,
`Sergei Trofimovich <https://github.com/trofi>`_,
`Petr Skocik <https://github.com/pskocik>`_,
`ligfx <https://github.com/ligfx>`_
and `raekye <https://github.com/raekye>`_.
+14
View File
@@ -0,0 +1,14 @@
The generated code interfaces with the outer program with the help of
*primitives*, collectively referred to as the *API*.
Which primitives should be defined for a particular program depends on multiple
factors, including the complexity of regular expressions, input representation,
buffering and the use of various features. All the necessary primitives should
be defined by the user in the form of macros, functions, variables or any other
suitable form that makes the generated code syntactically and semantically
correct. |re2c| does not (and cannot) check the definitions, so if anything is
missing or defined incorrectly, the generated program may have compile-time or
run-time errors.
This manual provides examples of API definitions in the most common cases.
.. _generic_api:
+99
View File
@@ -0,0 +1,99 @@
re2c has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for C/C++ backend. It consists of primitives
``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER`` and ``YYLIMIT``, which
should be defined as pointers of type ``YYCTYPE*``.
|
**Record API**
(*added in version 4.0*)
Record API is useful in cases when lexer state must be stored in a struct.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be
defined as a struct with fields ``yycursor``, ``yymarker``, ``yyctxmarker``,
``yylimit`` (only the fields used by the generated code need to be defined,
and their names can be configured).
|
**Generic API**
(*added in version 0.14*)
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
This API contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
Generic API supports two styles that determine the form in which the
primitives should be defined:
|
**Free-form**
Free-form style is enabled with configuration
``re2c:api:style = free-form``.
In this style interface primitives should be defined as free-form
pieces of code with interpolated variables of the form ``@@{var}`` or
optionally just ``@@`` if there is a single variable. The set of
variables is specific to each primitive. Here's how free-form generic
API can be defined in terms of pointers ``cursor``, ``limit``,
``marker`` and ``ctxmarker``:
.. code-block:: c
/*!re2c
re2c:YYPEEK = "*cursor";
re2c:YYSKIP = "++cursor;";
re2c:YYBACKUP = "marker = cursor;";
re2c:YYRESTORE = "cursor = marker;";
re2c:YYBACKUPCTX = "ctxmarker = cursor;";
re2c:YYRESTORECTX = "cursor = ctxmarker;";
re2c:YYRESTORETAG = "cursor = ${tag};";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYSTAGP = "@@{tag} = cursor;";
re2c:YYSTAGN = "@@{tag} = NULL;";
re2c:YYSHIFT = "cursor += @@{shift};";
re2c:YYSHIFTSTAG = "@@{tag} += @@{shift};";
*/
|
**Function-like**
Historically function-like style is the default one. It also can be
enabled with configuration ``re2c:api:style = functions``. In this
style primitives should be defined as functions or macros with
parentheses, accepting the necessary arguments. Here's how function-like
generic API can be defined in terms of pointers ``cursor``, ``limit``,
``marker`` and ``ctxmarker`` using preprocessor macros:
.. code-block:: c
#define YYPEEK() *cursor
#define YYSKIP() ++cursor
#define YYBACKUP() marker = cursor
#define YYRESTORE() cursor = marker
#define YYBACKUPCTX() ctxmarker = cursor
#define YYRESTORECTX() cursor = ctxmarker
#define YYRESTORETAG(tag) cursor = tag
#define YYLESSTHAN(len) limit - cursor < len
#define YYSTAGP(tag) tag = cursor
#define YYSTAGN(tag) tag = NULL
#define YYSHIFT(shift) cursor += shift
#define YYSHIFTSTAG(tag, shift) tag += shift
+41
View File
@@ -0,0 +1,41 @@
re2d has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for D backend. It consists of primitives
``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER`` and ``YYLIMIT``, which
should be defined as pointers of type ``YYCTYPE*``.
|
**Record API**
Record API is useful in cases when lexer state must be stored in a struct.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be
defined as a struct with fields ``yycursor``, ``yymarker``, ``yyctxmarker``,
``yylimit`` (only the fields used by the generated code need to be defined,
and their names can be configured).
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+96
View File
@@ -0,0 +1,96 @@
re2go has three API flavors that define the core set of primitives used by a
program:
**Simple API**
(*added in version 4.0*)
This is a basic API that can be enabled with ``--api simple`` option or
``re2c:api = simple`` configuration. It consists of the following
primitives: ``YYINPUT`` (which should be defined as a sequence of code
units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
(*added in version 4.0*)
Record API is useful in cases when lexer state must be stored in a struct.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be
defined as a struct with fields ``yyinput``, ``yycursor``, ``yymarker``,
``yyctxmarker``, ``yylimit`` (only the fields used by the generated code
need to be defined, and their names can be configured).
|
**Generic API**
This is the most flexible API and the default API for the Go backend.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
Generic API supports two styles that determine the form in which the
primitives should be defined:
|
**Free-form**
Free-form style is the default one. It can also be enabled with
configuration ``re2c:api:style = free-form``.
In this style interface primitives should be defined as free-form
pieces of code with interpolated variables of the form ``@@{var}`` or
optionally just ``@@`` if there is a single variable. The set of
variables is specific to each primitive. Here's how free-form generic
API can be defined in terms of integer variables ``cursor``, ``limit``,
``marker``, ``ctxmarker`` and a string (or a byte slice) ``data``:
.. code-block:: go
/*!re2c
re2c:YYPEEK = "data[cursor]";
re2c:YYSKIP = "cursor++";
re2c:YYBACKUP = "marker = cursor";
re2c:YYRESTORE = "cursor = marker";
re2c:YYBACKUPCTX = "ctxmarker = cursor";
re2c:YYRESTORECTX = "cursor = ctxmarker";
re2c:YYRESTORETAG = "cursor = ${tag}";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYSTAGP = "@@{tag} = cursor";
re2c:YYSTAGN = "@@{tag} = -1";
re2c:YYSHIFT = "cursor += @@{shift}";
re2c:YYSHIFTSTAG = "@@{tag} += @@{shift}";
*/
|
**Function-like**
Function-like style is enabled with configuration
``re2c:api:style = functions``. In this style primitives should be
defined as closures accepting the necessary arguments. Here's how
function-like generic API can be defined in terms of integer variables
``cursor``, ``limit``, ``marker``, ``ctxmarker`` and a string (or a byte
slice) ``data``:
.. code-block:: go
YYPEEK := func() byte { return data[cursor] }
YYSKIP := func() { cursor++ }
YYBACKUP := func() { marker = cursor }
YYRESTORE := func() { cursor = marker }
YYBACKUPCTX := func() { ctxmarker = cursor }
YYRESTORECTX := func() { cursor = ctxmarker }
YYLESSTHAN := func(n int) bool { return limit-cursor < n }
YYSHIFT := func(n int) { cursor += n }
+35
View File
@@ -0,0 +1,35 @@
re2hs has two API flavors that define the core set of primitives used by a
program:
**Record API**
Record API is the default API for the Haskell backend.
This API consists of a binding ``yyrecord`` (the name can be overridden with
``re2c:yyrecord``) that should be defined as a record with fields
``_yyinput``, ``_yycursor``, ``_yymarker``, ``_yyctxmarker``, ``_yylimit``.
Only the fields used by the generated code need to be defined, and their
names can be configured.
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYCOPYSTAG``,
``YYCOPYMTAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+42
View File
@@ -0,0 +1,42 @@
re2java has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for the Java backend. It consists of the following
primitives: ``YYINPUT`` (which should be defined as a sequence of code
units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
Record API is useful in cases when lexer state must be stored in a class.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be
defined as a class with fields ``yyinput``, ``yycursor``, ``yymarker``,
``yyctxmarker``, ``yylimit`` (only the fields used by the generated code
need to be defined, and their names can be configured).
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+42
View File
@@ -0,0 +1,42 @@
re2js has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for the JavaScript backend. It consists of the
following primitives: ``YYINPUT`` (which should be defined as a sequence of
code units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
Record API is useful in cases when lexer state must be stored in an object.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be defined as an
object with properties ``yyinput``, ``yycursor``, ``yymarker``,
``yyctxmarker``, ``yylimit`` (only the fields used by the generated code
need to be defined, and their names can be configured).
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+33
View File
@@ -0,0 +1,33 @@
re2ocaml has two API flavors that define the core set of primitives used by a
program:
**Record API**
Record API is the default API for the OCaml backend.
This API consists of a variable ``yyrecord`` (the name can be overridden with
``re2c:yyrecord``) that should be defined as a record with fields
``_yyinput``, ``_yycursor``, ``_yymarker``, ``_yyctxmarker``, ``_yylimit``.
Only the fields used by the generated code need to be defined, and their
names can be configured.
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+42
View File
@@ -0,0 +1,42 @@
re2py has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for the Python backend. It consists of the
following primitives: ``YYINPUT`` (which should be defined as a sequence of
code units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
Record API is useful in cases when lexer state must be stored in a class.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be defined as a
class with attributes ``yyinput``, ``yycursor``, ``yymarker``,
``yyctxmarker``, ``yylimit`` (only the fields used by the generated code
need to be defined, and their names can be configured).
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+65
View File
@@ -0,0 +1,65 @@
re2rust has three API flavors that define the core set of primitives used by a
program:
**Simple API**
(*added in version 4.0*)
This is a basic API that can be enabled with ``--api simple`` option or
``re2c:api = simple`` configuration. It consists of the following
primitives: ``YYINPUT`` (which should be defined as a sequence of code
units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
(*added in version 4.0*)
Record API is useful in cases when lexer state must be stored in a struct.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be defined as a
struct with fields ``yyinput``, ``yycursor``, ``yymarker``, ``yyctxmarker``,
``yylimit`` (only the fields used by the generated code need to be defined,
and their names can be configured).
|
**Generic API**
This is the most flexible API and the default API for the Rust backend.
This API contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
For example, if the input is a byte slice ``buffer: &[u8]``, variables
``cursor``, ``limit``, ``marker`` and ``ctxmarker`` of type ``usize``
represent input positions, and a constant ``NONE`` represents invalid
position, then generic API can be defined as follows:
.. code-block:: rust
/*!re2c
re2c:YYPEEK = "*buffer.get_unchecked(cursor)";
re2c:YYSKIP = "cursor += 1;";
re2c:YYBACKUP = "marker = cursor;";
re2c:YYRESTORE = "cursor = marker;";
re2c:YYBACKUPCTX = "ctxmarker = cursor;";
re2c:YYRESTORECTX = "cursor = ctxmarker;";
re2c:YYRESTORETAG = "cursor = @@{tag};";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYSTAGP = "@@{tag} = cursor;";
re2c:YYSTAGN = "@@{tag} = NONE;";
re2c:YYSHIFT = "cursor = (cursor as isize + @@{shift}) as usize;";
re2c:YYSHIFTSTAG = "@@{tag} = (@@{tag} as isize + @@{shift}) as usize;";
*/
+42
View File
@@ -0,0 +1,42 @@
re2v has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for the V backend. It consists of the following
primitives: ``YYINPUT`` (which should be defined as a sequence of code
units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
Record API is useful in cases when lexer state must be stored in a struct.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be
defined as a struct with fields ``yyinput``, ``yycursor``, ``yymarker``,
``yyctxmarker``, ``yylimit`` (only the fields used by the generated code
need to be defined, and their names can be configured).
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+42
View File
@@ -0,0 +1,42 @@
re2zig has three API flavors that define the core set of primitives used by a
program:
**Simple API**
This is the default API for the Zig backend. It consists of the following
primitives: ``YYINPUT`` (which should be defined as a sequence of code
units, e.g. a string) and ``YYCURSOR``, ``YYMARKER``, ``YYCTXMARKER``,
``YYLIMIT`` (which should be defined as indices in ``YYINPUT``).
|
**Record API**
Record API is useful in cases when lexer state must be stored in a struct.
It is enabled with ``--api record`` option or ``re2c:api = record``
configuration. This API consists of a variable ``yyrecord`` (the
name can be overridden with ``re2c:yyrecord``) that should be
defined as a struct with fields ``yyinput``, ``yycursor``, ``yymarker``,
``yyctxmarker``, ``yylimit`` (only the fields used by the generated code
need to be defined, and their names can be configured).
|
**Generic API**
This is the most flexible API. It is enabled with ``--api generic`` option
or ``re2c:api = generic`` configuration.
It contains primitives for generic operations:
``YYPEEK``,
``YYSKIP``,
``YYBACKUP``,
``YYBACKUPCTX``,
``YYSTAGP``,
``YYSTAGN``,
``YYMTAGP``,
``YYMTAGN``,
``YYRESTORE``,
``YYRESTORECTX``,
``YYRESTORETAG``,
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
+234
View File
@@ -0,0 +1,234 @@
Here is a full list of API primitives that may be used by the generated code in
order to interface with the outer program.
``YYCTYPE``
The type of the input characters (code units).
For ASCII, EBCDIC and UTF-8 encodings it should be 1-byte unsigned integer.
For UTF-16 or UCS-2 it should be 2-byte unsigned integer. For UTF-32 it
should be 4-byte unsigned integer.
``YYCURSOR``
An l-value that stores the current input position (a pointer or an integer
offset in ``YYINPUT``). Initially ``YYCURSOR`` should point to the first
input character, and later it is advanced by the generated code. When a rule
matches, ``YYCURSOR`` position is the one after the last matched character.
``YYLIMIT``
An r-value that stores the end of input position (a pointer or an integer
offset in ``YYINPUT``). Initially ``YYLIMIT`` should point to the position
after the last available input character. It is not changed by the
generated code. The lexer compares ``YYCURSOR`` to ``YYLIMIT``
in order to determine if there are enough input characters left.
``YYMARKER``
An l-value that stores the position of the latest matched rule (a pointer or
an integer offset in ``YYINPUT``). It is used to restore the ``YYCURSOR``
position if the longer match fails and the lexer needs to rollback.
Initialization is not needed.
``YYCTXMARKER``
An l-value that stores the position of the trailing context (a pointer or an
integer offset in ``YYINPUT``). No initialization is needed. ``YYCTXMARKER``
is needed only if the lookahead operator ``/`` is used.
``YYFILL``
A generic API primitive with one variable ``len``.
``YYFILL`` should provide at least ``len`` more input characters or fail.
If ``re2c:eof`` is used, then ``len`` is always ``1`` and ``YYFILL`` should
always return to the calling function; zero return value indicates success.
If ``re2c:eof`` is not used, then ``YYFILL`` return value is ignored and it
should not return on failure. The maximum value of ``len`` is ``YYMAXFILL``.
``YYFN``
A primitive that defines function prototype in ``--recursive-functions``
code model. Its value should be an array of one or more strings, where each
string contains two or three components separated by the string specified in
``re2c:fn:sep`` configuration (typically a semicolon). The first array
element defines function name and return type (empty for a void function).
Subsequent elements define function arguments: first, the expression for the
argument used in function body (usually just a name); second, argument type;
third, an optional formal parameter (it defaults to the first component -
usually both the argument and the parameter are the same identifier).
``YYINPUT``
An r-value that stores the current input character sequence (string, buffer,
etc.).
``YYMAXFILL``
An integral constant equal to the maximum value of the argument to
``YYFILL``. It can be generated with a ``max`` block.
``YYLESSTHAN``
A generic API primitive with one variable ``len``.
It should be defined as an r-value of boolean type that equals ``true`` if
and only if there are less than ``len`` input characters left.
``YYPEEK``
A generic API primitive with no variables.
It should be defined as an r-value of type ``YYCTYPE`` that is equal to the
character at the current input position.
``YYSKIP``
A generic API primitive that should advance the current input position by
one code unit.
``YYBACKUP``
A generic API primitive that should save the current input position (to be
restored with ``YYRESTORE`` later).
``YYRESTORE``
A generic API primitive that should restore the current input position to
the value saved by ``YYBACKUP``.
``YYBACKUPCTX``
A generic API primitive that should save the current input position as the
position of the trailing context (to be restored with ``YYRESTORECTX``
later).
``YYRESTORECTX``
A generic API primitive that should restore the trailing context position
saved with ``YYBACKUPCTX``.
``YYRESTORETAG``
A generic API primitive with one variable ``tag`` that should restore the
trailing context position to the value of ``tag``.
``YYSTAGP``
A generic API primitive with one variable ``tag``, where ``tag`` can be a
pointer or an offset in ``YYINPUT`` (see submatch extraction section for
details). ``YYSTAGP`` should set ``tag`` to the current input position.
``YYSTAGN``
A generic API primitive with one variable ``tag``, where ``tag`` can be a
pointer or an offset in ``YYINPUT`` (see submatch extraction section for
details). ``YYSTAGN`` should to set ``tag`` to a value that represents
non-existent input position.
``YYMTAGP``
A generic API primitive with one variable ``tag``.
``YYMTAGP`` should append the current position to the submatch history of
``tag`` (see the submatch extraction section for details.)
``YYMTAGN``
A generic API primitive with one variable ``tag``.
``YYMTAGN`` should append a value that represents non-existent input
position position to the submatch history of ``tag`` (see the submatch
extraction section for details.)
``YYSHIFT``
A generic API primitive with one variable ``shift`` that should shift the
current input position by ``shift`` characters (the shift value may be
negative).
``YYCOPYSTAG``
A generic API primitive with two variables, ``lhs`` and ``rhs`` that should
copy right-hand-side s-tag variable ``rhs`` to the left-hand-side s-tag
variable ``lhs``. For most languages this primitive has a default definition
that assigns ``lhs`` to ``rhs``.
``YYCOPYMTAG``
A generic API primitive with two variables, ``lhs`` and ``rhs`` that should
copy right-hand-side m-tag variable ``rhs`` to the left-hand-side m-tag
variable ``lhs``. For most languages this primitive has a default definition
that assigns ``lhs`` to ``rhs``.
``YYSHIFTSTAG``
A generic API primitive with two variables, ``tag`` and ``shift`` that
should shift ``tag`` by ``shift`` code units (the shift value may be
negative).
``YYSHIFTMTAG``
A generic API primitive with two variables, ``tag`` and ``shift`` that
should shift the latest value in the history of ``tag`` by ``shift`` code
units (the shift value may be negative).
``YYMAXNMATCH``
An integral constant equal to the maximal number of POSIX capturing groups
in a rule. It is generated with a ``maxnmatch`` block.
``YYCONDTYPE``
The type of the condition enum.
It can be generated either with ``conditions`` block or ``--header`` option.
``YYGETACCEPT``
A primitive with one variable ``var`` that stores numeric selector of the
accepted rule. For most languages this primitive has a default definition
that reads from ``var``.
``YYSETACCEPT``
A primitive with two variables: ``var`` (an l-value that stores numeric
selector of the accepted rule), and ``val`` (the value of selector). For
most languages this primitive has a default definition that assigns ``var``
to ``val``.
``YYGETCOND``
An r-value of type ``YYCONDTYPE`` that is equal to the current condition
identifier.
``YYSETCOND``
A primitive with one variable ``cond`` that should set the current
condition identifier to ``cond``.
``YYGETSTATE``
An r-value of integer type that is equal to the current lexer state. It
should be initialized to ``-1``.
``YYSETSTATE``
A primitive with one variable ``state`` that should set the current lexer
state to ``state``.
``YYDEBUG``
This primitive is generated only with ``-d``, ``--debug-output`` option.
Its purpose is to add logging to the generated code (typical ``YYDEBUG``
definition is a print statement). ``YYDEBUG`` statements are generated in
every state and have two variables: ``state`` (either a DFA state index or
``-1``) and ``symbol`` (the current input symbol).
``yyaccept``
An l-value of unsigned integral type that stores the number of the latest
matched rule. User definition is necessary only with ``--storable-state``
option.
``yybm``
A table containing compressed bitmaps for up to 8 transitions (used with
the ``--bitmaps`` option). The table contains 256 elements and is indexed by
1-byte code units. Each 8-bit element combines boolean values for up to 8
transitions. k-Th bit of n-th element is true iff n-th code unit is in the
range of k-th transition. The idea of this bitmap is to replace many `if`
branches or `switch` cases with one check of a single bit in the table.
``yych``
An l-value of type ``YYCTYPE`` that stores the current input character.
User definition is necessary only with ``-f`` ``--storable-state`` option.
``yyctable``
Jump table generated for the initial condition dispatch (enabled with the
combination of ``--conditions`` and ``--computed-gotos`` options).
``yyfill``
An l-value that stores the result of ``YYFILL`` call (this may be necessary
for pure functional languages, where ``YYFILL`` is a monadic function with
complex return value).
``yynmatch``
An l-value of unsigned integral type that stores the number of POSIX
capturing groups in the matched rule.
Used only with ``-P`` ``--posix-captures`` option.
``yypmatch``
An array of l-values that are used to hold the tag values corresponding
to the capturing parentheses in the matching rule. Array length must be
at least ``yynmatch * 2`` (usually ``YYMAXNMATCH * 2`` is a good choice).
Used only with ``-P`` ``--posix-captures`` option.
``yystable``
Deprecated.
``yystate``
An l-value used with the ``--loop-switch`` option to store the current DFA
state.
``yytarget``
Jump table that contains jump targets (label addresses) for all transitions
from a state. This table is local to each state. Generation of ``yytarget``
tables is enabled with ``--computed-gotos`` option.
+120
View File
@@ -0,0 +1,120 @@
Block start and end markers are either ``/*!re2c`` and ``*/``, or ``%{`` and
``%}`` (both styles are supported). Starting from version 2.2 blocks may have
optional names that allow them to be referenced in other blocks.
There are different kinds of blocks:
``/*!re2c[:<name>] ... */`` or ``%{[:<name>] ... %}``
A *global block* contains definitions, configurations, rules and directives.
|re2c| compiles regular expressions associated with each rule into a
deterministic finite automaton, encodes it in the form of conditional jumps
in the target language and replaces the block with the generated code. Names
and configurations defined in a global block are added to the global scope
and become visible to subsequent blocks. At the start of the program the
global scope is initialized with command-line `options`_.
``/*!local:re2c[:<name>] ... */`` or ``%{local[:<name>] ... %}``
A *local block* is like a global block, but the names and configurations in
it have local scope (they do not affect other blocks).
``/*!rules:re2c[:<name>] ... */`` or ``%{rules[:<name>] ... %}``
A *rules block* is like a local block, but it does not generate any code by
itself, nor does it add any definitions to the global scope -- it is meant
to be reused in other blocks. This is a way of sharing code (more details in
the `reusable blocks`_ section). Prior to |re2c| version 2.2 rules blocks
required ``-r --reusable`` option.
``/*!use:re2c[:<name>] ... */`` or ``%{use[:<name>] ... %}``
A use block that references a previously defined rules block. If the name is
specified, |re2c| looks for a rules blocks with this name. Otherwise the most
recent rules block is used (either a named or an unnamed one). A use block
can add definitions, configurations and rules of its own, which are added to
those of the referenced rules block. Prior to |re2c| version 2.2 use blocks
required ``-r --reusable`` option.
``/*!max:re2c[:<name1>[:<name2>...]] ... */`` or ``%{max[:<name1>[:<name2>...]] ... %}``
A block that generates ``YYMAXFILL`` definition. An optional list of block
names specifies which blocks should be included when computing ``YYMAXFILL``
value (if the list is empty, all blocks are included).
By default the generated code is a macro-definition for C
(``#define YYMAXFILL <n>``), or a global variable for Go
(``var YYMAXFILL int = <n>``). It can be customized with an optional
configuration ``format`` that specifies a template string where ``@@{max}``
(or ``@@`` for short) is replaced with the numeric value of ``YYMAXFILL``.
``/*!maxnmatch:re2c[:<name1>[:<name2>...]] ... */`` or ``%{maxnmatch[:<name1>[:<name2>...]] ... %}``
A block that generates ``YYMAXNMATCH`` definition (it requires
``-P --posix-captures`` option). An optional list of block names specifies
which blocks should be included when computing ``YYMAXNMATCH`` value (if the
list is empty, all blocks are included).
By default the generated code is a macro-definition for C
(``#define YYMAXNMATCH <n>``), or a global variable for Go
(``var YYMAXNMATCH int = <n>``). It can be customized with an optional
configuration ``format`` that specifies a template string where ``@@{max}``
(or ``@@`` for short) is replaced with the numeric value of ``YYMAXNMATCH``.
``/*!stags:re2c[:<name1>[:<name2>...]] ... */``, ``/*!mtags:re2c[:<name1>[:<name2>...]] ... */`` or ``%{stags[:<name1>[:<name2>...]] ... %}``, ``%{mtags[:<name1>[:<name2>...]] ... %{``
Blocks that specify a template piece of code that is expanded for each
s-tag/m-tag variable generated by |re2c|. An optional list of block names
specifies which blocks should be included when computing the set of tag
variables (if the list is empty, all blocks are included).
There are two optional configurations: ``format`` and ``separator``.
Configuration ``format`` specifies a template string where ``@@{tag}`` (or
``@@`` for short) is replaced with the name of each tag variable.
Configuration ``separator`` specifies a piece of code used to join the
generated ``format`` pieces for different tag variables.
``/*!svars:re2c[:<name1>[:<name2>...]] ... */``, ``/*!mvars:re2c[:<name1>[:<name2>...]] ... */`` or ``%{svars[:<name1>[:<name2>...]] ... %}``, ``%{mvars[:<name1>[:<name2>...]] ... %{``
Blocks that specify a template piece of code that is expanded for each
s-tag/m-tag that is either explicitly mentioned by the rules (with
``--tags`` option) or implicitly generated by |re2c| (with ``--captvars`` or
``--posix-captvars`` options). An optional list of block names specifies
which blocks should be included when computing the set of tags (if the list
is empty, all blocks are included).
There are two optional configurations: ``format`` and ``separator``.
Configuration ``format`` specifies a template string where ``@@{tag}`` (or
``@@`` for short) is replaced with the name of each tag.
Configuration ``separator`` specifies a piece of code used to join the
generated ``format`` pieces for different tags.
``/*!getstate:re2c[:<name1>[:<name2>...]] ... */`` or ``%{getstate[:<name1>[:<name2>...]] ... %}``
A block that generates conditional dispatch on the lexer state (it requires
``--storable-state`` option). An optional list of block names specifies
which blocks should be included in the state dispatch. The default
transition goes to the start label of the first block on the list. If the
list is empty, all blocks are included, and the default transition goes to
the first block in the file that has a start label.
This block type is incompatible with the ``--loop-switch`` option, as it
requires cross-block transitions that are unsupported without ``goto`` or
function calls.
``/*!conditions:re2c[:<name1>[:<name2>...]] ... */``, ``/*!types:re2c... */`` or ``%{conditions[:<name1>[:<name2>...]] ... %}``, ``%{types... %}``
A block that generates condition enumeration (it requires ``--conditions``
option). An optional list of block names specifies which blocks should be
included when computing the set of conditions (if the list is empty, all
blocks are included).
By default the generated code is an enumeration ``YYCONDTYPE``. It can be
customized with optional configurations ``format`` and ``separator``.
Configuration ``format`` specifies a template string where ``@@{cond}`` (or
``@@`` for short) is replaced with the name of each condition, and
``@@{num}`` is replaced with a numeric index of that condition.
Configuration ``separator`` specifies a piece of code used to join the
generated ``format`` pieces for different conditions.
``/*!include:re2c <file> */`` or ``%{include <file> %}``
This block allows one to include ``<file>``, which must be a double-quoted
file path. The contents of the file are literally substituted in place of
the block, in the same way as ``#include`` works in C/C++. This block can be
used together with the ``--depfile`` option to generate build system
dependencies on the included files.
``/*!header:re2c:on*/`` or ``%{header:on %}``
This block marks the start of header file. Everything after it and up to the
following ``header:off`` block is processed by |re2c| and written to the
header file specified with ``-t --type-header`` option.
``/*!header:re2c:off*/`` or ``%{header:off %}``
This block marks the end of header file started with ``header:on*/`` block.
``/*!ignore:re2c ... */`` or ``%{ignore ... %}``
A block which contents are ignored and removed from the output file.
@@ -1,5 +1,6 @@
Here is a full list of configurations supported by |re2c|:
``re2c:api``, ``re2c:flags:input``
``re2c:api``, ``re2c:input``
Same as the ``--api`` option.
``re2c:api:sigil``
@@ -9,7 +10,7 @@
to ``$``, then placeholders will have the form ``${name}``. Single-argument
APIs may use shorthand notation without the name in braces. This option can
be overridden by options for individual API primitives, e.g.
``re2c:define:YYFILL@len`` for ``YYFILL``.
``re2c:YYFILL@len`` for ``YYFILL``.
``re2c:api:style``
Specify API style. Possible values are ``functions`` (the default for C) and
@@ -24,12 +25,20 @@
variables of the form ``@@{var}`` or ``@@`` (they correspond to arguments in
function-like style).
This configuration may be overridden for individual API primitives, see for
example ``re2c:define:YYFILL:naked`` configuration for ``YYFILL``.
example ``re2c:YYFILL:naked`` configuration for ``YYFILL``.
``re2c:bit-vectors``, ``re2c:flags:bit-vectors``, ``re2c:flags:b``
Same as the ``--bit-vectors`` option, but can be configured on per-block
basis.
``re2c:captures``, ``re2c:leftmost-captures``
Same as the ``--leftmost-captures`` option, but can be configured on
per-block basis.
``re2c:captvars``, ``re2c:leftmost-captvars``
Same as the ``--leftmost-captvars`` option, but can be configured on
per-block basis.
``re2c:case-insensitive``, ``re2c:flags:case-insensitive``
Same as the ``--case-insensitive`` option, but can be configured on
per-block basis.
@@ -51,6 +60,10 @@
threshold that triggers the generation of jump tables instead of nested
``if`` statements and bitmaps. The default value is ``9``.
``re2c:cond:abort``
If set to a positive integer value, the default case in the generated
condition dispatch aborts program execution.
``re2c:cond:goto``
Specifies a piece of code used for the autogenerated shortcut rules ``:=>``
in conditions. The default is ``goto @@;``.
@@ -85,129 +98,6 @@
Same as the ``--debug-output`` option, but can be configured on per-block
basis.
``re2c:define:YYBACKUP``
Defines generic API primitive ``YYBACKUP`` (see the API primitives section).
``re2c:define:YYBACKUPCTX``
Defines generic API primitive ``YYBACKUPCTX`` (see the API primitives
section).
``re2c:define:YYCONDTYPE``
Defines ``YYCONDTYPE`` (see the API primitives section).
``re2c:define:YYCTYPE``
Defines ``YYCTYPE`` (see the API primitives section).
``re2c:define:YYCTXMARKER``
Defines API primitive ``YYCTXMARKER`` (see the API primitives section).
``re2c:define:YYCURSOR``
Defines API primitive ``YYCURSOR`` (see the API primitives section).
``re2c:define:YYDEBUG``
Defines API primitive ``YYDEBUG`` (see the API primitives section).
``re2c:define:YYFILL``
Defines API primitive ``YYFILL`` (see the API primitives section).
``re2c:define:YYFILL@len``
Specifies the sigil used for argument substitution in ``YYFILL``
definition. Defaults to ``@@``.
Overrides the more generic ``re2c:api:sigil`` configuration.
``re2c:define:YYFILL:naked``
Overrides the more generic ``re2c:api:style`` configuration for ``YYFILL``.
Zero value corresponds to free-form API style.
``re2c:define:YYGETCONDITION``
Defines API primitive ``YYGETCONDITION`` (see the API primitives section).
``re2c:define:YYGETCONDITION:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYGETCONDITION``. Zero value corresponds to free-form API style.
``re2c:define:YYGETSTATE``
Defines API primitive ``YYGETSTATE`` (see the API primitives section).
``re2c:define:YYGETSTATE:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYGETSTATE``. Zero value corresponds to free-form API style.
``re2c:define:YYLESSTHAN``
Defines generic API primitive ``YYLESSTHAN`` (see the API primitives
section).
``re2c:define:YYLIMIT``
Defines API primitive ``YYLIMIT`` (see the API primitives section).
``re2c:define:YYMARKER``
Defines API primitive ``YYMARKER`` (see the API primitives section).
``re2c:define:YYMTAGN``
Defines generic API primitive ``YYMTAGN`` (see the API primitives section).
``re2c:define:YYMTAGP``
Defines generic API primitive ``YYMTAGP`` (see the API primitives section).
``re2c:define:YYPEEK``
Defines generic API primitive ``YYPEEK`` (see the API primitives section).
``re2c:define:YYRESTORE``
Defines generic API primitive ``YYRESTORE`` (see the API primitives
section).
``re2c:define:YYRESTORECTX``
Defines generic API primitive ``YYRESTORECTX`` (see the API primitives
section).
``re2c:define:YYRESTORETAG``
Defines generic API primitive ``YYRESTORETAG`` (see the API primitives
section).
``re2c:define:YYSETCONDITION``
Defines API primitive ``YYSETCONDITION`` (see the API primitives section).
``re2c:define:YYSETCONDITION@cond``
Specifies the sigil used for argument substitution in ``YYSETCONDITION``
definition. The default value is ``@@``.
Overrides the more generic ``re2c:api:sigil`` configuration.
``re2c:define:YYSETCONDITION:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYSETCONDITION``. Zero value corresponds to free-form API style.
``re2c:define:YYSETSTATE``
Defines API primitive ``YYSETSTATE`` (see the API primitives section).
``re2c:define:YYSETSTATE@state``
Specifies the sigil used for argument substitution in ``YYSETSTATE``
definition. The default value is ``@@``.
Overrides the more generic ``re2c:api:sigil`` configuration.
``re2c:define:YYSETSTATE:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYSETSTATE``. Zero value corresponds to free-form API style.
``re2c:define:YYSKIP``
Defines generic API primitive ``YYSKIP`` (see the API primitives section).
``re2c:define:YYSHIFT``
Defines generic API primitive ``YYSHIFT`` (see the API primitives section).
``re2c:define:YYSHIFTMTAG``
Defines generic API primitive ``YYSHIFTMTAG`` (see the API primitives
section).
``re2c:define:YYSHIFTSTAG``
Defines generic API primitive ``YYSHIFTSTAG`` (see the API primitives
section).
``re2c:define:YYSTAGN``
Defines generic API primitive ``YYSTAGN`` (see the API primitives section).
``re2c:define:YYSTAGP``
Defines generic API primitive ``YYSTAGP`` (see the API primitives section).
``re2c:empty-class``, ``re2c:flags:empty-class``
Same as the ``--empty-class`` option, but can be configured on per-block
basis.
@@ -236,6 +126,9 @@
default value is ``-1`` (``$`` rule is not used). Other possible values
include all valid code units. Only decimal numbers are recognized.
``re2c:fn:sep``
Specifies separator used in ``YYFN`` elements (defaults to semicolon).
``re2c:header``, ``re2c:flags:type-header``, ``re2c:flags:t``
Specifies the name of the generated header file relative to the directory of
the output file. Same as the ``--header`` option except that the file path
@@ -250,6 +143,10 @@
Specifies the minimum amount of indentation to use. The default value is
zero. The value should be a non-negative integer number.
``re2c:invert-captures``
Same as the ``--invert-captures`` option, but can be configured on per-block
basis.
``re2c:label:prefix``, ``re2c:labelprefix``
Specifies the prefix used for DFA state labels. The default is ``yy``.
@@ -277,6 +174,10 @@
``re2c:lookahead``, ``re2c:flags:lookahead``
Deprecated (see the deprecated ``--no-lookahead`` option).
``re2c:monadic``
If set to non-zero, the generated lexer will use monadic notation (this
configuration is specific to Haskell).
``re2c:nested-ifs``, ``re2c:flags:nested-ifs``, ``re2c:flags:s``
Same as the ``--nested-ifs`` option, but can be configured on per-block
basis.
@@ -285,18 +186,27 @@
Same as the ``--posix-captures`` option, but can be configured on per-block
basis.
``re2c:posix-captvars``
Same as the ``--posix-captvars`` option, but can be configured on per-block
basis.
``re2c:tags``, ``re2c:flags:tags``, ``re2c:flags:T``
Same as the ``--tags`` option, but can be configured on per-block basis.
``re2c:tags:expression``
Specifies the expression used for tag variables.
By default re2c generates expressions of the form ``yyt<N>``. This might
By default |re2c| generates expressions of the form ``yyt<N>``. This might
be inconvenient, for example if tag variables are defined as fields in a
struct. All occurrences of ``@@{tag}`` or ``@@`` are replaced with the
actual tag name. For example, ``re2c:tags:expression = "s.@@";`` results
in expressions of the form ``s.yyt<N>`` in the generated code.
See also ``re2c:api:sigil`` configuration.
``re2c:tags:negative``
Specifies the constant expression that is used for negative tag value
(typically this would be ``-1`` if tags are integer offsets in the input
string, or null pointer if they are pointers).
``re2c:tags:prefix``
Specifies the prefix for tag variable names. The default is ``yyt``.
@@ -306,20 +216,20 @@
set). This configuration does not affect code generation: its purpose is to
verify that the sentinel is not allowed in the middle of a rule, and ensure
that the lexer won't read past the end of buffer. The default value is
`-1`` (in that case re2c assumes that the sentinel is zero, which is the
`-1`` (in that case |re2c| assumes that the sentinel is zero, which is the
most common case). Only decimal numbers are recognized.
``re2c:state:abort``
If set to a positive integer value, changes the default case in
``YYGETSTATE`` switch: by default it aborts the program, and an explicit
``-1`` case contains transition to the start of the block.
If set to a positive integer value, the default case in the generated
state dispatch aborts program execution, and an explicit ``-1`` case
contains transition to the start of the block.
``re2c:state:nextlabel``
Controls if the ``YYGETSTATE`` switch is followed by an ``yyNext`` label
(the default value is zero, which corresponds to no label).
Alternatively one can use ``re2c:label:start`` to generate a specific start
label, or an explicit ``getstate:re2c`` directive to generate the
``YYGETSTATE`` switch separately from the lexer block.
label, or an explicit ``getstate`` block to generate the ``YYGETSTATE``
switch separately from the lexer block.
``re2c:unsafe``, ``re2c:flags:unsafe``
Same as the ``--no-unsafe`` option, but can be configured on per-block
@@ -328,42 +238,188 @@
``YYPEEK``. The default is non-zero (wrappers are generated).
This configuration is specific to Rust.
``re2c:variable:yyaccept``
Specifies the name of the ``yyaccept`` variable (see the API primitives
section).
``re2c:YYBACKUP``, ``re2c:define:YYBACKUP``
Defines generic API primitive ``YYBACKUP``.
``re2c:variable:yybm``
Specifies the name of the ``yybm`` variable (used for bitmaps).
``re2c:YYBACKUPCTX``, ``re2c:define:YYBACKUPCTX``
Defines generic API primitive ``YYBACKUPCTX``.
``re2c:variable:yybm:hex``, ``re2c:yybm:hex``
``re2c:YYCONDTYPE``, ``re2c:define:YYCONDTYPE``
Defines API primitive ``YYCONDTYPE``.
``re2c:YYCTYPE``, ``re2c:define:YYCTYPE``
Defines API primitive ``YYCTYPE``.
``re2c:YYCTXMARKER``, ``re2c:define:YYCTXMARKER``
Defines API primitive ``YYCTXMARKER``.
``re2c:YYCURSOR``, ``re2c:define:YYCURSOR``
Defines API primitive ``YYCURSOR``.
``re2c:YYDEBUG``, ``re2c:define:YYDEBUG``
Defines API primitive ``YYDEBUG``.
``re2c:YYFILL``, ``re2c:define:YYFILL``
Defines API primitive ``YYFILL``.
``re2c:YYFILL@len``, ``re2c:define:YYFILL@len``
Specifies the sigil used for argument substitution in ``YYFILL``
definition. Defaults to ``@@``.
Overrides the more generic ``re2c:api:sigil`` configuration.
``re2c:YYFILL:naked``, ``re2c:define:YYFILL:naked``
Overrides the more generic ``re2c:api:style`` configuration for ``YYFILL``.
Zero value corresponds to free-form API style.
``re2c:YYFN``
Defines API primitive ``YYFN``.
``re2c:YYINPUT``
Defines API primitive ``YYINPUT``.
``re2c:YYGETCOND``, ``re2c:define:YYGETCONDITION``
Defines API primitive ``YYGETCOND``.
``re2c:YYGETCOND:naked``, ``re2c:define:YYGETCONDITION:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYGETCOND``. Zero value corresponds to free-form API style.
``re2c:YYGETSTATE``, ``re2c:define:YYGETSTATE``
Defines API primitive ``YYGETSTATE``.
``re2c:YYGETSTATE:naked``, ``re2c:define:YYGETSTATE:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYGETSTATE``. Zero value corresponds to free-form API style.
``re2c:YYGETACCEPT``, ``re2c:define:YYGETACCEPT``
Defines API primitive ``YYGETACCEPT``.
``re2c:YYLESSTHAN``, ``re2c:define:YYLESSTHAN``
Defines generic API primitive ``YYLESSTHAN``.
``re2c:YYLIMIT``, ``re2c:define:YYLIMIT``
Defines API primitive ``YYLIMIT``.
``re2c:YYMARKER``, ``re2c:define:YYMARKER``
Defines API primitive ``YYMARKER``.
``re2c:YYMTAGN``, ``re2c:define:YYMTAGN``
Defines generic API primitive ``YYMTAGN``.
``re2c:YYMTAGP``, ``re2c:define:YYMTAGP``
Defines generic API primitive ``YYMTAGP``.
``re2c:YYPEEK``, ``re2c:define:YYPEEK``
Defines generic API primitive ``YYPEEK``.
``re2c:YYRESTORE``, ``re2c:define:YYRESTORE``
Defines generic API primitive ``YYRESTORE``.
``re2c:YYRESTORECTX``, ``re2c:define:YYRESTORECTX``
Defines generic API primitive ``YYRESTORECTX``.
``re2c:YYRESTORETAG``, ``re2c:define:YYRESTORETAG``
Defines generic API primitive ``YYRESTORETAG``.
``re2c:YYSETCOND``, ``re2c:define:YYSETCONDITION``
Defines API primitive ``YYSETCOND``.
``re2c:YYSETCOND@cond``, ``re2c:define:YYSETCONDITION@cond``
Specifies the sigil used for argument substitution in ``YYSETCOND``
definition. The default value is ``@@``.
Overrides the more generic ``re2c:api:sigil`` configuration.
``re2c:YYSETCOND:naked``, ``re2c:define:YYSETCONDITION:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYSETCOND``. Zero value corresponds to free-form API style.
``re2c:YYSETSTATE``, ``re2c:define:YYSETSTATE``
Defines API primitive ``YYSETSTATE``.
``re2c:YYSETSTATE@state``, ``re2c:define:YYSETSTATE@state``
Specifies the sigil used for argument substitution in ``YYSETSTATE``
definition. The default value is ``@@``.
Overrides the more generic ``re2c:api:sigil`` configuration.
``re2c:YYSETSTATE:naked``, ``re2c:define:YYSETSTATE:naked``
Overrides the more generic ``re2c:api:style`` configuration for
``YYSETSTATE``. Zero value corresponds to free-form API style.
``re2c:YYSETACCEPT``, ``re2c:define:YYSETACCEPT``
Defines API primitive ``YYSETACCEPT``.
``re2c:YYSKIP``, ``re2c:define:YYSKIP``
Defines generic API primitive ``YYSKIP``.
``re2c:YYSHIFT``, ``re2c:define:YYSHIFT``
Defines generic API primitive ``YYSHIFT``.
``re2c:YYCOPYMTAG``, ``re2c:define:YYCOPYMTAG``
Defines generic API primitive ``YYCOPYMTAG``.
``re2c:YYCOPYSTAG``, ``re2c:define:YYCOPYSTAG``
Defines generic API primitive ``YYCOPYSTAG``.
``re2c:YYSHIFTMTAG``, ``re2c:define:YYSHIFTMTAG``
Defines generic API primitive ``YYSHIFTMTAG``.
``re2c:YYSHIFTSTAG``, ``re2c:define:YYSHIFTSTAG``
Defines generic API primitive ``YYSHIFTSTAG``.
``re2c:YYSTAGN``, ``re2c:define:YYSTAGN``
Defines generic API primitive ``YYSTAGN``.
``re2c:YYSTAGP``, ``re2c:define:YYSTAGP``
Defines generic API primitive ``YYSTAGP``.
``re2c:yyaccept``, ``re2c:variable:yyaccept``
Defines API primitive ``yyaccept``.
``re2c:yybm``, ``re2c:variable:yybm``
Defines API primitive ``yybm``.
``re2c:yybm:hex``, ``re2c:variable:yybm:hex``
If set to nonzero, bitmaps for the ``--bit-vectors`` option are generated
in hexadecimal format. The default is zero (bitmaps are in decimal format).
``re2c:variable:yych``
Specifies the name of the ``yych`` variable (see the API primitives
section).
``re2c:yych``, ``re2c:variable:yych``
Defines API primitive ``yych``.
``re2c:variable:yych:emit``, ``re2c:yych:emit``
``re2c:yych:emit``, ``re2c:variable:yych:emit``
If set to zero, ``yych`` definition is not generated.
The default is non-zero.
``re2c:variable:yych:conversion``, ``re2c:yych:conversion``
If set to non-zero, re2c automatically generates a conversion to ``YYCTYPE``
``re2c:yych:conversion``, ``re2c:variable:yych:conversion``
If set to non-zero, |re2c| automatically generates a conversion to ``YYCTYPE``
every time ``yych`` is read. The default is to zero (no conversion).
``re2c:variable:yyctable``
Specifies the name of the ``yyctable`` variable (the jump table generated
for ``YYGETCONDITION`` switch with ``--computed-gotos`` option).
``re2c:yych:literals``, ``re2c:variable:yych:literals``
Specifies the form of literals that ``yych`` is matched against. Possible
values are: ``char`` (character literals in single quotes, non-printable
ones use escape sequences that start with backslash), ``hex`` (hexadecimal
integers) and ``char_or_hex`` (a mixture of both, character literals for
printable characters and hexadecimal integers for others).
``re2c:variable:yytarget``
Specifies the name of the ``yytarget`` variable.
``re2c:yyctable``, ``re2c:variable:yyctable``
Defines API primitive ``yyctable``.
``re2c:variable:yystable``
``re2c:yynmatch``, ``re2c:variable:yynmatch``
Defines API primitive ``yynmatch``.
``re2c:yypmatch``, ``re2c:variable:yypmatch``
Defines API primitive ``yypmatch``.
``re2c:yytarget``, ``re2c:variable:yytarget``
Defines API primitive ``yytarget``.
``re2c:yystable``, ``re2c:variable:yystable``
Deprecated.
``re2c:variable:yystate``
Specifies the name of the ``yystate`` variable (used with the
``--loop-switch`` option to store the current DFA state).
``re2c:yystate``, ``re2c:variable:yystate``
Defines API primitive ``yystate``.
``re2c:yyfill``, ``re2c:variable:yyfill``
Defines API primitive ``yyfill``.
``re2c:yyfill:check``
If set to zero, suppresses the generation of pre-``YYFILL`` check for the
@@ -384,5 +440,5 @@
If set to zero, suppresses the generation of parameter passed to ``YYFILL``.
The parameter is the minimum number of characters that must be supplied.
Defaults to non-zero (the parameter is generated).
This configuration can be overridden with ``re2c:define:YYFILL:naked`` or
This configuration can be overridden with ``re2c:YYFILL:naked`` or
``re2c:api:style``.
+17
View File
@@ -0,0 +1,17 @@
Here is a full list of directives supported by |re2c|:
``!use:<name>;``
An in-block use directive that merges a previously defined rules block with
the specified name into the current block. Named definitions, configurations
and rules of the referenced block are added to the current ones. Conflicts
between overlapping rules and configurations are resolved in the usual way:
the first rule takes priority, and the latest configuration overrides the
preceding ones. One exception is the special rules ``*``, ``$`` and ``<!>``
for which a block-local definition always takes priority. A use directive
can be placed anywhere inside of a block, and multiple use directives are
allowed.
``!include <file>;``
This directive is the same as ``include`` block: it inserts ``<file>``
contents verbatim in place of the durective.

Some files were not shown because too many files have changed in this diff Show More