Compare commits

...
111 Commits
Author SHA1 Message Date
Ulya Trofimovich 9682dcd2b2 Github Actions: try 'oracle-openjdk' as 'redhat' has no macOS support. 2026-09-06 22:07:26 +01:00
Ulya Trofimovich 745a042652 Github Actions: also fix JDK version.
Pick the most recent one supported by 'redhat' distribution: 21.
2026-09-06 21:49:30 +01:00
Ulya Trofimovich b1720e831c Github Actions: fix infra error with setup-java@v6.
Pick 'redhat' distribution that packages OpenJDK, as the previously used
'adopt' distribution is no longer supported with setup-java@v6.
2026-09-06 21:44:31 +01:00
dependabot[bot] 1022a1cb0f Actions(deps): Bump actions/setup-java from 5 to 6
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 5 to 6.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-31 21:03:12 +01:00
Ulya Trofimovich e485c5d572 Release 4.6. 2026-08-29 22:26:02 +01:00
Ulya Trofimovich 957bc5359b Update CHANGELOG for release 4.6. 2026-08-29 22:15:34 +01:00
Ulya Trofimovich c117b7d1c9 Revert "Avoid new features added in 4.0 in C/C++ examples."
This reverts commit 5cea17c8fe.

Reason for revert: enough time has passed and most distributions have
updated to re2c version 4.0 or higher.

This fixes bug #507 "Update C/C++ examples".
2026-08-29 21:20:36 +01:00
Chun Pong Lam bda3544af9 Add Zig computed-continue optimization 2026-08-26 14:46:23 +01:00
dependabot[bot] dcc7411099 Actions(deps): Bump actions/setup-python from 6 to 7
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 6 to 7.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 19:47:54 +01:00
94xhn 9baaabbf4a Fix negative char2class[] index on high-byte input in libre2c DFA matchers
lib/regexec_dfa.cc (regexec_dfa(), regparse_dfa()) and
lib/regexec_dfa_multipass.cc (forward_pass(), shared by
regexec_dfa_multipass<>, regparse_dfa_multipass<>, and
regtstring_dfa_multipass<>) read the next input character as
`*p++` into a plain `int32_t`/`chr`, then use it directly to index
`preg->char2class[]`. On platforms where `char` is signed (the
default for x86/x64), any input byte >= 0x80 sign-extends to a
negative value, so `char2class[c]` reads before the start of the
257-element `size_t` array allocated in regcomp() -- an
out-of-bounds heap read (observed to segfault in a minimal
regcomp()/regexec() reproduction with a high-byte input string).

Fix by reading the byte through `static_cast<uint8_t>(...)` before
using it as an index, matching the pattern already used for the
same purpose in the NFA matchers (regexec_nfa_leftmost.cc,
regexec_nfa_leftmost_trie.cc, regexec_nfa_posix.cc,
regexec_nfa_posix_trie.cc). The `== 0` end-of-input check is
unaffected since 0 is unchanged by the cast.

Verified: rebuilt libre2c (RE2C_BUILD_LIBS=ON) and confirmed
test_libre2c passes before and after the change; a targeted
regcomp()/regexec() check over all 254 non-newline byte values
0x01-0xFF segfaults on the pre-fix code and passes cleanly after
the fix.
2026-07-19 22:51:50 +01:00
dependabot[bot] f1a46ca73a Actions(deps): Bump actions/cache from 5 to 6
Bumps [actions/cache](https://github.com/actions/cache) from 5 to 6.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-29 21:09:51 +01:00
dependabot[bot] fccdffc979 Actions(deps): Bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-24 21:49:44 +01:00
Ulya Trofimovich ae610e4ecf CMakePresets.json: update VS version.
The former VS 17 2022 version is no longer supported by Github Actions.
2026-06-23 21:17:58 +01:00
Ryan Carsten Schmidt 86137ce914 Use std::max_align_t instead of max_align_t.
Fixes build with old versions of clang.
2026-04-24 21:26:36 +01:00
Ulya Trofimovich c028cdd42b TDFA paper: apply corrections by Lisa Felidae. 2026-03-29 22:09:29 +01:00
Ulya Trofimovich 8a44906f5c Release 4.5.1. 2026-03-27 21:29:04 +00:00
Ulya Trofimovich 3122b9a415 Update CHANGELOG for release 4.5.1. 2026-03-27 21:09:25 +00:00
Ulya Trofimovich 2ab394e9d5 Docs: mention the new include files for Unicode blocks and properties. 2026-03-27 21:06:50 +00:00
Ulya Trofimovich e63ad223f5 Add missing include files to the distribution.
This fixes #573.
2026-03-27 21:01:55 +00:00
Ulya Trofimovich 3e3b91d75a Release 4.5. 2026-03-23 20:55:16 +00:00
Ulya Trofimovich 7059b54eb9 Update CHANGELOG for release 4.5. 2026-03-22 22:39:16 +00:00
Ulya Trofimovich c88a723fc4 Remove obsolete Unicode files generator. 2026-03-22 22:22:51 +00:00
Ulya Trofimovich 44d56c2804 Implement Unicode case mapping for case-insensitive string literals.
Do this for all Unicode encodings (UTF8, UTF16 and UTF32), and also for UCS2.

This addresses bug #235 "Unicode character classes".
2026-03-22 22:22:51 +00:00
Ulya Trofimovich 4685c639cd Clean up Unicode generator using tags instead of blocks. 2026-03-22 22:22:51 +00:00
Ulya Trofimovich 6a71463d6d Add derived Unicode properties to include/unicode_properties.re. 2026-03-22 22:22:51 +00:00
Ulya Trofimovich 79596e186d Generate include file for Unicode properties.
This partially addresses bug #235 "Unicode character classes".
2026-03-22 22:22:51 +00:00
Ulya Trofimovich 94d1ceb2e9 Update Unicode files to the latest standard. 2026-03-22 22:22:51 +00:00
Ulya Trofimovich e4ba9a90b2 Remove Unicode category tests for encoding policies "fail" and "substitute".
They mostly duplicate the "ignore" policy (except for the categories that
include surrogates). These policies are also covered by the Unicode block tests.
2026-03-22 22:22:50 +00:00
Ulya Trofimovich fce0e9cbd1 Implement generation of Unicode categories tests in the new generator. 2026-03-22 22:22:50 +00:00
Ulya Trofimovich 8fcbced4e4 Clean up Unicode generator code (split large functions). 2026-03-22 22:22:50 +00:00
Ulya Trofimovich 92a98bcf1e Implement generation of Unicode blocks tests in the new generator.
Tests have changed due to the changes in the Unicode standard - the old test
were generated using Haskell "Charset" library, which supports unknown version
of Blocks.txt (none of the existing version matches exactly, but Unicode 4.0 is
somewhat close). There are also other changes in the tests, mostly
simplification and cleanup of the generated code.
2026-03-22 22:22:50 +00:00
Ulya Trofimovich a76b9f592c Use uint16_t for UTF-16 code points in utf16::{lead,trail}_surr.
Previously uint32_t was used to avoid static_cast on 16-bit results of
arithmetic operations on 32-bit values.
2026-03-22 22:22:50 +00:00
Ulya Trofimovich c30687f0f1 Use uint8_t for UTF-8 code points in utf8::rune_to_bytes.
Previously uint32_t was used to avoid static_cast on 8-bit results of
arithmetic operations on 32-bit values.
2026-03-22 22:22:50 +00:00
Ulya Trofimovich dd05aab240 Implement new generator for unicode_blocks.re.
The new generator is based on the official Blocks.txt file from the unicode.org
website. The generated result has changed; it's unclear why some of the blocks
are missing in the Haskell "Charset" library - most likely the library was not
updated for Unicode 15.1.0 (although the categories' definitions correspond to
Unicode 15.1.0).

This partially addresses bug #235 "Unicode character classes".
2026-03-22 22:22:50 +00:00
Ulya Trofimovich 5b0e960177 Add Unicode include file unicode_blocks.re.
Don't use it in auto generated tests, because that creates a problem with
include paths: they are relative to the test directory, which makes the
error messages different based on the build directory (so the tests fail).

Use the old generator based on haskell "Charset" library in order to avoid
changes in the generated code - the library has some discrepancies with
https://unicode.org/Public/15.1.0/ucd/Blocks.txt.

Update test results - the changes have been verified with
test/__run_unicode_tests.sh.

This partially addresses bug #235 "Unicode character classes".
2026-03-22 22:22:50 +00:00
Ulya Trofimovich 04e7048069 Implement new generator for unicode_categories.re.
The new generator is based on the official UnicodeData.txt file from the
unicode.org website. After some experimentation, I found that the the
Unicode standard supported by the previously used Haskell "Charset" library
is 15.1.0, so this is the version used in the new generator. The generated
include file unicode_categories.re is identical to the old one, which
verifies correctness of the new generator.

This partially addresses bug #235 "Unicode character classes".
2026-03-22 22:22:50 +00:00
Ulya Trofimovich a92dad12d8 Render characters compactly in Unicode header and tests.
Previously edge cases like 0xFF were rendered as \u0ff rather than \xff.

The difference in the generated files was verified with:
  `git diff --word-diff=color --word-diff-regex='-?\\[a-zA-Z0-9]+'`
2026-03-22 22:22:50 +00:00
Ulya Trofimovich 0011cab9f9 Render one-character ranges compactly in Unicode header and tests.
Previously even if lower and upper characters were the same, the range
would still be rendered with a dash rather than a single character.
This commit removes useless duplication.

The difference in the generated files was verified with:
  `git diff --word-diff=color --word-diff-regex='-?\\[a-zA-Z0-9]+'`
2026-03-22 22:22:50 +00:00
Ulya Trofimovich f1694c513f Regenerate Unicode tests and include header to support a newer standard.
Regenerate files using haskell script test/encodings/unicode_groups.hs
that is based on Data.Charset library (charser-0.3.12 package). The
script generates tests in test/unicode directory inplace and include
file unicode_categories.re.inc that needs to be copied to
include/unicode_categories.re.

Update test results. As there are substantial changes in the standard,
updates are also nontrivial. They have been verified with
test/__run_unicode_tests.sh.

The example for C was werified with examples/c/__run_all.sh scripts.
2026-03-22 22:22:50 +00:00
dependabot[bot] 55802e3b40 Actions(deps): Bump actions/upload-artifact from 6 to 7
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-02 11:13:01 +00:00
Ulya Trofimovich 18fc5091b9 Add tests for #571. 2026-02-03 21:48:21 +00:00
Ulya Trofimovich febeb97793 Fix null pointer dereference when actions are used without rules.
Null pointer dereference happened because the root TNFA state was null:
there were no rules for a block, but determinization still happened.

In this case re2c should emit an error and never even attempt
determinization. It was properly handled for blocks with start
conditions, but not for normal blocks.

This addresses #571 "[Bug] Segmentation Fault (NULL Dereference) in
re2c::closure_leftmost_dfs during determinization".
2026-02-03 21:33:11 +00:00
Ulya Trofimovich 04f1424210 TDFA paper: apply corrections by https://github.com/Raekye. 2026-01-16 21:50:29 +00:00
Ulya Trofimovich 1f8d826558 TDFA paper: apply corrections by Lisa Felidae. 2026-01-16 21:50:29 +00:00
Ulya Trofimovich 1dc02f7b70 Dot: use "dashed" style for non-consuming states.
This addresses bug #569 "Invalid DFA in -D output".
2025-12-28 14:12:10 +00:00
Gui Andrade 37350f906c [re2c.bzl] Always pass --no-generation-date
This prevents non-deterministic file generation which can cause a lot of issues in Bazel.
2025-12-23 21:00:53 +00:00
Ulya Trofimovich 8c758c7649 Release 4.4. 2025-12-20 20:36:43 +00:00
Ulya Trofimovich d46322fb89 Update CHANGELOG for release 4.4. 2025-12-20 13:14:52 +00:00
Ulya Trofimovich 5811f5ad65 Docs: add description of YYEND, code:yyend and .yyfill.enable. 2025-12-17 22:56:50 +00:00
Ulya Trofimovich ee0b1f6daf Docs: regenerate following recent changes in examples. 2025-12-17 21:53:03 +00:00
Ulya Trofimovich 82915e38ba Add tests for generalized $.
Note: for Haskell and monadic lexers in general I considered adding `yyend`
variable in order to allow monadic YYEND (similar to the existing `yyfill`
variable). However, this is not yet useful even for Haskell, because it's always
easy to store the end in a record field and define YYEND as a simple non-monadic
comparison expression. It won't be late to add `yyend` variable later in a
backwards compatible way (if the variable is empty, generate code the old way,
otherwise do it the new way), therefore I decided to postpone `yyend`addition
until such time when it's needed.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 67f50f6907 Allow tags after $ in regular expressions.
This is necessary in order to accommodate negative tags, which are added at the
end of the other alternative (the one that doesn't have tags). During TNFA
construction $ is moved past negative tags and placed immediately before the
final TNFA state. This ensures that there are no tags on the $-transition and we
don't have to append tag operations to incoming transitions when getting rid of
the $-transitions in TDFA.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich bc5c3022d1 Rework detection of shadowed end-of-input rules.
Do it right after TDFA construction. This is only strictly necessary for
self-shadowed rules, but it's better to handle all end-of-input rules
together (especially since the previous analysis was still a hack in
the reversed-TDFA structure).
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 827682202e Fix handling of self-shadowed end-of-input rules.
Also, add tests for generalized end-of-input symbol $ and tags.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 6fcfa14e15 Fix YYEND generation for "bounds checks with padding" method.
Generate YYEND before YYFILL. This order is makes sense because YYEND should be
faster than YYFILL. In fact, it is the only possible order, as YYFILL may not
return if it's impossible to supply enough input characters.

Don't generate YYEND on transition in the case of "sentinel with bounds checks"
method; instead, generate it in state. This doesn't make any difference on the
tests because YYEND is only needed in the "end" states that have a single
transition.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 0b5185c03a Allow $ to be used with any end-of-input handling method.
Prevously end-of-input symbol $ was only allowed with "sentinel with
bounds check" method (when `re2c:eof` configuration is set to a
nonnegative value). This commit removes the above restriction and
enables YYEND checks for all end-of-input handling methods. Code
generation is not quite right yet, as in some of the cases YYEND checks
are emitted after YYFILL, while they should go before it.

Internally the main challengege was adding $-transitions in TDFA for all
end-of-input handling methods, and to hide them when necessary depending
on the method. E.g. -Wunreachable-rules analysis must ignore them except
for the $-final states, unless "sentinel with bounds checks" method is
used.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 07d6f5f7f5 Initial implementation of YYEND check.
For the moment, YYEND is only supported for the "bounds checks with sentinel"
end-of-input handling method (the case of `re2c:eof` configuration). In this
case states that have transitions on symbos do not need YYEND check, as they
have the sentinel transition with YYLESSTHAN / YYFILL pair.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich ab2d4b2504 Change default implementation of YYEND to be like YYLESSTHAN.
Namely, use `YYLIMIT <= YYCURSOR` rather than `YYLIMIT == YYCURSOR`.

The goal is to bridge the gap between YYEND and YYLESSTHAN in the case
of `re2c:eof`. $-final states that have outgoing transitions defer the
end of input check until matching `re2c:eof` symbol range on transition
(and then use YYLESSTHAN in the same way as non-$-final state would do).
But $-final states that are terminal (have no outgoing transitions on
symbols) use YYEND.

We can only bridge this gap in simple / record (not generic) API, and
only if YYFILL is disabled. Otherwise it has to be YYEND and YYLESSTHAN
as macros, and the distinction remains.

This commit does not compromise correctness of the generated code, as
YYCURSOR cannot read past YYLIMIT in a correct lexer, so if it was
correct before this commit it will be as correct after it.
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 299bfc7fe0 Add a new API primitive YYEND.
Also, add the corresponding syntax file configuration `code:yyend` and
syntax file conditional `.yyfill.enable`.

The new API primitive will be used in the implementation of generalized
$ (the end of input symbol). If YYFILL is disabled, and the API used is
either simple or record (not generic API), then YYEND defaults to a
comparison `YYCURSOR == YYLIMIT`, otherwise it remains a macro to be
defined by the user.

We don't use a combination of YYLESSTHAN and YYFILL instead of the new
primitive for a number of reasons:

  - Using YYEND allows us to unify all codegen cases instead of having
    many different implementations based on YYFILL, storable state,
    generic API, etc.

  - Involving YYFILL would add runtime overhead: a possible function
    call instead of a simple inplace check, useless reiteration via
    YYFILL label (which is currently not even generated in these states)
2025-12-17 21:44:14 +00:00
Ulya Trofimovich 2ad0561e4f Move re2c:yyfill config in syntax files closer to the yyfill group. 2025-12-17 21:44:14 +00:00
Ulya Trofimovich 59677b5eb4 Change precedence for conflicting end of input rules.
This change breaks backwards compatibility. This is intentional, following
a period when -Wdeprecate-eof-rule has been a warning by default, now the
default is an error (-Werror-deprecate-eof-rule).

There are code generation changes: end of input rule is now handled as a
normal rue with positional precedence / inheritance order (it is no longer
a special rule like the default rule *). The changes in the code can be
observed with -Wno-error-deprecate-eof-rule (applied to the tests).
2025-12-17 21:44:14 +00:00
dependabot[bot] 82bfcce637 Actions(deps): Bump actions/cache from 4 to 5
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-15 20:52:09 +00:00
dependabot[bot] 6eb9718a67 Actions(deps): Bump actions/upload-artifact from 5 to 6
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 5 to 6.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-15 09:54:01 +00:00
Ulya Trofimovich 5513aff4c0 Revert "Go backend: add test for signed YYCTYPE."
This reverts commit b0d740994c.

Reason for revert: don't keep signed YYCTYPE examples for languages
that don't allow the user to do the incorrect thing (Go, Swift forbid
comparison of signed 8-bit type to literals that overflow it, like 0xFF;
Python, JS, OCaml don't even have a signed 8-bit type).
2025-12-09 21:55:02 +00:00
Ulya Trofimovich 43c7512c31 V backend: add test for signed YYCTYPE.
There's no need to fix examples, as they use `u8` and `u32`.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-08 21:40:40 +00:00
Ulya Trofimovich 28cca31af9 V backend: more updates in the examples/tests for the new version of V. 2025-12-08 21:21:11 +00:00
Ulya Trofimovich e98dbd359a V backend: specify type in variable initializer.
The code without exact types in variable initializers used to compile
in older versions of V, but not anymore.
2025-12-08 20:39:53 +00:00
Ulya Trofimovich eece38b1e6 Zig backend: add test for signed YYCTYPE.
There's no need to fix examples, as they use `u8` and `u32`.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-07 13:51:57 +00:00
Ulya Trofimovich 7553c68cb4 Zig backend: port one remaining test to ZIg 0.15. 2025-12-07 13:38:06 +00:00
Ulya Trofimovich 69ffc41706 Zig backend: port examples to Zig 0.15.
This fixes bug #565 "Migrate Zig examples to Zig 0.15".
2025-12-06 22:48:16 +00:00
Ulya Trofimovich 1a26160b69 Java backend: make YYCTYPE/YYPEEK work correctly with signed bytes.
Use `int` instead of `byte` for `YYCTYPE`, as `byte` is signed and therefore
incapable of holding the full range of literals generated by re2c (e.g. 0xFF).

use `Byte.toUnsignedInt` in YYPEEK in order to convert correctly from signed
bytes to `yych` of type `int`. Add a test that demonstrates the need for this.

Using `char` is fine, as it is 2-byte in Java and thus capable of holding
ASCII and UTF-8 range used in the examples.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-03 22:17:28 +00:00
Ulya Trofimovich 0b7572c30d Haskell backend: use unsigned YYCTYPE in examples. Add a test.
Only one example required fixing `Int` -> `Word`, others use `Word8`.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-02 22:14:51 +00:00
Ulya Trofimovich 5393573711 Rust backend: add test for signed YYCTYPE.
The generated code compiles only with `#[allow(overflowing_literals)]`,
and it requires `re2c:yych:conversion = 1`.

There's no need to fix examples, as they use `u8` and `u32`.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-02 21:32:45 +00:00
Ulya Trofimovich b0d740994c Go backend: add test for signed YYCTYPE.
The generated code for the test does not compile - Go rejects it:
    signed_yyctype.go:34:9: cannot use yyinput[yycursor] (value of type byte)
                            as int8 value in assignment
    signed_yyctype.go:35:14: 0xFF (untyped int constant 255) overflows int8

There's no need to fix examples, as they use `byte` (which is unsigned
8-bit type) or `uint32`.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-02 21:28:17 +00:00
Ulya Trofimovich e2ee1bfa9d D backend: add test for signed YYCTYPE.
There's no need to fix examples, as they use `char` (which is unsigned
8-bit type according to https://dlang.org/spec/type.html#basic-data-types)
or `uint8_t`/`uint32_t`.

This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-12-02 21:23:30 +00:00
Ulya Trofimovich 600717ad6a Fix CHANGELOG formatting. 2025-12-01 22:59:46 +00:00
Ulya Trofimovich af13e1d896 Release 4.3.1. 2025-12-01 22:53:31 +00:00
Ulya Trofimovich f760dccc55 Update CHANGELOG for release 4.3.1. 2025-12-01 22:28:01 +00:00
Ulya Trofimovich 9d76662c22 Regenerate docs. 2025-12-01 22:15:42 +00:00
Ulya Trofimovich 5ed46a79a1 release.sh: Add option --ignore-examples.
This is needed as a last resort to allow releasing re2c on a system where some
of the language toolchains are broken (as it becomes excessively hard to keep
them all working and to keep the examples up to date for languages that don't
care about backwards compatibility, such as Zig).
2025-12-01 22:13:08 +00:00
Ulya Trofimovich dcf934fb33 Allow tags after $ in regular expressions.
This addresses bug #564 "End of input ($) rule deemed invalid when Posix
captures enabled". It is needed t allow implicit capture tags after $ in a
regexp, which was inadvertently forbidden in release 4.3.

It will also be necessary in order to accommodate negative tags added at the
end of alternatives that don't have tags.

During TNFA construction $ is moved past negative tags and placed immediately
before the final TNFA state. This ensures that there are no tags on the
$-transition and we don't have to append tag operations to incoming transitions
when getting rid of the $-transitions in TDFA.
2025-12-01 21:07:53 +00:00
Ulya Trofimovich 55487d4ab8 Fix YYCTYPE to be unsigned in the examples for C/C++. Add a test.
This addresses bug #561 "Incorrectness with ASCII signedness and range
(in C/C++)".
2025-11-26 22:47:09 +00:00
dependabot[bot] 59de285996 Actions(deps): Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-24 10:57:38 +00:00
Ulya Trofimovich da7d8fe924 Use ptrdiff_t instead of non-standard ssize_t.
This fixes the build on windows.
2025-11-20 22:04:41 +00:00
Ulya Trofimovich 325db7adfd Rework handling of conditions that have no rules.
This addresses bug #560 'Illformed C/C++ code due to missing "final"
conditions in generated enumeration'.

After much discussion (see the bug) it was decided that aborting in the initial
state dispatch for conditions without rules doesn't play well with the existing
configuration `re2c:cond:abort`. Some language backends (notably, C/C++ backend)
have it disabled by default, so the general-case default (no abort) would be at
odds with the special-case default for empty conditionss (abort).

This commit takes a different approach: always raise an error on conditions
without rules, but before doing that check if there are any `<*>` rules that
can be merged to them.
2025-11-20 21:21:25 +00:00
Ulya Trofimovich ccb1d45431 Revert "Always explicitly initialize condition enum members."
This reverts commit 34f6e5269f.

Reason for revert: to make sure we don't break existing code, e.g. if
the numeric constants are incompatible with the user-defined enum type.
2025-11-17 22:48:43 +00:00
Ulya Trofimovich deaabdd4ca Fix check for conditions with the same name in goto/label mode.
This check should not compare condition numbers in goto/label mode,
as conditions get renumbered anyway. Previously it used to work because
all numbers were set to zero in goto/label mode, but it was broken by
a recent commit 8a4e4ebd54.

This addresses bug #560 'Illformed C/C++ code due to missing "final"
conditions in generated enumeration'.
2025-11-15 22:37:48 +00:00
Ulya Trofimovich 550451d8b4 Check for conditions that have no rules.
Check that all conditions referenced by `=>` and `:=>` exist (have rules).
In the case of `:=>`, raise an error on non-existent conditions (because
the autogenerated semantic action would go to a nonexistent condition start
label). In the case of `=>` add the nonexistent condition to condition enum
(the user may want to set condition variable and return from the lexer to
handle it in user code), but make the initial dispatch abort on it (in case
it was a typo).

This addresses bug #560 'Illformed C/C++ code due to missing "final"
conditions in generated enumeration'.
2025-11-13 22:51:24 +00:00
Ulya Trofimovich 34f6e5269f Always explicitly initialize condition enum members.
Historically in goto/label mode conditions weren't assigned explicit
numeric identifiers - the numbers were assigned implicitly based on
position in the condition enumeration. This affected language backends
for C/C++, D, Go, V (those supporting goto/label model).

In loop/switch and rec/func modes condition numbers correspond to TDFA
state indices, so they are not consecutive and require explicit
initializers.

This commit makes the enumeration always have explcit initializers
regardless of the code model. The generated initializers are backwards
compatible (identical to the implicitly assigned ones).
2025-11-12 22:32:02 +00:00
Ulya Trofimovich 8a4e4ebd54 Unify handling of numeric condition identifiers across code models.
Historically in goto/label mode conditions aren't assigned explicit
numeric identifiers - the numbers are assigned implicitly based on
position in the condition enumeration. However, this correlation is
erroneous: there's no guarantee that the languages that support `goto`
also have enums with implicit numbers.

For now, keep the erroneous correlation (to avoid changing the generated
code), but move it from re2c code to syntax file definitions.
2025-11-12 21:10:34 +00:00
dependabot[bot] 79831797ff Actions(deps): Bump actions/upload-artifact from 4 to 5
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4 to 5.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-27 12:32:46 +00:00
dependabot[bot] 0bfddb867b Actions(deps): Bump actions/setup-python from 5 to 6
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 11:35:27 +01:00
Alexey Abramov 7563ecaec0 Use maximum alignment to ensure compatibility across all architectures. 2025-08-31 12:22:56 +01:00
dependabot[bot] e74cef8655 Actions(deps): Bump actions/setup-java from 4 to 5
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 4 to 5.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-25 21:00:13 +01:00
dependabot[bot] 26f01b60ee Actions(deps): Bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-18 15:46:44 +01:00
Stefan A. Haubenthal 6662452bde Fixed minor typos 2025-08-04 06:19:13 +01:00
Ulya Trofimovich ffdc69dc2e Release 4.3. 2025-06-30 14:17:05 +01:00
Ulya Trofimovich 8bc53228ff Update changelog for release 4.3. 2025-06-30 07:02:33 +01:00
Ulya Trofimovich 2a64e74ff7 Docs: add description of -Wdeprecated-eof-rule warning. 2025-06-30 07:02:33 +01:00
Ulya Trofimovich 76e14817fb Allow to use $ in a regexp.
Previously $ was a special end-of-input rule with precedence and
inheritance order similar to the special default rule *.

Now $ can be used in a regexp as part of a normal rule with normal
position-based precedence and inheritance order. However, this change would
break backwards compatibility in some cases, so for now there's a workaround
that enforces the old order and gives a warning. In the future the warning
will be turned to error, and the old order will no longer be enforced.

New options that control this behavior:

    -Wdeprecated-eof-rule          (turn on warning, on by default)
    -Wno-deprecated-eof-rule       (turn off warning)
    -Werror-deprecated-eof-rule    (turn on error, off by default for now)
    -Wno-error-deprecated-eof-rule (turn off error)

The case when $ is in the middle of a regexp (like `[a] $ [b]`) are forbidden
and raise an error. The case when $ is at the end but not standalone (like
`[a] $ | [b]`) are forbidden at the moment, as they are not handled properly in
codegen, but they will be allowed later. For now, only the old-style standalone
rule `$` is handled properly.

This is the first part of the work needed for issue
https://github.com/skvadrik/re2c/issues/525.
2025-06-29 06:45:13 +01:00
Ulya Trofimovich e89281382f Store rules (not rule locations) in the shadow set.
This will be used later to check if a shadowing rule is an end-of-input rule.
2025-06-29 06:45:13 +01:00
Ulya Trofimovich 83b1f8769a Fix analysis that determines if default state is needed with re2c:eof.
Use fallthrough states, not fallback states.

The added test used to SIGSEGV before the change.
2025-06-29 06:45:13 +01:00
Ulya Trofimovich 325c102712 Use correct union member.
The code happened to work correctly because the two union members had
identical layout.
2025-06-29 06:45:13 +01:00
Ulya Trofimovich f15465cd60 Do not emit -Wunreachable-rules for <*> if a rule is alive in some conditions. 2025-06-29 06:45:13 +01:00
Ulya Trofimovich 9cfdb736c6 Fix incorrect comment in the test and add another test case.
The comment was initially consistent with the generated code, but it got
inconsistent after commit 277f0295fc which
fixed code generation.
2025-06-29 06:45:13 +01:00
Ulya Trofimovich 9601d30173 Don't forget to add fallback tags with end-of-input rule $.
If end-of-input rule `$` is used, re2c takes a different approach and
uses a different set of subroutines to find unreachable rules.
Previously these lacked "fallthough" analysis that is normally performed
without the `$` rule. As a result, some code was generated incorrectly
(as can be seen on the updated tests and the newly added test).
2025-06-29 06:45:13 +01:00
Peter Kokot ffefa3914d CMake: Add CheckPIESupported
The CMAKE_POSITION_INDEPENDENT_CODE variable enables PIC when building
objects, and the CheckPIESupported module provides a
check_pie_supported() command, which enables position independent code
for executables (PIE) at the link step. Without this module, for
example, building at the link step in some cases might fail. For
example, on Haiku.
2025-06-26 06:31:33 +01:00
Ulya Trofimovich d528489324 Unify clos_t with conf_t from libre2c.
After a recent rework of `clos_t` it has become identical to `conf_t`, so
there's no need for using a different type in libre2c.
2025-05-16 22:41:09 +01:00
Ulya Trofimovich 862eee4570 Speed up core determinization algorithm by another ~42%.
Avoid popping/pushing on-stack closure items and patch them in place if
possible. Note that using `emplace` instead of `push_back` method on
`std::vector` instead of this change is not nearly as much helpful: it adds
only a ~6% speedup compared to the ~42% speedup caused by this change.

It only affects leftmost greedy closure construction (which is the default).

This addresses bug https://github.com/skvadrik/re2c/discussions/544
"Unicode characters in UTF8 and generation performance".

The 42% speedup was measured on examples/c/unicode_identifier.re modified as
suggested in the comment
https://github.com/skvadrik/re2c/discussions/544#discussioncomment-13011740.
2025-05-16 17:24:49 +01:00
Ulya Trofimovich 3734d5bdd7 Speed up core determinization algorithm by ~10%.
Make closure items smaller - don't store transition tags and tag versions
in them, as they can be retrieved from the origin kernel using origin TNFA
state for each closure item. Making the items smaller reduces the amount
of copying during closure construction.

Also, avoid extra copy between the main and auxiliary closure vectors;
construct the new TDFA state kernel right from the main vector. This required
a lot of changes in the code, as the kernel stores information as a struct of
arrays (this allows fast comparison and hashing of only the relevant parts of
the kernel), while the closure is an array of structs (this is more convenient
for closure construction and sorting).

Also, make the conditional in the kenel hashing function compile-time rather
than run-time.

There are no algorithmic changes; only the way information is organized and
propagated.

This addresses bug https://github.com/skvadrik/re2c/discussions/544
"Unicode characters in UTF8 and generation performance".

The 10% speedup was measured on examples/c/unicode_identifier.re modified as
suggested in the comment
https://github.com/skvadrik/re2c/discussions/544#discussioncomment-13011740.
2025-05-16 17:19:24 +01:00
Ulya Trofimovich e461e348b1 Disable Swift in builds configs that are used for bootstrap and need only C. 2025-04-23 22:32:06 +01:00
1314 changed files with 303992 additions and 374364 deletions
+8 -5
View File
@@ -33,18 +33,20 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: '3.8'
- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@v6
with:
distribution: 'adopt'
java-version: '24'
# One of the distributions that packages OpenJDK, see
# https://github.com/marketplace/actions/setup-java-jdk#supported-distributions
distribution: 'oracle-openjdk'
java-version: '26'
- name: Setup Common Prerequisites
run: |
@@ -79,6 +81,7 @@ jobs:
-DRE2C_BUILD_RE2OCAML=OFF \
-DRE2C_BUILD_RE2PY=OFF \
-DRE2C_BUILD_RE2RUST=OFF \
-DRE2C_BUILD_RE2SWIFT=OFF \
-DRE2C_BUILD_RE2V=OFF \
-DRE2C_BUILD_RE2ZIG=OFF \
-DRE2C_BUILD_BENCHMARKS=ON \
+13 -4
View File
@@ -36,11 +36,11 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup apt cache (Linux)
if: startsWith(runner.os, 'Linux')
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: /var/cache/apt
key: ${{ runner.os }}-apt-cache-${{ matrix.os }}-${{ github.sha }}
@@ -69,7 +69,7 @@ jobs:
esac
- name: Setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: 3.x
architecture: x64
@@ -85,8 +85,17 @@ jobs:
- name: Fast Configure
run: |
./configure \
--disable-dlang \
--disable-golang \
--disable-haskell \
--disable-java \
--disable-js \
--disable-ocaml \
--disable-python \
--disable-rust \
--disable-swift \
--disable-vlang \
--disable-zig \
--prefix=$PWD/install
- name: Fast Build
@@ -146,7 +155,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@v4
uses: actions/upload-artifact@v7
with:
# To ensure that jobs don't overwrite existing artifacts,
# use a different name per job.
+5 -5
View File
@@ -62,11 +62,11 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Setup chocolatey Cache (Windows)
if: startsWith(runner.os, 'Windows')
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
key: ${{ runner.os }}-chocolatey-${{ matrix.os }}-${{ github.sha }}
@@ -76,7 +76,7 @@ jobs:
- name: Setup apt cache (Linux)
if: startsWith(runner.os, 'Linux')
uses: actions/cache@v4
uses: actions/cache@v6
with:
path: /var/cache/apt
key: ${{ runner.os }}-apt-cache-${{ matrix.os }}-${{ github.sha }}
@@ -105,7 +105,7 @@ jobs:
esac
- name: Setup Python
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: 3.x
architecture: x64
@@ -165,7 +165,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@v4
uses: actions/upload-artifact@v7
with:
# To ensure that jobs don't overwrite existing artifacts,
# use a different name per job.
+73
View File
@@ -2,6 +2,79 @@ Changelog
=========
4.6 (2026-08-29)
~~~~~~~~~~~~~~~~
- Added support for Zig labeled continue optimization.
(`#580 <https://github.com/skvadrik/re2c/pull/580>`_).
- Updated C/C++ examples to use re2c features available in version 4.0 or higher.
4.5.1 (2026-03-27)
~~~~~~~~~~~~~~~~~~
- Added missing include files to the distribution
(`#573 <https://github.com/skvadrik/re2c/issues/573>`_).
- Updated the documentation to mention the new include files.
4.5 (2026-03-23)
~~~~~~~~~~~~~~~~
- Migrated include files to Unicode 17.0.0 standard.
- Added Unicode include files:
+ `include/unicode_blocks.re <https://github.com/skvadrik/re2c/blob/master/include/unicode_blocks.re>`_
+ `include/unicode_properties.re <https://github.com/skvadrik/re2c/blob/master/include/unicode_properties.re>`_
- Implemented Unicode case mapping for case-insensitive string literals
(`#235 <https://github.com/skvadrik/re2c/issues/235>`_).
- Fixed `#571 <https://github.com/skvadrik/re2c/issues/571>`_
(segmentation fault on erroneous input during determinization).
- Updated paper `A closer look at TDFA <https://arxiv.org/abs/2206.01398>`_
(applied corrections by Lisa Felidae).
4.4 (2025-12-20)
~~~~~~~~~~~~~~~~
- Added generalized end-of-input symbol ``$``
(`#525 <https://github.com/skvadrik/re2c/issues/525>`_).
This change may break old code with conflicitng end-of-input rules,
as they now have position-based precedence. The broken cases were
reported with ``-Wdeprecated-eof-rule`` since version 4.3.
4.3.1 (2025-12-01)
~~~~~~~~~~~~~~~~~~
- Fixed bugs:
+ `#560 <https://github.com/skvadrik/re2c/issues/560>`_
(allow conditions that have no rules except for default rule)
+ `#561 <https://github.com/skvadrik/re2c/issues/561>`_
(use unsigned character type in C/C++ examples)
+ `#564 <https://github.com/skvadrik/re2c/issues/564>`_
(fix broken end of input rule $ with captures)
4.3 (2025-06-30)
~~~~~~~~~~~~~~~~
- Added warning ``-Wdeprecated-eof-rule``, this will be turned to error in the
future (`#525 <https://github.com/skvadrik/re2c/issues/525>`_).
- Improved re2c performance (made determinization faster,
`#544 <https://github.com/skvadrik/re2c/discussions/544>`_).
4.2 (2025-04-23)
~~~~~~~~~~~~~~~~
+10 -2
View File
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.15)
project(re2c VERSION 4.2 HOMEPAGE_URL "https://re2c.org/")
project(re2c VERSION 4.6 HOMEPAGE_URL "https://re2c.org/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -73,7 +73,11 @@ endif()
# Cygwin and NetBSD.
set(CMAKE_CXX_STANDARD 11)
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
# make sure object libraries work with shared libraries
include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# needed for POSIX file API
ac_check_headers("sys/types.h")
@@ -226,6 +230,7 @@ set(re2c_sources
src/encoding/ebcdic.cc
src/encoding/enc.cc
src/encoding/range_suffix.cc
src/encoding/unicode_casemap.cc
src/encoding/utf8.cc
src/encoding/utf16.cc
src/msg/msg.cc
@@ -466,7 +471,9 @@ if(RE2C_IS_ROOT_PROJECT)
include/syntax/swift
include/syntax/v
include/syntax/zig
include/unicode_blocks.re
include/unicode_categories.re
include/unicode_properties.re
DESTINATION "${RE2C_STDLIB_DIR}")
# rebuild all re2c sources using newly built re2c
@@ -594,6 +601,7 @@ if (RE2C_BUILD_LIBS)
src/nfa/re_to_nfa.cc
src/encoding/enc.cc
src/encoding/range_suffix.cc
src/encoding/unicode_casemap.cc
src/encoding/ebcdic.cc
src/encoding/utf16.cc
src/encoding/utf8.cc
+7 -1
View File
@@ -239,6 +239,7 @@
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
@@ -266,6 +267,7 @@
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
@@ -291,6 +293,7 @@
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
@@ -305,7 +308,7 @@
{
"name": "windows-config-base",
"hidden": true,
"generator": "Visual Studio 17 2022",
"generator": "Visual Studio 18 2026",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
@@ -336,6 +339,7 @@
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
@@ -361,6 +365,7 @@
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
@@ -386,6 +391,7 @@
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
+4 -1
View File
@@ -104,6 +104,7 @@ re2c_SRC = \
src/encoding/ebcdic.cc \
src/encoding/enc.cc \
src/encoding/range_suffix.cc \
src/encoding/unicode_casemap.cc \
src/encoding/utf8.cc \
src/encoding/utf16.cc \
src/msg/msg.cc \
@@ -628,7 +629,9 @@ dist_stdlib_DATA = \
include/syntax/swift \
include/syntax/v \
include/syntax/zig \
include/unicode_categories.re
include/unicode_blocks.re \
include/unicode_categories.re \
include/unicode_properties.re
BAZELFILES := \
BUILD.bazel \
+1
View File
@@ -99,6 +99,7 @@ libre2c_la_SRC = \
src/nfa/re_to_nfa.cc \
src/encoding/enc.cc \
src/encoding/range_suffix.cc \
src/encoding/unicode_casemap.cc \
src/encoding/ebcdic.cc \
src/encoding/utf16.cc \
src/encoding/utf8.cc \
+1 -1
View File
@@ -23,7 +23,7 @@ def _re2c_impl(ctx):
tools = [ctx.executable._re2c_tool],
inputs = ctx.files.srcs + ctx.files.data,
command = """
"{re2c}" "{src}" -o "{out}" {re2c_args} {includes}
"{re2c}" --no-generation-date "{src}" -o "{out}" {re2c_args} {includes}
""".format(
re2c = ctx.executable._re2c_tool.path,
src = srcs[0].path,
+100 -60
View File
@@ -56,11 +56,10 @@ decimal number:
// re2c $INPUT \-o $OUTPUT \-i \-\-case\-ranges
#include <assert.h>
int lex(const char *s) {
const char *YYCURSOR = s;
int lex(const char* YYCURSOR) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
[1\-9][0\-9]* { return 0; }
* { return 1; }
@@ -87,11 +86,10 @@ In the output re2c replaced the block in the middle with the generated code:
// re2c $INPUT \-o $OUTPUT \-i \-\-case\-ranges
#include <assert.h>
int lex(const char *s) {
const char *YYCURSOR = s;
int lex(const char* YYCURSOR) {
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case \(aq1\(aq ... \(aq9\(aq: goto yy2;
@@ -821,6 +819,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -931,6 +932,7 @@ This API contains primitives for generic operations:
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYEND\fP\&.
Generic API supports two styles that determine the form in which the
primitives should be defined:
.nf
@@ -962,6 +964,7 @@ API can be defined in terms of pointers \fBcursor\fP, \fBlimit\fP,
re2c:YYRESTORECTX = \(dqcursor = ctxmarker;\(dq;
re2c:YYRESTORETAG = \(dqcursor = ${tag};\(dq;
re2c:YYLESSTHAN = \(dqlimit \- cursor < @@{len}\(dq;
re2c:YYEND = \(dqlimit == cursor\(dq;
re2c:YYSTAGP = \(dq@@{tag} = cursor;\(dq;
re2c:YYSTAGN = \(dq@@{tag} = NULL;\(dq;
re2c:YYSHIFT = \(dqcursor += @@{shift};\(dq;
@@ -996,6 +999,7 @@ generic API can be defined in terms of pointers \fBcursor\fP, \fBlimit\fP,
#define YYRESTORECTX() cursor = ctxmarker
#define YYRESTORETAG(tag) cursor = tag
#define YYLESSTHAN(len) limit \- cursor < len
#define YYEND() limit == cursor
#define YYSTAGP(tag) tag = cursor
#define YYSTAGN(tag) tag = NULL
#define YYSHIFT(shift) cursor += shift
@@ -1073,6 +1077,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1256,7 +1268,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1393,6 +1405,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1656,6 +1674,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2c silently ignores such escapes, but this may as well
@@ -1723,7 +1748,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1987,12 +2012,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2230,6 +2258,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2296,6 +2328,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2331,6 +2367,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2c version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -2453,7 +2492,7 @@ static int lex(const char *YYCURSOR) {
for (;;) {
/*!re2c
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:yyfill:enable = 0;
* { return \-1; }
@@ -2509,7 +2548,7 @@ static int lex(const char *str, unsigned int len) {
for (;;) {
/*!re2c
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:yyfill:enable = 0;
re2c:eof = 0;
@@ -2581,8 +2620,8 @@ static int lex(const char *str, unsigned int len) {
loop:
/*!re2c
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYFILL = \(dqgoto fail;\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYFILL = \(dqgoto fail;\(dq;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
@@ -2647,11 +2686,11 @@ static int lex(const char *str, unsigned int len) {
for (;;) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:api = custom;
re2c:api = generic;
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYPEEK = \(dqcur < lim ? *cur : 0\(dq; // fake null
re2c:define:YYSKIP = \(dq++cur;\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYPEEK = \(dqcur < lim ? *cur : 0\(dq; // fake null
re2c:YYSKIP = \(dq++cur;\(dq;
* { count = \-1; break; }
[\ex00] { break;; }
@@ -2806,11 +2845,11 @@ loop:
in\->tok = in\->cur;
/*!re2c
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = in\->cur;
re2c:define:YYMARKER = in\->mar;
re2c:define:YYLIMIT = in\->lim;
re2c:define:YYFILL = \(dqfill(in) == 0\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYCURSOR = in\->cur;
re2c:YYMARKER = in\->mar;
re2c:YYLIMIT = in\->lim;
re2c:YYFILL = \(dqfill(in) == 0\(dq;
re2c:eof = 0;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
@@ -2953,10 +2992,10 @@ loop:
in\->tok = in\->cur;
/*!re2c
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = in\->cur;
re2c:define:YYLIMIT = in\->lim;
re2c:define:YYFILL = \(dqif (fill(in, @@) != 0) return \-1;\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYCURSOR = in\->cur;
re2c:YYLIMIT = in\->lim;
re2c:YYFILL = \(dqif (fill(in, @@) != 0) return \-1;\(dq;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
@@ -3044,7 +3083,7 @@ static uint64_t parse_u32(const char *s) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
end = \(dq\ex00\(dq;
@@ -3206,9 +3245,9 @@ static uint64_t parse_u32(const char *s) {
/*!re2c
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYGETCONDITION = \(dqc\(dq;
re2c:define:YYSETCONDITION = \(dqc = @@;\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYGETCOND = \(dqc\(dq;
re2c:YYSETCOND = \(dqc = @@;\(dq;
re2c:yyfill:enable = 0;
<*> * { return ERROR; }
@@ -3346,13 +3385,13 @@ static Status lex(State *st, unsigned int *recv) {
st\->tok = st\->cur;
/*!re2c
re2c:api:style = free\-form;
re2c:define:YYCTYPE = \(dqchar\(dq;
re2c:define:YYCURSOR = \(dqst\->cur\(dq;
re2c:define:YYMARKER = \(dqst\->mar\(dq;
re2c:define:YYLIMIT = \(dqst\->lim\(dq;
re2c:define:YYGETSTATE = \(dqst\->state\(dq;
re2c:define:YYSETSTATE = \(dqst\->state = @@;\(dq;
re2c:define:YYFILL = \(dqreturn WAITING;\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYCURSOR = \(dqst\->cur\(dq;
re2c:YYMARKER = \(dqst\->mar\(dq;
re2c:YYLIMIT = \(dqst\->lim\(dq;
re2c:YYGETSTATE = \(dqst\->state\(dq;
re2c:YYSETSTATE = \(dqst\->state = @@;\(dq;
re2c:YYFILL = \(dqreturn WAITING;\(dq;
re2c:eof = 0;
packet = [a\-z]+[;];
@@ -3501,7 +3540,7 @@ static What lex(const char *s) {
const char *YYCURSOR = s, *YYMARKER;
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
!use:fish;
!use:colors;
@@ -3542,7 +3581,7 @@ int main() {
static int lex_utf8(const uint8_t *s) {
const uint8_t *YYCURSOR = s, *YYMARKER;
/*!use:re2c
re2c:define:YYCTYPE = uint8_t;
re2c:YYCTYPE = uint8_t;
re2c:encoding:utf8 = 1;
*/
}
@@ -3550,7 +3589,7 @@ static int lex_utf8(const uint8_t *s) {
static int lex_utf32(const uint32_t *s) {
const uint32_t *YYCURSOR = s, *YYMARKER;
/*!use:re2c
re2c:define:YYCTYPE = uint32_t;
re2c:YYCTYPE = uint32_t;
re2c:encoding:utf32 = 1;
*/
}
@@ -3695,7 +3734,7 @@ static int lex(const char *str, SemVer *ver) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:tags = 1;
num = [0\-9]+;
@@ -3802,11 +3841,11 @@ static bool lex(Input &in, std::vector<SemVer> &vers) {
/*!re2c
re2c:eof = 0;
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = in.cur;
re2c:define:YYMARKER = in.mar;
re2c:define:YYLIMIT = in.lim;
re2c:define:YYFILL = \(dqfill(in) == 0\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYCURSOR = in.cur;
re2c:YYMARKER = in.mar;
re2c:YYLIMIT = in.lim;
re2c:YYFILL = \(dqfill(in) == 0\(dq;
re2c:tags:expression = \(dqin.@@\(dq;
num = [0\-9]+;
@@ -3889,7 +3928,7 @@ static int lex(const char *str, SemVer *ver) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:captvars = 1;
num = [0\-9]+;
@@ -3992,11 +4031,11 @@ static bool parse(const char *str, Ver &ver) {
/*!re2c
re2c:api:style = free\-form;
re2c:define:YYCTYPE = char;
re2c:define:YYSTAGP = \(dq@@ = YYCURSOR;\(dq;
re2c:define:YYSTAGN = \(dq@@ = NULL;\(dq;
re2c:define:YYMTAGP = \(dqadd_mtag(mt, @@, YYCURSOR);\(dq;
re2c:define:YYMTAGN = \(dqadd_mtag(mt, @@, NULL);\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYSTAGP = \(dq@@ = YYCURSOR;\(dq;
re2c:YYSTAGN = \(dq@@ = NULL;\(dq;
re2c:YYMTAGP = \(dqadd_mtag(mt, @@, YYCURSOR);\(dq;
re2c:YYMTAGN = \(dqadd_mtag(mt, @@, NULL);\(dq;
re2c:yyfill:enable = 0;
re2c:tags = 1;
@@ -4068,8 +4107,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2c definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2c definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
@@ -4093,7 +4133,7 @@ Below is an example of a lexer for UTF8 encoded Unicode identifiers.
static int lex(const char *s) {
const char *YYCURSOR = s, *YYMARKER;
/*!re2c
re2c:define:YYCTYPE = \(aqunsigned char\(aq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:yyfill:enable = 0;
// Simplified \(dqUnicode Identifier and Pattern Syntax\(dq
@@ -4177,7 +4217,7 @@ float { return OK; }
Result lex(const char *s) {
const char *YYCURSOR = s, *YYMARKER;
/*!re2c
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:yyfill:enable = 0;
* { return FAIL; }
@@ -4235,8 +4275,8 @@ long lex(LexerState* st) {
/*!re2c
re2c:header = \(dqlexer/state.h\(dq;
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = \(dqst\->cur\(dq;
re2c:YYCTYPE = \(dqunsigned char\(dq;
re2c:YYCURSOR = \(dqst\->cur\(dq;
re2c:tags = 1;
re2c:tags:expression = \(dqst\->@@\(dq;
+48 -8
View File
@@ -815,6 +815,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -922,7 +925,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -991,6 +995,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1174,7 +1186,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1311,6 +1323,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1574,6 +1592,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2d silently ignores such escapes, but this may as well
@@ -1641,7 +1666,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1905,12 +1930,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2148,6 +2176,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2214,6 +2246,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2249,6 +2285,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2d version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -3958,8 +3997,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2d definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2d definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+50 -8
View File
@@ -822,6 +822,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -932,7 +935,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
Generic API supports two styles that determine the form in which the
primitives should be defined:
.nf
@@ -964,6 +968,7 @@ API can be defined in terms of integer variables \fBcursor\fP, \fBlimit\fP,
re2c:YYRESTORECTX = \(dqcursor = ctxmarker\(dq;
re2c:YYRESTORETAG = \(dqcursor = ${tag}\(dq;
re2c:YYLESSTHAN = \(dqlimit \- cursor < @@{len}\(dq;
re2c:YYEND = \(dqlimit == cursor\(dq;
re2c:YYSTAGP = \(dq@@{tag} = cursor\(dq;
re2c:YYSTAGN = \(dq@@{tag} = \-1\(dq;
re2c:YYSHIFT = \(dqcursor += @@{shift}\(dq;
@@ -997,6 +1002,7 @@ YYRESTORE := func() { cursor = marker }
YYBACKUPCTX := func() { ctxmarker = cursor }
YYRESTORECTX := func() { cursor = ctxmarker }
YYLESSTHAN := func(n int) bool { return limit\-cursor < n }
YYEND := func(n int) bool { return limit == cursor }
YYSHIFT := func(n int) { cursor += n }
.ft P
.fi
@@ -1071,6 +1077,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1254,7 +1268,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1391,6 +1405,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1654,6 +1674,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2go silently ignores such escapes, but this may as well
@@ -1721,7 +1748,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1985,12 +2012,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2228,6 +2258,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2294,6 +2328,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2329,6 +2367,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2go version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -4109,8 +4150,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2go definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2go definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+50 -10
View File
@@ -843,6 +843,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -942,7 +945,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -1011,6 +1015,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1194,7 +1206,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1331,6 +1343,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1594,6 +1612,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2hs silently ignores such escapes, but this may as well
@@ -1661,7 +1686,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1925,12 +1950,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2168,6 +2196,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2234,6 +2266,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2269,6 +2305,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2hs version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -3510,9 +3549,9 @@ data State a = State {
%}
%{use
re2c:YYFN = [\(dqlex32;Maybe Int\(dq, \(dqState{..};State (Array Int Int)\(dq];
re2c:YYFN = [\(dqlex32;Maybe Int\(dq, \(dqState{..};State (Array Int Word)\(dq];
re2c:encoding:utf32 = 1;
re2c:YYCTYPE = Int;
re2c:YYCTYPE = Word;
%}
main :: IO ()
@@ -4012,8 +4051,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2hs definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2hs definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+72 -31
View File
@@ -856,6 +856,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -964,7 +967,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -1033,6 +1037,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1216,7 +1228,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1353,6 +1365,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1616,6 +1634,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2java silently ignores such escapes, but this may as well
@@ -1683,7 +1708,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1947,12 +1972,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2190,6 +2218,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2256,6 +2288,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2291,6 +2327,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2java version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -2532,10 +2571,10 @@ class Main {
/*!max:re2c*/
// Expects yymaxfill\-padded string.
static int lex(String str) {
static int lex(byte[] str) {
// Pad string with yymaxfill zeroes at the end.
byte[] yyinput = new byte[str.length() + YYMAXFILL];
System.arraycopy(str.getBytes(), 0, yyinput, 0, str.length());
byte[] yyinput = new byte[str.length + YYMAXFILL];
System.arraycopy(str, 0, yyinput, 0, str.length);
int yycursor = 0;
int yylimit = yyinput.length;
@@ -2543,15 +2582,15 @@ class Main {
loop: while (true) {
/*!re2c
re2c:YYCTYPE = \(dqbyte\(dq;
re2c:YYPEEK = \(dqyyinput[yycursor]\(dq;
re2c:YYCTYPE = \(dqint\(dq;
re2c:YYPEEK = \(dqByte.toUnsignedInt(yyinput[yycursor])\(dq;
re2c:YYFILL = \(dqreturn \-1;\(dq;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
[\ex00] {
// Check that it is the sentinel, not some unexpected null.
return (yycursor \- 1 == str.length()) ? count : \-1;
return (yycursor \- 1 == str.length) ? count : \-1;
}
str { count += 1; continue loop; }
[ ]+ { continue loop; }
@@ -2561,10 +2600,10 @@ class Main {
}
public static void main(String []args) {
assert lex(\(dq\(dq) == 0;
assert lex(\(dq\(aqqu\e0tes\(aq \(aqare\(aq \(aqfine: \e\e\(aq\(aq \(dq) == 3;
assert lex(\(dq\(aqunterminated\e\e\(aq\(dq) == \-1;
assert lex(\(dq\(aqunexpected \e00 null\e\e\(aq\(dq) == \-1;
assert lex(\(dq\(dq.getBytes()) == 0;
assert lex(\(dq\(aqqu\e0tes\(aq \(aqare\(aq \(aqfine: \e\e\(aq\(aq \(dq.getBytes()) == 3;
assert lex(\(dq\(aqunterminated\e\e\(aq\(dq.getBytes()) == \-1;
assert lex(\(dq\(aqunexpected \e00 null\e\e\(aq\(dq.getBytes()) == \-1;
}
};
@@ -2599,8 +2638,9 @@ class Main {
loop: while (true) {
/*!re2c
re2c:api = generic;
re2c:YYCTYPE = \(dqbyte\(dq;
re2c:YYPEEK = \(dq(yycursor < yyinput.length) ? yyinput[yycursor] : 0\(dq;
re2c:YYCTYPE = \(dqint\(dq;
re2c:YYPEEK = \(dq(yycursor < yyinput.length)\(dq
\(dq ? Byte.toUnsignedInt(yyinput[yycursor]) : 0\(dq;
re2c:YYSKIP = \(dqyycursor += 1;\(dq;
re2c:yyfill:enable = 0;
@@ -2764,8 +2804,8 @@ class Lexer {
loop: while (true) {
token = yycursor;
/*!re2c
re2c:YYCTYPE = \(dqbyte\(dq;
re2c:YYPEEK = \(dqyyinput[yycursor]\(dq;
re2c:YYCTYPE = \(dqint\(dq;
re2c:YYPEEK = \(dqByte.toUnsignedInt(yyinput[yycursor])\(dq;
re2c:YYFILL = \(dqfill() == 0\(dq;
re2c:eof = 0;
@@ -2912,8 +2952,8 @@ class Lexer {
loop: while (true) {
token = yycursor;
/*!re2c
re2c:YYCTYPE = \(dqbyte\(dq;
re2c:YYPEEK = \(dqyyinput[yycursor]\(dq;
re2c:YYCTYPE = \(dqint\(dq;
re2c:YYPEEK = \(dqByte.toUnsignedInt(yyinput[yycursor])\(dq;
re2c:YYFILL = \(dqif (fill(@@) != 0) { return \-2; }\(dq;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
@@ -3344,13 +3384,13 @@ class Lexer {
}
private static Status lex(State yyrecord) {
byte yych;
int yych;
loop: while (true) {
yyrecord.token = yyrecord.yycursor;
/*!re2c
re2c:api = record;
re2c:YYCTYPE = \(dqbyte\(dq;
re2c:YYPEEK = \(dqyyrecord.yyinput[yyrecord.yycursor]\(dq;
re2c:YYCTYPE = \(dqint\(dq;
re2c:YYPEEK = \(dqByte.toUnsignedInt(yyrecord.yyinput[yyrecord.yycursor])\(dq;
re2c:YYFILL = \(dqreturn Status.WAITING;\(dq;
re2c:eof = 0;
@@ -3534,7 +3574,7 @@ class Main {
int yycursor = 0;
int yymarker = 0;
/*!use:re2c
re2c:YYCTYPE = \(dqint\(dq; // should be \(gabyte\(ga, but it\(aqs signed in Java
re2c:YYCTYPE = \(dqint\(dq; // Java lacks unsigned 8\-bit integer type
re2c:encoding:utf8 = 1;
*/
}
@@ -3818,8 +3858,8 @@ class Lexer {
loop: while (true) {
token = yycursor;
/*!re2c
re2c:YYCTYPE = \(dqbyte\(dq;
re2c:YYPEEK = \(dqyyinput[yycursor]\(dq;
re2c:YYCTYPE = \(dqint\(dq;
re2c:YYPEEK = \(dqByte.toUnsignedInt(yyinput[yycursor])\(dq;
re2c:YYFILL = \(dqfill() == 0\(dq;
re2c:eof = 0;
re2c:tags = 1;
@@ -3854,7 +3894,7 @@ class Lexer {
// Run the lexer.
Optional<ArrayList<SemVer>> vers = lexer.lex();
// Check resuts.
// Check results.
assert vers.isPresent() && vers.get().size() == BUFSIZE;
SemVer v = new SemVer(1, 22, 333);
for (int i = 0; i < BUFSIZE; ++i) {
@@ -4040,8 +4080,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2java definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2java definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+48 -8
View File
@@ -848,6 +848,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -956,7 +959,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -1025,6 +1029,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1208,7 +1220,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1345,6 +1357,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1608,6 +1626,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2js silently ignores such escapes, but this may as well
@@ -1675,7 +1700,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1939,12 +1964,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2182,6 +2210,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2248,6 +2280,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2283,6 +2319,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2js version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -3842,8 +3881,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2js definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2js definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+48 -8
View File
@@ -832,6 +832,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -929,7 +932,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -998,6 +1002,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1181,7 +1193,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1318,6 +1330,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1581,6 +1599,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2ocaml silently ignores such escapes, but this may as well
@@ -1648,7 +1673,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1912,12 +1937,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2155,6 +2183,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2221,6 +2253,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2256,6 +2292,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2ocaml version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -3975,8 +4014,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2ocaml definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2ocaml definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+48 -8
View File
@@ -821,6 +821,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -929,7 +932,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -998,6 +1002,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1181,7 +1193,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1318,6 +1330,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1581,6 +1599,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2py silently ignores such escapes, but this may as well
@@ -1648,7 +1673,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1912,12 +1937,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2155,6 +2183,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2221,6 +2253,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2256,6 +2292,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2py version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -3853,8 +3892,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2py definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2py definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+49 -8
View File
@@ -836,6 +836,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -946,7 +949,8 @@ This API contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
For example, if the input is a byte slice \fBbuffer: &[u8]\fP, variables
\fBcursor\fP, \fBlimit\fP, \fBmarker\fP and \fBctxmarker\fP of type \fBusize\fP
represent input positions, and a constant \fBNONE\fP represents invalid
@@ -965,6 +969,7 @@ position, then generic API can be defined as follows:
re2c:YYRESTORECTX = \(dqcursor = ctxmarker;\(dq;
re2c:YYRESTORETAG = \(dqcursor = @@{tag};\(dq;
re2c:YYLESSTHAN = \(dqlimit \- cursor < @@{len}\(dq;
re2c:YYEND = \(dqlimit == cursor\(dq;
re2c:YYSTAGP = \(dq@@{tag} = cursor;\(dq;
re2c:YYSTAGN = \(dq@@{tag} = NONE;\(dq;
re2c:YYSHIFT = \(dqcursor = (cursor as isize + @@{shift}) as usize;\(dq;
@@ -1042,6 +1047,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1225,7 +1238,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1362,6 +1375,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1625,6 +1644,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2rust silently ignores such escapes, but this may as well
@@ -1692,7 +1718,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1956,12 +1982,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2199,6 +2228,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2265,6 +2298,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2300,6 +2337,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2rust version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -4092,8 +4132,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2rust definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2rust definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+49 -8
View File
@@ -822,6 +822,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -930,7 +933,8 @@ This API contains the following primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
For example, if the input is a zero\-terminated array of bytes
\fBbuffer: [UInt8]\fP, variables \fBcursor\fP, \fBlimit\fP, \fBmarker\fP and
\fBctxmarker\fP of type \fBInt\fP represent input positions, and \fB\-1\fP
@@ -949,6 +953,7 @@ represents invalid positions, then a generic API can be defined as follows:
re2c:YYRESTORECTX = \(dqcursor = ctxmarker\(dq;
re2c:YYRESTORETAG = \(dqcursor = ${tag}\(dq;
re2c:YYLESSTHAN = \(dqlimit \- cursor < @@{len}\(dq;
re2c:YYEND = \(dqlimit == cursor\(dq;
re2c:YYSTAGP = \(dq@@{tag} = cursor\(dq;
re2c:YYSTAGN = \(dq@@{tag} = \-1\(dq;
re2c:YYSHIFT = \(dqcursor += @@{shift}\(dq;
@@ -1026,6 +1031,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1209,7 +1222,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1346,6 +1359,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1609,6 +1628,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2swift silently ignores such escapes, but this may as well
@@ -1676,7 +1702,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1940,12 +1966,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2183,6 +2212,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2249,6 +2282,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2284,6 +2321,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2swift version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -4077,8 +4117,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2swift definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2swift definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+59 -18
View File
@@ -84,7 +84,7 @@ In the output re2v replaced the block in the middle with the generated code:
fn lex(yyinput string) {
mut yycursor := 0
mut yych := 0
mut yych := u8(0)
yych = yyinput[yycursor]
match yych {
0x31...0x39 { unsafe { goto yy2 } }
@@ -813,6 +813,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -921,7 +924,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -990,6 +994,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1173,7 +1185,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1310,6 +1322,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1573,6 +1591,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2v silently ignores such escapes, but this may as well
@@ -1640,7 +1665,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1904,12 +1929,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2147,6 +2175,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2213,6 +2245,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2248,6 +2284,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2v version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -2738,7 +2777,7 @@ fn main() {
}
// Run the lexer.
n := lex(mut st)
n := lex(mut &st)
if n != count { panic(\(dqexpected $count, got $n\(dq) }
// Cleanup: remove input file.
@@ -2888,7 +2927,7 @@ fn main() {
}
// Run the lexer.
n := lex(mut st)
n := lex(mut &st)
if n != count { panic(\(dqexpected $count, got $n\(dq) }
// Cleanup: remove input file.
@@ -3304,7 +3343,7 @@ fn test(expect Status, packets []string) {
mut send := 0
mut recv := 0
for {
status = lex(mut st, mut &recv)
status = lex(mut &st, mut &recv)
if status == .lex_end {
break
} else if status == .lex_waiting {
@@ -3314,7 +3353,7 @@ fn test(expect Status, packets []string) {
fw.flush()
send += 1
}
status = fill(mut st)
status = fill(mut &st)
log.debug(\(dqfilled buffer $st.yyinput, status $status\(dq)
if status != .lex_ready {
break
@@ -3763,7 +3802,7 @@ fn main() {
// Run the lexer.
expect := []SemVer{len: bufsize, init: SemVer{1, 22, 333}}
result := parse(mut st) or { panic(\(dqparse failed\(dq) }
result := parse(mut &st) or { panic(\(dqparse failed\(dq) }
if result != expect { panic(\(dqerror\(dq) }
// Cleanup: remove input file.
@@ -3866,7 +3905,7 @@ struct MtagElem {
type MtagTrie = []MtagElem
// Append a single value to an m\-tag history.
fn add_mtag(mut trie &MtagTrie, mtag int, value int) int {
fn add_mtag(mut trie MtagTrie, mtag int, value int) int {
trie = arrays.concat(trie, MtagElem{value, mtag})
return trie.len \- 1
}
@@ -3905,7 +3944,8 @@ fn s2n(s string) int { // convert pre\-parsed string to number
fn parse(yyinput string) ?[]int {
mut yycursor, mut yymarker := 0, 0
mut trie := []MtagElem{}
// mut trie := []MtagElem{}
mut trie := MtagTrie{}
// Final tag variables available in semantic action.
/*!svars:re2c format = \(aqmut @@ := tag_none\en\(aq; */
@@ -3918,8 +3958,8 @@ fn parse(yyinput string) ?[]int {
/*!re2c
re2c:tags = 1;
re2c:yyfill:enable = 0;
re2c:YYMTAGP = \(dq@@ = add_mtag(mut &trie, @@, yycursor)\(dq;
re2c:YYMTAGN = \(dq@@ = add_mtag(mut &trie, @@, tag_none)\(dq;
re2c:YYMTAGP = \(dq@@ = add_mtag(mut trie, @@, yycursor)\(dq;
re2c:YYMTAGN = \(dq@@ = add_mtag(mut trie, @@, tag_none)\(dq;
num = [0\-9]+;
@@ -3994,8 +4034,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2v definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2v definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+105 -61
View File
@@ -836,6 +836,9 @@ variable named \fBstag\fP\&.
.B \fB#mtag\fP
An \fIm\-tag\fP: saves all input positions at which \fB#mtag\fP matches in a
variable named \fBmtag\fP\&.
.TP
.B \fB$\fP
End of input.
.UNINDENT
.sp
Character classes and string literals may contain the following escape
@@ -944,7 +947,8 @@ It contains primitives for generic operations:
\fBYYSHIFT\fP,
\fBYYSHIFTSTAG\fP,
\fBYYSHIFTMTAG\fP,
\fBYYLESSTHAN\fP\&.
\fBYYLESSTHAN\fP,
\fBYYEND\fP\&.
.UNINDENT
.sp
Here is a full list of API primitives that may be used by the generated code in
@@ -1013,6 +1017,14 @@ A generic API primitive with one variable \fBlen\fP\&.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if there are less than \fBlen\fP input characters left.
.TP
.B \fBYYEND\fP
A generic API primitive with no variables.
It should be defined as an r\-value of boolean type that equals \fBtrue\fP if
and only if the \fIlogical\fP end of input has been reached (excluding any
padding or sentinel symbols). \fBYYEND\fP is used to implement \fB$\fP symbol in
regular expressions. It differs from \fBYYLESSTHAN\fP, which is used to ensure
that the lexer won\(aqt read past the end of buffer.
.TP
.B \fBYYPEEK\fP
A generic API primitive with no variables.
It should be defined as an r\-value of type \fBYYCTYPE\fP that is equal to the
@@ -1196,7 +1208,7 @@ Show help message.
.TP
.B \fB\-\-api <simple | record | generic>\fP
Specify the API used by the generated code to interface with used\-defined
code. Option \fBsimple\fP shold be used in simple cases when there\(aqs no need
code. Option \fBsimple\fP should be used in simple cases when there\(aqs no need
for buffer refilling and storing lexer state. Option \fBrecord\fP should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option \fBgeneric\fP should be used in complex cases when the other two APIs
@@ -1333,6 +1345,12 @@ variable \fByystate\fP\&. Transitions between states update \fByystate\fP to the
case label of the destination state and continue execution to the head of
the loop.
.TP
.B \fB\-\-computed\-continue\fP
This option requires the \fB\-\-loop\-switch\fP code model. It uses computed
\fBcontinue\fP statements to select the next switch case directly, enabling
jump\-table optimization similar to \fB\-\-computed\-gotos\fP in the goto/label
code model.
.TP
.B \fB\-\-nested\-ifs \-s\fP
Use nested \fBif\fP statements instead of \fBswitch\fP statements in conditional
jumps. This usually results in more efficient code with non\-optimizing
@@ -1596,6 +1614,13 @@ priority, matches any code unit, and always consumes a single code unit.
.B \fB\-Wunreachable\-rules\fP
Warn about rules that are shadowed by other rules and will never match.
.TP
.B \fB\-Wdeprecated\-eof_rule\fP
Warn about standalone end of input rules \fB$\fP that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol \fB$\fP precedence order will change and these rules will
become shadowed by other rules.
.TP
.B \fB\-Wuseless\-escape\fP
Warn if a symbol is escaped when it shouldn\(aqt be.
By default, re2zig silently ignores such escapes, but this may as well
@@ -1663,7 +1688,7 @@ A list of supported codegen targets with possible elements \fBcode\fP,
.B \fBsupported_features\fP
A list of supported features with possible elements \fBnested\-ifs\fP,
\fBbitmaps\fP, \fBcomputed\-gotos\fP, \fBcase\-ranges\fP, \fBmonadic\fP, \fBunsafe\fP,
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP\&.
\fBtags\fP, \fBcaptures\fP, \fBcaptvars\fP, \fBcomputed\-continue\fP\&.
.UNINDENT
.UNINDENT
.UNINDENT
@@ -1927,12 +1952,15 @@ Default switch case.
.TP
.B \fBcode:loop\fP
A loop that runs forever (unless interrupted from the loop body).
Supported variables: \fBlabel\fP (loop label), \fBstmt\fP (a list variable
that expands to all statements in the loop body).
Supported variables: \fBlabel\fP (loop label), \fBval\fP (initial state),
\fBvar\fP (state variable), \fBstate\fP (a list variable that expands to all
state names) and \fBstmt\fP (a list variable that expands to all statements
in the loop body or the current state).
.TP
.B \fBcode:continue\fP
Continue statement. Supported variables: \fBlabel\fP (label from which to
continue execution).
continue execution), \fBval\fP (value passed to a labeled switch) and \fBvar\fP
(state variable).
.TP
.B \fBcode:goto\fP
Goto statement. Supported variables: \fBlabel\fP (label of the jump
@@ -2170,6 +2198,10 @@ Supported variables: \fBYYLESSTHAN\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP,
\fBneed\fP (the number of code units to check against). Conditional:
\fB\&.many\fP (true if the \fBneed\fP is more than one).
.TP
.B \fBcode:yyend\fP
\fBYYEND\fP expression, possibly specialized for different APIs.
Supported variables: \fBYYEND\fP, \fBYYCURSOR\fP, \fBYYLIMIT\fP\&.
.TP
.B \fBcode:yybm_filter\fP
Condition that is used to filter out \fByych\fP values that are not
covered by the \fByybm\fP table (used with \fB\-\-bitmaps\fP option).
@@ -2236,6 +2268,10 @@ True if case ranges feature is enabled (\fB\-\-case\-ranges\fP or
True if the relative form of computed \fBgoto\fP is used
(\fB\-\-computed\-gotos\-relative\fP or \fBre2c:cgoto:relative = 1\fP).
.TP
.B \fB\&.computed_continue\fP
True if loop/switch model uses labeled\-switch transitions
(\fB\-\-computed\-continue\fP).
.TP
.B \fB\&.code_model.goto_label\fP
True if code model based on goto/label is used (\fB\-\-goto\-label\fP).
.TP
@@ -2271,6 +2307,9 @@ languages that have \(dqunsafe\(dq feature.
.B \fB\&.version\fP
True if the generated fingerprint should contain re2zig version.
.TP
.B \fB\&.yyfill.enable\fP
True if \fBYYFILL\fP is enabled (\fBre2c:yyfill:enable = 1\fP).
.TP
.B \fB\&.yyfn.throw\fP
True if \fBre2c:yyfn:throw\fP configuration is defined to a nonempty string.
.UNINDENT
@@ -2692,6 +2731,7 @@ const std = @import(\(dqstd\(dq);
const bufsize = 4095;
const State = struct {
file: *std.Io.Reader,
yyinput: [bufsize + 1]u8,
yycursor: usize,
yymarker: usize,
@@ -2700,7 +2740,7 @@ const State = struct {
eof: bool
};
fn fill(st: *State, file: anytype) i32 {
fn fill(st: *State) i32 {
if (st.eof) { return \-1; } // unexpected EOF
// Error: lexeme too long. In real life can reallocate a larger buffer.
@@ -2715,7 +2755,7 @@ fn fill(st: *State, file: anytype) i32 {
st.token = 0;
// Fill free space at the end of buffer with new data from file.
st.yylimit += file.read(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yylimit += st.file.readSliceShort(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yyinput[st.yylimit] = 0; // append sentinel symbol
// If read less than expected, this is the end of input.
@@ -2724,14 +2764,14 @@ fn fill(st: *State, file: anytype) i32 {
return 0;
}
fn lex(yyrecord: *State, file: anytype) i32 {
fn lex(yyrecord: *State) i32 {
var count: i32 = 0;
loop: while (true) {
yyrecord.token = yyrecord.yycursor;
%{
re2c:api = record;
re2c:eof = 0;
re2c:YYFILL = \(dqfill(yyrecord, file) == 0\(dq;
re2c:YYFILL = \(dqfill(yyrecord) == 0\(dq;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
@@ -2755,10 +2795,12 @@ test {
fw.close();
// Prepare lexer state: all offsets are at the end of buffer.
var fr = try std.fs.cwd().openFile(fname, .{ .mode = .read_only});
// Normally file would be part of the state struct, but BufferedReader type is unclear.
var br = std.io.bufferedReader(fr.reader());
// Use unbuffered reader \- lexer does its own buffering.
const zerobuf: [0]u8 = undefined;
var fr = try std.fs.cwd().openFile(fname, .{.mode = .read_only});
var reader = fr.reader(&zerobuf);
var st = State{
.file = &reader.interface,
.yyinput = undefined,
.yycursor = bufsize,
.yymarker = bufsize,
@@ -2770,7 +2812,7 @@ test {
st.yyinput[st.yylimit] = 0;
// Run the lexer.
try std.testing.expectEqual(lex(&st, &br), count);
try std.testing.expectEqual(lex(&st), count);
// Cleanup: remove input file.
fr.close();
@@ -2837,6 +2879,7 @@ const std = @import(\(dqstd\(dq);
const bufsize = 4096;
const State = struct {
file: *std.Io.Reader,
yyinput: [bufsize + yymaxfill]u8,
yycursor: usize,
yymarker: usize,
@@ -2845,7 +2888,7 @@ const State = struct {
eof: bool
};
fn fill(st: *State, need: usize, file: anytype) i32 {
fn fill(st: *State, need: usize) i32 {
if (st.eof) { return \-1; } // unexpected EOF
// Error: lexeme too long. In real life can reallocate a larger buffer.
@@ -2860,7 +2903,7 @@ fn fill(st: *State, need: usize, file: anytype) i32 {
st.token = 0;
// Fill free space at the end of buffer with new data from file.
st.yylimit += file.read(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yylimit += st.file.readSliceShort(st.yyinput[st.yylimit..bufsize]) catch 0;
// If read less than expected, this is the end of input.
if (st.yylimit < bufsize) {
@@ -2872,13 +2915,13 @@ fn fill(st: *State, need: usize, file: anytype) i32 {
return 0;
}
fn lex(yyrecord: *State, file: anytype) i32 {
fn lex(yyrecord: *State) i32 {
var count: i32 = 0;
loop: while (true) {
yyrecord.token = yyrecord.yycursor;
%{
re2c:api = record;
re2c:YYFILL = \(dq{ if (fill(yyrecord, @@, file) != 0) return \-2; }\(dq;
re2c:YYFILL = \(dq{ if (fill(yyrecord, @@) != 0) return \-2; }\(dq;
str = [\(aq] ([^\(aq\e\e] | [\e\e][^])* [\(aq];
@@ -2906,10 +2949,12 @@ test {
// Prepare lexer state: all offsets are at the end of buffer.
// This immediately triggers YYFILL, as the YYLESSTHAN condition is true.
var fr = try std.fs.cwd().openFile(fname, .{ .mode = .read_only});
// Normally file would be part of the state struct, but BufferedReader type is unclear.
var br = std.io.bufferedReader(fr.reader());
// Use unbuffered reader \- lexer does its own buffering.
const zerobuf: [0]u8 = undefined;
var fr = try std.fs.cwd().openFile(fname, .{.mode = .read_only});
var reader = fr.reader(&zerobuf);
var st = State{
.file = &reader.interface,
.yyinput = undefined,
.yycursor = bufsize,
.yymarker = bufsize,
@@ -2920,7 +2965,7 @@ test {
@memset(st.yyinput[st.yylimit..st.yylimit + yymaxfill], 0); // zero\-padding at the end
// Run the lexer.
try std.testing.expectEqual(lex(&st, &br), count);
try std.testing.expectEqual(lex(&st), count);
// Cleanup: remove input file.
fr.close();
@@ -3261,6 +3306,7 @@ const Status = enum {
const bufsize = 10;
const State = struct {
file: std.fs.File.Reader,
yyinput: [bufsize + 1]u8,
yycursor: usize,
yymarker: usize,
@@ -3270,7 +3316,7 @@ const State = struct {
received: usize,
};
fn fill(st: *State, file: anytype) Status {
fn fill(st: *State) Status {
// Error: lexeme too long. In real life can reallocate a larger buffer.
if (st.token < 1) { return Status.big_packet; }
@@ -3283,7 +3329,7 @@ fn fill(st: *State, file: anytype) Status {
st.token = 0;
// Fill free space at the end of buffer with new data from file.
st.yylimit += file.read(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yylimit += st.file.interface.readSliceShort(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yyinput[st.yylimit] = 0; // append sentinel symbol
return Status.ready;
@@ -3314,10 +3360,10 @@ fn run(expect: Status, packets: []const []const u8) !void {
var fr = try std.fs.cwd().openFile(fname, .{ .mode = .read_only});
// Initialize lexer state: \(gastate\(ga value is \-1, all offsets are at the end
// of buffer. Normally file would be part of the state, but BufferedReader
// type is unclear.
var br = std.io.bufferedReader(fr.reader());
// of buffer. Use unbuffered reader \- lexer does its own buffering.
const zerobuf: [0]u8 = undefined;
var st = State{
.file = fr.reader(&zerobuf),
.yyinput = undefined,
.yycursor = bufsize,
.yymarker = bufsize,
@@ -3344,7 +3390,7 @@ fn run(expect: Status, packets: []const []const u8) !void {
try fw.writeAll(packets[send]);
send += 1;
}
status = fill(&st, &br);
status = fill(&st);
std.log.debug(\(dqfilled buffer [{s}], status {}\(dq, .{st.yyinput, status});
if (status != Status.ready) {
break;
@@ -3695,6 +3741,7 @@ fn s2n(str: []const u8) u32 { // convert a pre\-parsed string to a number
}
const State = struct {
file: *std.Io.Reader,
yyinput: [bufsize + 1]u8,
yycursor: usize,
yymarker: usize,
@@ -3706,7 +3753,7 @@ const State = struct {
eof: bool
};
fn fill(st: *State, file: anytype) i32 {
fn fill(st: *State) i32 {
if (st.eof) { return \-1; } // unexpected EOF
// Error: lexeme too long. In real life can reallocate a larger buffer.
@@ -3725,7 +3772,7 @@ fn fill(st: *State, file: anytype) i32 {
st.token = 0;
// Fill free space at the end of buffer with new data from file.
st.yylimit += file.read(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yylimit += st.file.readSliceShort(st.yyinput[st.yylimit..bufsize]) catch 0;
st.yyinput[st.yylimit] = 0; // append sentinel symbol
// If read less than expected, this is the end of input.
@@ -3734,8 +3781,8 @@ fn fill(st: *State, file: anytype) i32 {
return 0;
}
fn parse(st: *State, file: anytype) !std.ArrayList(SemVer) {
var vers = std.ArrayList(SemVer).init(std.testing.allocator);
fn parse(st: *State) !std.ArrayList(SemVer) {
var vers = try std.ArrayList(SemVer).initCapacity(std.testing.allocator, 0);
// Final tag variables available in semantic action.
%{svars format = \(dqvar @@: usize = 0;\en\(dq; %}
@@ -3747,12 +3794,12 @@ fn parse(st: *State, file: anytype) !std.ArrayList(SemVer) {
re2c:eof = 0;
re2c:tags = 1;
re2c:yyrecord = st;
re2c:YYFILL = \(dqfill(st, file) == 0\(dq;
re2c:YYFILL = \(dqfill(st) == 0\(dq;
num = [0\-9]+;
num @t1 \(dq.\(dq @t2 num @t3 (\(dq.\(dq @t4 num)? [\en] {
try vers.append(SemVer {
try vers.append(std.testing.allocator, SemVer {
.major = s2n(st.yyinput[st.token..t1]),
.minor = s2n(st.yyinput[t2..t3]),
.patch = if (t4 == none) 0 else s2n(st.yyinput[t4..st.yycursor \- 1]),
@@ -3776,10 +3823,12 @@ test {
fw.close();
// Prepare lexer state: all offsets are at the end of buffer.
var fr = try std.fs.cwd().openFile(fname, .{ .mode = .read_only});
// Normally file would be part of the state struct, but BufferedReader type is unclear.
var br = std.io.bufferedReader(fr.reader());
// Use unbuffered reader \- lexer does its own buffering.
const zerobuf: [0]u8 = undefined;
var fr = try std.fs.cwd().openFile(fname, .{.mode = .read_only});
var reader = fr.reader(&zerobuf);
var st = State{
.file = &reader.interface,
.yyinput = undefined,
.yycursor = bufsize,
.yymarker = bufsize,
@@ -3792,16 +3841,14 @@ test {
st.yyinput[st.yylimit] = 0;
// Manually construct expected result.
var expect = std.ArrayList(SemVer).init(std.testing.allocator);
for (0..bufsize) |_| try expect.append(SemVer{.major = 1, .minor = 22, .patch = 333});
var expect = [_]SemVer{SemVer{.major = 1, .minor = 22, .patch = 333}} ** bufsize;
// Run the lexer.
var result = try parse(&st, &br);
try std.testing.expectEqualDeep(result, expect);
var result = try parse(&st);
try std.testing.expectEqualDeep(&expect, result.items);
// Cleanup: free memory and remove input file.
expect.deinit();
result.deinit();
result.deinit(std.testing.allocator);
fr.close();
try std.fs.cwd().deleteFile(fname);
}
@@ -3900,7 +3947,7 @@ const MtagElem = struct {
// Append a single value to an m\-tag history.
fn add_mtag(trie: *std.ArrayList(MtagElem), mtag: usize, value: usize) !usize {
try trie.append(MtagElem{.elem = value, .pred = mtag});
try trie.append(std.testing.allocator, MtagElem{.elem = value, .pred = mtag});
return trie.items.len \- 1;
}
@@ -3923,7 +3970,7 @@ fn unwind(trie: *std.ArrayList(MtagElem),
if (ex != none and ey != none) {
// Both tags are valid string indices, extract component.
try ver.append(s2n(str[ex..ey]));
try ver.append(std.testing.allocator, s2n(str[ex..ey]));
} else {
// Both tags are none (this corresponds to zero repetitions).
std.debug.assert(ex == none and ey == none);
@@ -3939,8 +3986,8 @@ fn s2n(str: []const u8) u32 { // convert a pre\-parsed string to a number
fn parse(yyinput: [:0]const u8) !std.ArrayList(u32) {
var yycursor: usize = 0;
var yymarker: usize = 0;
var mt = std.ArrayList(MtagElem).init(std.testing.allocator);
defer mt.deinit();
var mt = try std.ArrayList(MtagElem).initCapacity(std.testing.allocator, 0);
defer mt.deinit(std.testing.allocator);
// Final tag variables available in semantic action.
%{svars format = \(dqvar @@: usize = none;\(dq; %}
@@ -3959,8 +4006,8 @@ fn parse(yyinput: [:0]const u8) !std.ArrayList(u32) {
num = [0\-9]+;
@t1 num @t2 (\(dq.\(dq #t3 num #t4)* [\ex00] {
var ver = std.ArrayList(u32).init(std.testing.allocator);
try ver.append(s2n(yyinput[t1..t2]));
var ver = try std.ArrayList(u32).initCapacity(std.testing.allocator, 0);
try ver.append(std.testing.allocator, s2n(yyinput[t1..t2]));
try unwind(&mt, t3, t4, yyinput, &ver);
return ver;
}
@@ -3970,20 +4017,16 @@ fn parse(yyinput: [:0]const u8) !std.ArrayList(u32) {
test {
var result = try parse(\(dq1\(dq);
var expect = std.ArrayList(u32).init(std.testing.allocator);
try expect.appendSlice(&[_]u32{1});
try std.testing.expectEqualDeep(result, expect);
expect.deinit();
result.deinit();
var expect = [_]u32{1};
try std.testing.expectEqualDeep(&expect, result.items);
result.deinit(std.testing.allocator);
}
test {
var result = try parse(\(dq1.2.3.4.5.6.7\(dq);
var expect = std.ArrayList(u32).init(std.testing.allocator);
try expect.appendSlice(&[_]u32{1, 2, 3, 4, 5, 6, 7});
try std.testing.expectEqualDeep(result, expect);
expect.deinit();
result.deinit();
var expect = [_]u32{1, 2, 3, 4, 5, 6, 7};
try std.testing.expectEqualDeep(&expect, result.items);
result.deinit(std.testing.allocator);
}
test {
@@ -4039,8 +4082,9 @@ fixed\-length Unicode encoding with code space \fB[0\-0x10FFFF]\fP and 4\-byte c
points and code units.
.UNINDENT
.sp
Include file \fBinclude/unicode_categories.re\fP provides re2zig definitions for the
standard Unicode categories.
Include files \fBinclude/unicode_blocks.re\fP, \fBinclude/unicode_categories.re\fP
and \fBinclude/unicode_properties.re\fP provide re2zig definitions for blocks,
categories and properties described in the Unicode standard.
.sp
Option \fB\-\-input\-encoding\fP specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
+1 -1
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 4.2 */
/* Generated by re2c 4.6 */
#line 1 "../lib/lex.re"
#include <stdint.h>
#include <stdio.h>
+1 -1
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 4.2 */
/* Generated by re2c 4.6 */
#line 1 "../lib/test_helper.re"
#include "lib/test_helper.h"
+9 -3
View File
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_C =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_C =
"re2c:YYCTYPE = \"YYCTYPE\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \"->yycursor\" : \"YYCURSOR\");\n"
"re2c:YYDEBUG = \"YYDEBUG\";\n"
"re2c:YYEND = \"YYEND\";\n"
"re2c:YYFILL = \"YYFILL\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"YYGETCONDITION\"; // historic default\n"
@@ -174,8 +175,8 @@ static constexpr const char* DEFAULT_SYNTAX_C =
"\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"
" [elem{0:-2}: topindent elem (!.code_model.goto_label ? \" = \" init) \",\" nl]\n"
" [elem{-1}: topindent elem (!.code_model.goto_label ? \" = \" init) nl]\n"
" dedent \"};\" nl;\n"
"\n"
"code:enum_elem = name;\n"
@@ -451,6 +452,11 @@ static constexpr const char* DEFAULT_SYNTAX_C =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND (.api_style.functions ? \"()\")\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = yybm \"[\" offset \"+\" yych \"] & \" mask;\n"
+9 -3
View File
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_D =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_D =
"re2c:YYCTYPE = \"YYChar\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -174,8 +175,8 @@ static constexpr const char* DEFAULT_SYNTAX_D =
"\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"
" [elem{0:-2}: topindent elem (!.code_model.goto_label ? \" = \" init) \",\" nl]\n"
" [elem{-1}: topindent elem (!.code_model.goto_label ? \" = \" init) nl]\n"
" dedent \"};\" nl;\n"
"\n"
"code:enum_elem = type \".\" name;\n"
@@ -424,6 +425,11 @@ static constexpr const char* DEFAULT_SYNTAX_D =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
+9 -3
View File
@@ -62,11 +62,11 @@ static constexpr const char* DEFAULT_SYNTAX_GO =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -122,6 +122,7 @@ static constexpr const char* DEFAULT_SYNTAX_GO =
"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:YYEND = \"YYEND\";\n"
"re2c:YYFILL = \"YYFILL\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"YYGETCONDITION\"; // historic default\n"
@@ -175,8 +176,8 @@ static constexpr const char* DEFAULT_SYNTAX_GO =
"\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"
" [elem{0}: topindent elem \" = \" (!.code_model.goto_label ? init : \"iota\") nl]\n"
" [elem{1:-1}: topindent elem (!.code_model.goto_label ? \" = \" init) nl]\n"
" dedent \")\" nl;\n"
"\n"
"code:enum_elem = name;\n"
@@ -406,6 +407,11 @@ static constexpr const char* DEFAULT_SYNTAX_GO =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND (.api_style.functions ? \"()\")\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
+7 -1
View File
@@ -62,11 +62,11 @@ static constexpr const char* DEFAULT_SYNTAX_HASKELL =
"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 = \"yyfill\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -122,6 +122,7 @@ static constexpr const char* DEFAULT_SYNTAX_HASKELL =
"re2c:YYCTXMARKER = \"_yyctxmarker\";\n"
"re2c:YYCURSOR = \"_yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = \"yygetaccept\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -415,6 +416,11 @@ static constexpr const char* DEFAULT_SYNTAX_HASKELL =
" ? YYCURSOR \" >= \" YYLIMIT // YYFILL check can only be used with EOF rule $\n"
" : YYLESSTHAN);\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYCURSOR \" >= \" YYLIMIT);\n"
"\n"
"code:yybm_filter = \"(\" yych \" .&. complement 0xFF) /= 0\";\n"
"\n"
"code:yybm_match = \"(\" yybm \" ! (\" offset \" + fromIntegral \" yych \") .&. \" mask \") /= 0\";\n"
+7 -1
View File
@@ -62,11 +62,11 @@ static constexpr const char* DEFAULT_SYNTAX_JAVA =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -122,6 +122,7 @@ static constexpr const char* DEFAULT_SYNTAX_JAVA =
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -381,6 +382,11 @@ static constexpr const char* DEFAULT_SYNTAX_JAVA =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
+7 -1
View File
@@ -62,11 +62,11 @@ static constexpr const char* DEFAULT_SYNTAX_JS =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -122,6 +122,7 @@ static constexpr const char* DEFAULT_SYNTAX_JS =
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -384,6 +385,11 @@ static constexpr const char* DEFAULT_SYNTAX_JS =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") !== 0\";\n"
+7 -1
View File
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_OCAML =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_OCAML =
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -394,6 +395,11 @@ static constexpr const char* DEFAULT_SYNTAX_OCAML =
" : YYLIMIT \" <= \" YYCURSOR)\n"
" : YYLESSTHAN);\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" land ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \".(\" offset \" + Char.code \" yych \") land \" mask \") != 0\";\n"
+7 -1
View File
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_PYTHON =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_PYTHON =
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -389,6 +390,11 @@ static constexpr const char* DEFAULT_SYNTAX_PYTHON =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
+7 -1
View File
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_RUST =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_RUST =
"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:YYEND = \"YYEND\";\n"
"re2c:YYFILL = \"YYFILL\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"YYGETCONDITION\"; // historic default\n"
@@ -407,6 +408,11 @@ static constexpr const char* DEFAULT_SYNTAX_RUST =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \" as usize] & \" mask \") != 0\";\n"
+7 -1
View File
@@ -62,11 +62,11 @@ static constexpr const char* DEFAULT_SYNTAX_SWIFT =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_SWIFT =
"re2c:YYCTYPE = \"UInt8\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -409,6 +410,11 @@ static constexpr const char* DEFAULT_SYNTAX_SWIFT =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \" + Int(\" yych \")] & \" mask \") != 0\";\n"
+9 -3
View File
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_V =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_V =
"re2c:YYCTXMARKER = (.api.record ? yyrecord \".\") \"yyctxmarker\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -156,7 +157,7 @@ static constexpr const char* DEFAULT_SYNTAX_V =
"\n"
"// code templates --------------------------------------------------------------\n"
"\n"
"code:var_local = topindent \"mut \" name \" := \" init nl;\n"
"code:var_local = topindent \"mut \" name \" := \" type \"(\" init \")\" nl;\n"
"code:var_global = <undefined>;\n"
"\n"
"code:const_local = topindent \"const \" name \" = \" init nl;\n"
@@ -176,7 +177,7 @@ static constexpr const char* DEFAULT_SYNTAX_V =
"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"
" indent [elem: topindent elem (!.code_model.goto_label ? \" = \" init) nl] dedent\n"
" \"}\" nl);\n"
"\n"
"code:enum_elem = (!.code_model.loop_switch ? \".\") name;\n"
@@ -408,6 +409,11 @@ static constexpr const char* DEFAULT_SYNTAX_V =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
+21 -6
View File
@@ -6,7 +6,7 @@ static constexpr const char* DEFAULT_SYNTAX_ZIG =
"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"
" \"tags\", \"captures\", \"captvars\", \"computed-continue\"];\n"
"\n"
"\n"
"// language-specific options ---------------------------------------------------\n"
@@ -63,11 +63,11 @@ static constexpr const char* DEFAULT_SYNTAX_ZIG =
"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 = \"\";\n"
"re2c:yyfill:enable = 1;\n"
"re2c:yyfill:parameter = 1;\n"
"re2c:yyfill:check = 1;\n"
@@ -123,6 +123,7 @@ static constexpr const char* DEFAULT_SYNTAX_ZIG =
"re2c:YYCTYPE = \"u8\";\n"
"re2c:YYCURSOR = (.api.record ? yyrecord \".\") \"yycursor\";\n"
"re2c:YYDEBUG = \"yydebug\";\n"
"re2c:YYEND = \"yyend\";\n"
"re2c:YYFILL = \"yyfill\";\n"
"re2c:YYGETACCEPT = sigil \"{var}\";\n"
"re2c:YYGETCOND = \"yygetcond\";\n"
@@ -220,12 +221,21 @@ static constexpr const char* DEFAULT_SYNTAX_ZIG =
"\n"
"code:switch_case_default = \"else\";\n"
"\n"
"code:loop =\n"
" topindent (.loop_label ? label \": \") \"while (true) {\" nl\n"
"code:loop = (.computed_continue\n"
" ? topindent var \": switch (@as(enum {\" nl\n"
" indent [state: topindent state \",\" nl] dedent\n"
" topindent \"}, .\" val \")) {\" nl\n"
" indent [state:\n"
" topindent \".\" state \" => {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"},\" nl] dedent\n"
" topindent \"}\" nl\n"
" : topindent (.loop_label ? label \": \") \"while (true) {\" nl\n"
" indent [stmt: stmt] dedent\n"
" topindent \"}\" nl;\n"
" topindent \"}\" nl);\n"
"\n"
"code:continue = topindent \"continue\" (.loop_label ? \" :\" label) \";\" nl;\n"
"code:continue = topindent \"continue\"\n"
" (.computed_continue ? \" :\" var \" .\" val : (.loop_label ? \" :\" label)) \";\" nl;\n"
"\n"
"code:goto = topindent \"goto \" label \";\" nl;\n"
"\n"
@@ -422,6 +432,11 @@ static constexpr const char* DEFAULT_SYNTAX_ZIG =
" ? \"(\" YYLIMIT \" - \" YYCURSOR \") < \" need\n"
" : YYLIMIT \" <= \" YYCURSOR));\n"
"\n"
"code:yyend =\n"
" (.api.generic | .yyfill.enable\n"
" ? YYEND\n"
" : YYLIMIT \" <= \" YYCURSOR);\n"
"\n"
"code:yybm_filter = yych \" & ~0xFF\";\n"
"\n"
"code:yybm_match = \"(\" yybm \"[\" offset \"+\" yych \"] & \" mask \") != 0\";\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2c\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2d\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2go\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2hs\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -177,6 +177,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -490,6 +497,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2java\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2js\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -178,6 +178,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -491,6 +498,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2ocaml\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2py\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -177,6 +177,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -490,6 +497,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2rust\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -178,6 +178,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -491,6 +498,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2swift\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -176,6 +176,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -489,6 +496,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2v\n"
+16 -1
View File
@@ -15,7 +15,7 @@ const char* help =
" --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"
" defined code. Option simple should 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"
@@ -177,6 +177,13 @@ const char* help =
" to the case label of the destination state and continue execution to\n"
" the head of the loop.\n"
"\n"
" --computed-continue\n"
"\n"
" This option requires the --loop-switch code model. It uses computed\n"
" continue statements to select the next switch case directly, enabling\n"
" jump-table optimization similar to --computed-gotos in the goto/label\n"
" code model.\n"
"\n"
" --nested-ifs -s\n"
"\n"
" Use nested if statements instead of switch statements in conditional\n"
@@ -490,6 +497,14 @@ const char* help =
"\n"
" Warn about rules that are shadowed by other rules and will never match.\n"
"\n"
" -Wdeprecated-eof_rule\n"
"\n"
" Warn about standalone end of input rules $ that will be broken by the\n"
" future changes and require fixing. At the moment these rules take\n"
" precedence when conflicting with other rules, but after the\n"
" introduction of generalized end of input symbol $ precedence order will\n"
" change and these rules will become shadowed by other rules.\n"
"\n"
" -Wuseless-escape\n"
"\n"
" Warn if a symbol is escaped when it shouldn't be. By default, re2zig\n"
+1 -1
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 4.2 */
/* Generated by re2c 4.6 */
#line 1 "../src/msg/ver_to_vernum.re"
#include <stddef.h>
#include <stdint.h>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2227 -2219
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 4.2 */
/* Generated by re2c 4.6 */
#ifndef _RE2C_PARSE_LEX_
#define _RE2C_PARSE_LEX_
+178 -201
View File
@@ -147,28 +147,27 @@ enum yysymbol_kind_t
YYSYMBOL_23_ = 23, /* '=' */
YYSYMBOL_24_ = 24, /* ';' */
YYSYMBOL_25_ = 25, /* '*' */
YYSYMBOL_26_ = 26, /* '$' */
YYSYMBOL_27_ = 27, /* '|' */
YYSYMBOL_28_ = 28, /* '\\' */
YYSYMBOL_29_ = 29, /* '+' */
YYSYMBOL_30_ = 30, /* '?' */
YYSYMBOL_31_ = 31, /* '(' */
YYSYMBOL_32_ = 32, /* ')' */
YYSYMBOL_YYACCEPT = 33, /* $accept */
YYSYMBOL_spec = 34, /* spec */
YYSYMBOL_def = 35, /* def */
YYSYMBOL_name = 36, /* name */
YYSYMBOL_enddef = 37, /* enddef */
YYSYMBOL_rule = 38, /* rule */
YYSYMBOL_ccode = 39, /* ccode */
YYSYMBOL_trailexpr = 40, /* trailexpr */
YYSYMBOL_expr = 41, /* expr */
YYSYMBOL_diff = 42, /* diff */
YYSYMBOL_term = 43, /* term */
YYSYMBOL_factor = 44, /* factor */
YYSYMBOL_closes = 45, /* closes */
YYSYMBOL_close = 46, /* close */
YYSYMBOL_primary = 47 /* primary */
YYSYMBOL_26_ = 26, /* '|' */
YYSYMBOL_27_ = 27, /* '\\' */
YYSYMBOL_28_ = 28, /* '+' */
YYSYMBOL_29_ = 29, /* '?' */
YYSYMBOL_30_ = 30, /* '(' */
YYSYMBOL_31_ = 31, /* ')' */
YYSYMBOL_YYACCEPT = 32, /* $accept */
YYSYMBOL_spec = 33, /* spec */
YYSYMBOL_def = 34, /* def */
YYSYMBOL_name = 35, /* name */
YYSYMBOL_enddef = 36, /* enddef */
YYSYMBOL_rule = 37, /* rule */
YYSYMBOL_ccode = 38, /* ccode */
YYSYMBOL_trailexpr = 39, /* trailexpr */
YYSYMBOL_expr = 40, /* expr */
YYSYMBOL_diff = 41, /* diff */
YYSYMBOL_term = 42, /* term */
YYSYMBOL_factor = 43, /* factor */
YYSYMBOL_closes = 44, /* closes */
YYSYMBOL_close = 45, /* close */
YYSYMBOL_primary = 46 /* primary */
};
typedef enum yysymbol_kind_t yysymbol_kind_t;
@@ -496,16 +495,16 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 2
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 75
#define YYLAST 71
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 33
#define YYNTOKENS 32
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 15
/* YYNRULES -- Number of rules. */
#define YYNRULES 50
#define YYNRULES 48
/* YYNSTATES -- Number of states. */
#define YYNSTATES 77
#define YYNSTATES 73
/* YYMAXUTOK -- Last valid token kind. */
#define YYMAXUTOK 276
@@ -525,16 +524,16 @@ 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, 26, 2, 2, 2,
31, 32, 25, 29, 2, 2, 2, 22, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
30, 31, 25, 28, 2, 2, 2, 22, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 24,
2, 23, 2, 30, 2, 2, 2, 2, 2, 2,
2, 23, 2, 29, 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, 28, 2, 2, 2, 2, 2, 2, 2,
2, 2, 27, 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, 27, 2, 2, 2, 2, 2,
2, 2, 2, 2, 26, 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,
@@ -558,10 +557,9 @@ static const yytype_uint8 yyrline[] =
{
0, 81, 81, 82, 86, 90, 91, 92, 96, 99,
105, 106, 109, 109, 112, 115, 118, 121, 124, 127,
130, 136, 142, 148, 154, 160, 166, 172, 179, 180,
185, 190, 191, 197, 198, 202, 203, 207, 209, 213,
214, 227, 233, 234, 238, 239, 240, 244, 245, 254,
255
133, 139, 145, 151, 157, 163, 170, 171, 176, 181,
182, 188, 189, 193, 194, 198, 200, 204, 205, 218,
224, 225, 229, 230, 231, 235, 236, 245, 246
};
#endif
@@ -582,8 +580,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_ENTRY", "TOKEN_PRE_RULE", "TOKEN_POST_RULE", "TOKEN_LPAREN_NEG",
"TOKEN_ERROR", "'/'", "'='", "';'", "'*'", "'$'", "'|'", "'\\\\'", "'+'",
"'?'", "'('", "')'", "$accept", "spec", "def", "name", "enddef", "rule",
"TOKEN_ERROR", "'/'", "'='", "';'", "'*'", "'|'", "'\\\\'", "'+'", "'?'",
"'('", "')'", "$accept", "spec", "def", "name", "enddef", "rule",
"ccode", "trailexpr", "expr", "diff", "term", "factor", "closes",
"close", "primary", YY_NULLPTR
};
@@ -595,7 +593,7 @@ yysymbol_name (yysymbol_kind_t yysymbol)
}
#endif
#define YYPACT_NINF (-25)
#define YYPACT_NINF (-23)
#define yypact_value_is_default(Yyn) \
((Yyn) == YYPACT_NINF)
@@ -609,14 +607,14 @@ yysymbol_name (yysymbol_kind_t yysymbol)
STATE-NUM. */
static const yytype_int8 yypact[] =
{
-25, 1, -25, 30, 5, 20, -25, -13, -25, -25,
-25, -25, 25, 31, 43, 22, 48, 54, 22, -25,
22, -25, 55, -18, 10, -25, 22, 14, -25, 20,
20, 20, 20, 20, 20, -25, -25, 63, -25, -25,
-25, -25, -25, -25, -2, -25, -25, 4, 38, -25,
22, 22, 22, -25, -25, -25, -25, -25, 29, -25,
-25, -25, -25, -25, -25, -25, -25, -25, -25, -25,
-25, -25, -25, 19, 10, -25, -25
-23, 1, -23, 29, 42, 26, -23, -13, -23, -23,
-23, -23, 44, 48, 49, -6, 56, -6, -23, -6,
-23, 57, 11, 40, -23, -6, 14, -23, 26, 26,
26, 26, 26, -23, -23, 59, -23, -23, -23, -23,
-23, -23, -3, -23, 19, 12, -23, -6, -6, -6,
-23, -23, -23, -23, -23, 27, -23, -23, -23, -23,
-23, -23, -23, -23, -23, -23, -23, -23, -23, 15,
40, -23, -23
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -624,28 +622,28 @@ static const yytype_int8 yypact[] =
means the default is an error. */
static const yytype_int8 yydefact[] =
{
2, 0, 1, 0, 0, 0, 4, 48, 11, 7,
47, 3, 0, 0, 0, 0, 0, 0, 0, 5,
0, 6, 0, 31, 33, 35, 37, 39, 48, 0,
0, 0, 0, 0, 0, 26, 30, 0, 28, 27,
10, 17, 18, 19, 0, 15, 16, 0, 0, 14,
0, 0, 0, 38, 41, 44, 45, 46, 40, 42,
23, 24, 25, 21, 22, 20, 29, 50, 49, 13,
9, 12, 8, 32, 34, 36, 43
2, 0, 1, 0, 0, 0, 4, 46, 11, 7,
45, 3, 0, 0, 0, 0, 0, 0, 5, 0,
6, 0, 29, 31, 33, 35, 37, 46, 0, 0,
0, 0, 0, 24, 28, 0, 26, 25, 10, 16,
17, 18, 0, 15, 0, 0, 14, 0, 0, 0,
36, 39, 42, 43, 44, 38, 40, 21, 22, 23,
20, 19, 27, 48, 47, 13, 9, 12, 8, 30,
32, 34, 41
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-25, -25, -25, -25, -25, -25, 37, 70, -15, 23,
-24, -25, -25, 17, -25
-23, -23, -23, -23, -23, -23, 32, 66, -15, 22,
-22, -23, -23, 16, -23
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
0, 1, 19, 20, 72, 21, 39, 22, 23, 24,
25, 26, 58, 59, 27
0, 1, 18, 19, 68, 20, 37, 21, 22, 23,
24, 25, 55, 56, 26
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -653,62 +651,60 @@ static const yytype_int8 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int8 yytable[] =
{
44, 2, 53, 47, 50, 48, 3, 4, 5, 51,
40, 6, 7, 8, 35, 9, 10, 11, 12, 13,
14, 15, 54, 36, 37, 51, 16, 17, 75, 38,
67, 51, 18, 28, 41, 73, 68, 10, 52, 55,
42, 28, 15, 56, 57, 10, 51, 29, 30, 31,
15, 69, 43, 18, 55, 32, 33, 45, 56, 57,
70, 18, 71, 46, 49, 51, 60, 61, 62, 63,
64, 65, 66, 34, 74, 76
42, 2, 44, 50, 45, 27, 3, 4, 5, 10,
38, 6, 7, 8, 15, 9, 10, 11, 12, 13,
14, 15, 51, 48, 17, 65, 16, 71, 63, 34,
35, 17, 69, 47, 66, 36, 67, 48, 48, 52,
27, 48, 53, 54, 10, 48, 28, 29, 30, 15,
64, 33, 52, 39, 31, 53, 54, 40, 41, 17,
57, 58, 59, 60, 61, 43, 46, 49, 62, 32,
70, 72
};
static const yytype_int8 yycheck[] =
{
15, 0, 26, 18, 22, 20, 5, 6, 7, 27,
23, 10, 11, 12, 9, 14, 15, 16, 17, 18,
19, 20, 8, 3, 4, 27, 25, 26, 52, 9,
32, 27, 31, 11, 9, 50, 32, 15, 28, 25,
9, 11, 20, 29, 30, 15, 27, 17, 18, 19,
20, 13, 9, 31, 25, 25, 26, 9, 29, 30,
22, 31, 24, 9, 9, 27, 29, 30, 31, 32,
33, 34, 9, 3, 51, 58
15, 0, 17, 25, 19, 11, 5, 6, 7, 15,
23, 10, 11, 12, 20, 14, 15, 16, 17, 18,
19, 20, 8, 26, 30, 13, 25, 49, 31, 3,
4, 30, 47, 22, 22, 9, 24, 26, 26, 25,
11, 26, 28, 29, 15, 26, 17, 18, 19, 20,
31, 9, 25, 9, 25, 28, 29, 9, 9, 30,
28, 29, 30, 31, 32, 9, 9, 27, 9, 3,
48, 55
};
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
state STATE-NUM. */
static const yytype_int8 yystos[] =
{
0, 34, 0, 5, 6, 7, 10, 11, 12, 14,
15, 16, 17, 18, 19, 20, 25, 26, 31, 35,
36, 38, 40, 41, 42, 43, 44, 47, 11, 17,
18, 19, 25, 26, 40, 9, 3, 4, 9, 39,
23, 9, 9, 9, 41, 9, 9, 41, 41, 9,
22, 27, 28, 43, 8, 25, 29, 30, 45, 46,
39, 39, 39, 39, 39, 39, 9, 32, 32, 13,
22, 24, 37, 41, 42, 43, 46
0, 33, 0, 5, 6, 7, 10, 11, 12, 14,
15, 16, 17, 18, 19, 20, 25, 30, 34, 35,
37, 39, 40, 41, 42, 43, 46, 11, 17, 18,
19, 25, 39, 9, 3, 4, 9, 38, 23, 9,
9, 9, 40, 9, 40, 40, 9, 22, 26, 27,
42, 8, 25, 28, 29, 44, 45, 38, 38, 38,
38, 38, 9, 31, 31, 13, 22, 24, 36, 40,
41, 42, 45
};
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
static const yytype_int8 yyr1[] =
{
0, 33, 34, 34, 34, 34, 34, 34, 35, 35,
36, 36, 37, 37, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38, 39, 39,
39, 40, 40, 41, 41, 42, 42, 43, 43, 44,
44, 44, 45, 45, 46, 46, 46, 47, 47, 47,
47
0, 32, 33, 33, 33, 33, 33, 33, 34, 34,
35, 35, 36, 36, 37, 37, 37, 37, 37, 37,
37, 37, 37, 37, 37, 37, 38, 38, 38, 39,
39, 40, 40, 41, 41, 42, 42, 43, 43, 43,
44, 44, 45, 45, 45, 46, 46, 46, 46
};
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
static const yytype_int8 yyr2[] =
{
0, 2, 0, 2, 2, 2, 2, 2, 3, 3,
2, 1, 1, 1, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 2, 2, 1, 2,
1, 1, 3, 1, 3, 1, 3, 1, 2, 1,
2, 2, 1, 2, 1, 1, 1, 1, 1, 3,
3
2, 1, 1, 1, 2, 2, 2, 2, 2, 3,
3, 3, 3, 3, 2, 2, 1, 2, 1, 1,
3, 1, 3, 1, 3, 1, 2, 1, 2, 2,
1, 2, 1, 1, 1, 1, 1, 3, 3
};
@@ -1191,7 +1187,7 @@ yyreduce:
if (use_block(input, ast, opts, grams, ast.temp_blockname) != Ret::OK) YYABORT;
ast.temp_blockname.clear();
}
#line 1195 "src/parse/parser.cc"
#line 1191 "src/parse/parser.cc"
break;
case 4: /* spec: spec TOKEN_CONF */
@@ -1200,7 +1196,7 @@ yyreduce:
// Handled here, as the main lexer should not get access to opts under construction.
if (input.lex_conf(opts) != Ret::OK) YYABORT;
}
#line 1204 "src/parse/parser.cc"
#line 1200 "src/parse/parser.cc"
break;
case 8: /* def: name expr enddef */
@@ -1208,7 +1204,7 @@ yyreduce:
{
if (add_named_def(opts.symtab, (yyvsp[-2].cstr), (yyvsp[-1].regexp), input) != Ret::OK) YYABORT;
}
#line 1212 "src/parse/parser.cc"
#line 1208 "src/parse/parser.cc"
break;
case 9: /* def: name expr '/' */
@@ -1217,21 +1213,21 @@ yyreduce:
input.error_at_tok("trailing contexts are not allowed in named definitions");
YYABORT;
}
#line 1221 "src/parse/parser.cc"
#line 1217 "src/parse/parser.cc"
break;
case 10: /* name: TOKEN_ID '=' */
#line 105 "../src/parse/parser.ypp"
{ (yyval.cstr) = (yyvsp[-1].cstr); }
#line 1227 "src/parse/parser.cc"
#line 1223 "src/parse/parser.cc"
break;
case 14: /* rule: trailexpr TOKEN_CODE */
#line 112 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").rules.push_back(AstRule((yyvsp[-1].regexp), (yyvsp[0].semact)));
find_or_add_gram(grams, "").rules.push_back({(yyvsp[-1].regexp), (yyvsp[0].semact)});
}
#line 1235 "src/parse/parser.cc"
#line 1231 "src/parse/parser.cc"
break;
case 15: /* rule: '*' TOKEN_CODE */
@@ -1239,181 +1235,162 @@ yyreduce:
{
find_or_add_gram(grams, "").defs.push_back((yyvsp[0].semact));
}
#line 1243 "src/parse/parser.cc"
#line 1239 "src/parse/parser.cc"
break;
case 16: /* rule: '$' TOKEN_CODE */
case 16: /* rule: TOKEN_ENTRY TOKEN_CODE */
#line 118 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").eofs.push_back((yyvsp[0].semact));
}
#line 1251 "src/parse/parser.cc"
break;
case 17: /* rule: TOKEN_ENTRY TOKEN_CODE */
#line 121 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").entry.push_back((yyvsp[0].semact));
}
#line 1259 "src/parse/parser.cc"
#line 1247 "src/parse/parser.cc"
break;
case 18: /* rule: TOKEN_PRE_RULE TOKEN_CODE */
#line 124 "../src/parse/parser.ypp"
case 17: /* rule: TOKEN_PRE_RULE TOKEN_CODE */
#line 121 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").pre_rule.push_back((yyvsp[0].semact));
}
#line 1267 "src/parse/parser.cc"
#line 1255 "src/parse/parser.cc"
break;
case 19: /* rule: TOKEN_POST_RULE TOKEN_CODE */
#line 127 "../src/parse/parser.ypp"
case 18: /* rule: TOKEN_POST_RULE TOKEN_CODE */
#line 124 "../src/parse/parser.ypp"
{
find_or_add_gram(grams, "").post_rule.push_back((yyvsp[0].semact));
}
#line 1275 "src/parse/parser.cc"
#line 1263 "src/parse/parser.cc"
break;
case 20: /* rule: TOKEN_CLIST trailexpr ccode */
#line 130 "../src/parse/parser.ypp"
case 19: /* rule: TOKEN_CLIST trailexpr ccode */
#line 127 "../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)));
find_or_add_gram(grams, cond).rules.push_back({(yyvsp[-1].regexp), (yyvsp[0].semact)});
}
ast.temp_condlist.clear();
}
#line 1286 "src/parse/parser.cc"
#line 1274 "src/parse/parser.cc"
break;
case 21: /* rule: TOKEN_CLIST '*' ccode */
#line 136 "../src/parse/parser.ypp"
case 20: /* rule: TOKEN_CLIST '*' ccode */
#line 133 "../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 1297 "src/parse/parser.cc"
#line 1285 "src/parse/parser.cc"
break;
case 22: /* rule: TOKEN_CLIST '$' ccode */
#line 142 "../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 1308 "src/parse/parser.cc"
break;
case 23: /* rule: TOKEN_CLIST TOKEN_ENTRY ccode */
#line 148 "../src/parse/parser.ypp"
case 21: /* rule: TOKEN_CLIST TOKEN_ENTRY ccode */
#line 139 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).entry.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1319 "src/parse/parser.cc"
#line 1296 "src/parse/parser.cc"
break;
case 24: /* rule: TOKEN_CLIST TOKEN_PRE_RULE ccode */
#line 154 "../src/parse/parser.ypp"
case 22: /* rule: TOKEN_CLIST TOKEN_PRE_RULE ccode */
#line 145 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).pre_rule.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1330 "src/parse/parser.cc"
#line 1307 "src/parse/parser.cc"
break;
case 25: /* rule: TOKEN_CLIST TOKEN_POST_RULE ccode */
#line 160 "../src/parse/parser.ypp"
case 23: /* rule: TOKEN_CLIST TOKEN_POST_RULE ccode */
#line 151 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).post_rule.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1341 "src/parse/parser.cc"
#line 1318 "src/parse/parser.cc"
break;
case 26: /* rule: TOKEN_CPRE_RULE TOKEN_CODE */
#line 166 "../src/parse/parser.ypp"
case 24: /* rule: TOKEN_CPRE_RULE TOKEN_CODE */
#line 157 "../src/parse/parser.ypp"
{
for (const std::string& cond : ast.temp_condlist) {
find_or_add_gram(grams, cond).pre_rule.push_back((yyvsp[0].semact));
}
ast.temp_condlist.clear();
}
#line 1352 "src/parse/parser.cc"
#line 1329 "src/parse/parser.cc"
break;
case 27: /* rule: TOKEN_CZERO ccode */
#line 172 "../src/parse/parser.ypp"
case 25: /* rule: TOKEN_CZERO ccode */
#line 163 "../src/parse/parser.ypp"
{
const AstNode* r = ast.nil(input.tok_loc());
find_or_add_gram(grams, ZERO_COND).rules.push_back(AstRule(r, (yyvsp[0].semact)));
find_or_add_gram(grams, ZERO_COND).rules.push_back({r, (yyvsp[0].semact)});
ast.temp_condlist.clear();
}
#line 1362 "src/parse/parser.cc"
#line 1339 "src/parse/parser.cc"
break;
case 29: /* ccode: TOKEN_CNEXT TOKEN_CODE */
#line 180 "../src/parse/parser.ypp"
case 27: /* ccode: TOKEN_CNEXT TOKEN_CODE */
#line 171 "../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 1372 "src/parse/parser.cc"
#line 1349 "src/parse/parser.cc"
break;
case 30: /* ccode: TOKEN_CJUMP */
#line 185 "../src/parse/parser.ypp"
case 28: /* ccode: TOKEN_CJUMP */
#line 176 "../src/parse/parser.ypp"
{
(yyval.semact) = ast.sem_act(input.tok_loc(), nullptr, (yyvsp[0].cstr), true);
}
#line 1380 "src/parse/parser.cc"
#line 1357 "src/parse/parser.cc"
break;
case 31: /* trailexpr: expr */
#line 190 "../src/parse/parser.ypp"
case 29: /* trailexpr: expr */
#line 181 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[0].regexp), CAPTURE_IF_NOT_INVERTED); }
#line 1386 "src/parse/parser.cc"
#line 1363 "src/parse/parser.cc"
break;
case 32: /* trailexpr: expr '/' expr */
#line 191 "../src/parse/parser.ypp"
case 30: /* trailexpr: expr '/' expr */
#line 182 "../src/parse/parser.ypp"
{
(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 1395 "src/parse/parser.cc"
#line 1372 "src/parse/parser.cc"
break;
case 34: /* expr: expr '|' diff */
#line 198 "../src/parse/parser.ypp"
case 32: /* expr: expr '|' diff */
#line 189 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.alt((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
#line 1401 "src/parse/parser.cc"
#line 1378 "src/parse/parser.cc"
break;
case 36: /* diff: diff '\\' term */
#line 203 "../src/parse/parser.ypp"
case 34: /* diff: diff '\\' term */
#line 194 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.diff((yyvsp[-2].regexp), (yyvsp[0].regexp)); }
#line 1407 "src/parse/parser.cc"
#line 1384 "src/parse/parser.cc"
break;
case 38: /* term: factor term */
#line 209 "../src/parse/parser.ypp"
case 36: /* term: factor term */
#line 200 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cat((yyvsp[-1].regexp), (yyvsp[0].regexp)); }
#line 1413 "src/parse/parser.cc"
#line 1390 "src/parse/parser.cc"
break;
case 40: /* factor: primary closes */
#line 214 "../src/parse/parser.ypp"
case 38: /* factor: primary closes */
#line 205 "../src/parse/parser.ypp"
{
switch((yyvsp[0].op)) {
case '*':
@@ -1427,43 +1404,43 @@ yyreduce:
break;
}
}
#line 1431 "src/parse/parser.cc"
#line 1408 "src/parse/parser.cc"
break;
case 41: /* factor: primary TOKEN_CLOSESIZE */
#line 227 "../src/parse/parser.ypp"
case 39: /* factor: primary TOKEN_CLOSESIZE */
#line 218 "../src/parse/parser.ypp"
{
(yyval.regexp) = ast.iter((yyvsp[-1].regexp), (yyvsp[0].bounds).min, (yyvsp[0].bounds).max);
}
#line 1439 "src/parse/parser.cc"
#line 1416 "src/parse/parser.cc"
break;
case 43: /* closes: closes close */
#line 234 "../src/parse/parser.ypp"
case 41: /* closes: closes close */
#line 225 "../src/parse/parser.ypp"
{ (yyval.op) = ((yyvsp[-1].op) == (yyvsp[0].op)) ? (yyvsp[-1].op) : '*'; }
#line 1445 "src/parse/parser.cc"
#line 1422 "src/parse/parser.cc"
break;
case 44: /* close: '*' */
#line 238 "../src/parse/parser.ypp"
case 42: /* close: '*' */
#line 229 "../src/parse/parser.ypp"
{ (yyval.op) = '*'; }
#line 1451 "src/parse/parser.cc"
#line 1428 "src/parse/parser.cc"
break;
case 45: /* close: '+' */
#line 239 "../src/parse/parser.ypp"
case 43: /* close: '+' */
#line 230 "../src/parse/parser.ypp"
{ (yyval.op) = '+'; }
#line 1457 "src/parse/parser.cc"
#line 1434 "src/parse/parser.cc"
break;
case 46: /* close: '?' */
#line 240 "../src/parse/parser.ypp"
case 44: /* close: '?' */
#line 231 "../src/parse/parser.ypp"
{ (yyval.op) = '?'; }
#line 1463 "src/parse/parser.cc"
#line 1440 "src/parse/parser.cc"
break;
case 48: /* primary: TOKEN_ID */
#line 245 "../src/parse/parser.ypp"
case 46: /* primary: TOKEN_ID */
#line 236 "../src/parse/parser.ypp"
{
(yyval.regexp) = find_def(opts.symtab, (yyvsp[0].cstr));
if ((yyval.regexp) == nullptr) {
@@ -1473,23 +1450,23 @@ yyreduce:
(yyval.regexp) = ast.cap((yyval.regexp), NO_CAPTURE);
}
}
#line 1477 "src/parse/parser.cc"
#line 1454 "src/parse/parser.cc"
break;
case 49: /* primary: '(' expr ')' */
#line 254 "../src/parse/parser.ypp"
case 47: /* primary: '(' expr ')' */
#line 245 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), CAPTURE_IF_NOT_INVERTED); }
#line 1483 "src/parse/parser.cc"
#line 1460 "src/parse/parser.cc"
break;
case 50: /* primary: TOKEN_LPAREN_NEG expr ')' */
#line 255 "../src/parse/parser.ypp"
case 48: /* primary: TOKEN_LPAREN_NEG expr ')' */
#line 246 "../src/parse/parser.ypp"
{ (yyval.regexp) = ast.cap((yyvsp[-1].regexp), CAPTURE_IF_INVERTED); }
#line 1489 "src/parse/parser.cc"
#line 1466 "src/parse/parser.cc"
break;
#line 1493 "src/parse/parser.cc"
#line 1470 "src/parse/parser.cc"
default: break;
}
@@ -1682,7 +1659,7 @@ yyreturnlab:
return yyresult;
}
#line 258 "../src/parse/parser.ypp"
#line 249 "../src/parse/parser.ypp"
#pragma GCC diagnostic pop
+1 -1
View File
@@ -1,4 +1,4 @@
AC_INIT([re2c],[4.2],[re2c-general@lists.sourceforge.net])
AC_INIT([re2c],[4.6],[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])
+3
View File
@@ -41,6 +41,7 @@ program:
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYEND``.
Generic API supports two styles that determine the form in which the
primitives should be defined:
@@ -67,6 +68,7 @@ program:
re2c:YYRESTORECTX = "cursor = ctxmarker;";
re2c:YYRESTORETAG = "cursor = ${tag};";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYEND = "limit == cursor";
re2c:YYSTAGP = "@@{tag} = cursor;";
re2c:YYSTAGN = "@@{tag} = NULL;";
re2c:YYSHIFT = "cursor += @@{shift};";
@@ -93,6 +95,7 @@ program:
#define YYRESTORECTX() cursor = ctxmarker
#define YYRESTORETAG(tag) cursor = tag
#define YYLESSTHAN(len) limit - cursor < len
#define YYEND() limit == cursor
#define YYSTAGP(tag) tag = cursor
#define YYSTAGN(tag) tag = NULL
#define YYSHIFT(shift) cursor += shift
+2 -1
View File
@@ -38,4 +38,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+4 -1
View File
@@ -41,7 +41,8 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
Generic API supports two styles that determine the form in which the
primitives should be defined:
@@ -68,6 +69,7 @@ program:
re2c:YYRESTORECTX = "cursor = ctxmarker";
re2c:YYRESTORETAG = "cursor = ${tag}";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYEND = "limit == cursor";
re2c:YYSTAGP = "@@{tag} = cursor";
re2c:YYSTAGN = "@@{tag} = -1";
re2c:YYSHIFT = "cursor += @@{shift}";
@@ -93,4 +95,5 @@ program:
YYBACKUPCTX := func() { ctxmarker = cursor }
YYRESTORECTX := func() { cursor = ctxmarker }
YYLESSTHAN := func(n int) bool { return limit-cursor < n }
YYEND := func(n int) bool { return limit == cursor }
YYSHIFT := func(n int) { cursor += n }
+2 -1
View File
@@ -32,4 +32,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+2 -1
View File
@@ -39,4 +39,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+2 -1
View File
@@ -39,4 +39,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+2 -1
View File
@@ -30,4 +30,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+2 -1
View File
@@ -39,4 +39,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+3 -1
View File
@@ -41,7 +41,8 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
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
@@ -58,6 +59,7 @@ program:
re2c:YYRESTORECTX = "cursor = ctxmarker;";
re2c:YYRESTORETAG = "cursor = @@{tag};";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYEND = "limit == cursor";
re2c:YYSTAGP = "@@{tag} = cursor;";
re2c:YYSTAGN = "@@{tag} = NONE;";
re2c:YYSHIFT = "cursor = (cursor as isize + @@{shift}) as usize;";
+3 -1
View File
@@ -39,7 +39,8 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
For example, if the input is a zero-terminated array of bytes
``buffer: [UInt8]``, variables ``cursor``, ``limit``, ``marker`` and
``ctxmarker`` of type ``Int`` represent input positions, and ``-1``
@@ -56,6 +57,7 @@ program:
re2c:YYRESTORECTX = "cursor = ctxmarker";
re2c:YYRESTORETAG = "cursor = ${tag}";
re2c:YYLESSTHAN = "limit - cursor < @@{len}";
re2c:YYEND = "limit == cursor";
re2c:YYSTAGP = "@@{tag} = cursor";
re2c:YYSTAGN = "@@{tag} = -1";
re2c:YYSHIFT = "cursor += @@{shift}";
+2 -1
View File
@@ -39,4 +39,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+2 -1
View File
@@ -39,4 +39,5 @@ program:
``YYSHIFT``,
``YYSHIFTSTAG``,
``YYSHIFTMTAG``,
``YYLESSTHAN``.
``YYLESSTHAN``,
``YYEND``.
+8
View File
@@ -63,6 +63,14 @@ order to interface with the outer program.
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.
``YYEND``
A generic API primitive with no variables.
It should be defined as an r-value of boolean type that equals ``true`` if
and only if the *logical* end of input has been reached (excluding any
padding or sentinel symbols). ``YYEND`` is used to implement ``$`` symbol in
regular expressions. It differs from ``YYLESSTHAN``, which is used to ensure
that the lexer won't read past the end of buffer.
``YYPEEK``
A generic API primitive with no variables.
It should be defined as an r-value of type ``YYCTYPE`` that is equal to the
+7 -1
View File
@@ -4,7 +4,7 @@
``--api <simple | record | generic>``
Specify the API used by the generated code to interface with used-defined
code. Option ``simple`` shold be used in simple cases when there's no need
code. Option ``simple`` should be used in simple cases when there's no need
for buffer refilling and storing lexer state. Option ``record`` should be
used when lexer state needs to be stored in a record (struct, class, etc.).
Option ``generic`` should be used in complex cases when the other two APIs
@@ -141,6 +141,12 @@
case label of the destination state and continue execution to the head of
the loop.
``--computed-continue``
This option requires the ``--loop-switch`` code model. It uses computed
``continue`` statements to select the next switch case directly, enabling
jump-table optimization similar to ``--computed-gotos`` in the goto/label
code model.
``--nested-ifs -s``
Use nested ``if`` statements instead of ``switch`` statements in conditional
jumps. This usually results in more efficient code with non-optimizing
@@ -66,6 +66,9 @@
An *m-tag*: saves all input positions at which ``#mtag`` matches in a
variable named ``mtag``.
``$``
End of input.
Character classes and string literals may contain the following escape
sequences: ``\a``, ``\b``, ``\f``, ``\n``, ``\r``, ``\t``, ``\v``, ``\\``,
octal escapes ``\ooo`` and hexadecimal escapes ``\xhh``, ``\uhhhh`` and
+18 -5
View File
@@ -37,7 +37,7 @@ language configurations, inplace configurations and code templates.
``supported_features``
A list of supported features with possible elements ``nested-ifs``,
``bitmaps``, ``computed-gotos``, ``case-ranges``, ``monadic``, ``unsafe``,
``tags``, ``captures``, ``captvars``.
``tags``, ``captures``, ``captvars``, ``computed-continue``.
**Language configurations**
@@ -270,12 +270,15 @@ language configurations, inplace configurations and code templates.
``code:loop``
A loop that runs forever (unless interrupted from the loop body).
Supported variables: ``label`` (loop label), ``stmt`` (a list variable
that expands to all statements in the loop body).
Supported variables: ``label`` (loop label), ``val`` (initial state),
``var`` (state variable), ``state`` (a list variable that expands to all
state names) and ``stmt`` (a list variable that expands to all statements
in the loop body or the current state).
``code:continue``
Continue statement. Supported variables: ``label`` (label from which to
continue execution).
continue execution), ``val`` (value passed to a labeled switch) and ``var``
(state variable).
``code:goto``
Goto statement. Supported variables: ``label`` (label of the jump
@@ -513,6 +516,10 @@ language configurations, inplace configurations and code templates.
``need`` (the number of code units to check against). Conditional:
``.many`` (true if the ``need`` is more than one).
``code:yyend``
``YYEND`` expression, possibly specialized for different APIs.
Supported variables: ``YYEND``, ``YYCURSOR``, ``YYLIMIT``.
``code:yybm_filter``
Condition that is used to filter out ``yych`` values that are not
covered by the ``yybm`` table (used with ``--bitmaps`` option).
@@ -575,6 +582,10 @@ language configurations, inplace configurations and code templates.
True if the relative form of computed ``goto`` is used
(``--computed-gotos-relative`` or ``re2c:cgoto:relative = 1``).
``.computed_continue``
True if loop/switch model uses labeled-switch transitions
(``--computed-continue``).
``.code_model.goto_label``
True if code model based on goto/label is used (``--goto-label``).
@@ -610,6 +621,8 @@ language configurations, inplace configurations and code templates.
``.version``
True if the generated fingerprint should contain |re2c| version.
``.yyfill.enable``
True if ``YYFILL`` is enabled (``re2c:yyfill:enable = 1``).
``.yyfn.throw``
True if ``re2c:yyfn:throw`` configuration is defined to a nonempty string.
@@ -30,6 +30,13 @@
``-Wunreachable-rules``
Warn about rules that are shadowed by other rules and will never match.
``-Wdeprecated-eof_rule``
Warn about standalone end of input rules ``$`` that will be broken by the
future changes and require fixing. At the moment these rules take precedence
when conflicting with other rules, but after the introduction of generalized
end of input symbol ``$`` precedence order will change and these rules will
become shadowed by other rules.
``-Wuseless-escape``
Warn if a symbol is escaped when it shouldn't be.
By default, |re2c| silently ignores such escapes, but this may as well
+3 -2
View File
@@ -38,8 +38,9 @@ The following encodings are supported:
fixed-length Unicode encoding with code space ``[0-0x10FFFF]`` and 4-byte code
points and code units.
Include file ``include/unicode_categories.re`` provides |re2c| definitions for the
standard Unicode categories.
Include files ``include/unicode_blocks.re``, ``include/unicode_categories.re``
and ``include/unicode_properties.re`` provide |re2c| definitions for blocks,
categories and properties described in the Unicode standard.
Option ``--input-encoding`` specifies source file encoding, which can be used to
enable Unicode literals in regular expressions. For example
@@ -466,7 +466,7 @@ Figure \ref{fig:tdfa} in section \ref{section_tdfa} shows an example of TNFA sim
\ElseIf {$e = e_1 \mid e_2$} {
$(\Sigma, T_2, Q_2, q_2, q_f, \Delta_2) = \retonfa (e_2, q_f)$ \;
$(\Sigma, T_2, Q'_2, q'_2, q_f, \Delta'_2) = \ntag (T_2, q_f)$ \;
$(\Sigma, T_1, Q_1, q_1, q'_2, \Delta_1) = \retonfa (e_2, q'_2)$ \;
$(\Sigma, T_1, Q_1, q_1, q'_2, \Delta_1) = \retonfa (e_1, q'_2)$ \;
$(\Sigma, T_1, Q'_1, q'_1, q_2, \Delta'_1) = \ntag (T_1, q_2)$ \;
$Q = Q_1 \cup Q'_1 \cup Q_2 \cup Q'_2 \cup \{q_0\}$ \;
$\Delta = \Delta_1 \cup \Delta'_1 \cup \Delta_2 \cup \Delta'_2 \cup \{ (q_0,1,\epsilon,q_1), (q_0,2,\epsilon,q'_1) \}$ \;
@@ -722,7 +722,6 @@ and $l$ is the new sequence constructed by the $\epsilon$-closure.
\nonl\Fn {$\underline{step \Xund on \Xund symbol \big( (X, P), a \big)} \smallskip$} {
$B:$ empty sequence of configurations \;
\BlankLine
\For {$(q, r, l) \in X$ ordered by $q$ in the order of $P$} {
\If {$\exists (q, a, p) \in \Delta \mid a \in \Sigma$} {
append $(p, r, l, \epsilon)$ to $B$
@@ -758,45 +757,44 @@ and $l$ is the new sequence constructed by the $\epsilon$-closure.
\nonl\Fn {$\underline{transition \Xund regops \big( C, R, V \big)} \smallskip$} {
$O:$ empty list of operations \;
\BlankLine
\For {each $(q, r, h, l) \in C$} {
\For {each tag $t \in T$} {
\If {$h_t = history(h, t) \neq \epsilon$} {
\If {$h_t = history(h, t) \neq \epsilon$ and \;
\quad\quad $(history(l, t) = \epsilon$ or $t$ is a multi-tag$)$} {
$v = regop \Xund rhs(r, h_t, t)$ \;
\BlankLine
\If {$V[t][v]$ is undefined } {
$i = max \{R\} + 1$ \;
$i = V[t][v]$ \;
\If {$i$ is undefined } {
$V[t][v] = i = max \{R\} + 1$ \;
$R = R \cup \{i\}$ \;
$V[t][v] = i$ \;
}
\If {operation $i \leftarrow v$ is not in $O$} {
append operation $i \leftarrow v$ to $O$ \;
}
\BlankLine
$r[t] = V[t][v]$ \;
$r[t] = i$ \;
}
}
}
\BlankLine
\Return $O$ \;
}
\vspace{2em}
\nonl\Fn {$\underline{final \Xund regops \big( R_f, r, l \big)} \smallskip$} {
$O:$ empty list of operations \;
\BlankLine
\For {each tag $t \in T$} {
\If {$l_t = history(l, t) \neq \epsilon$} {
append $R_f[t] \leftarrow regop \Xund rhs(r, l_t, t)$ to $O$ \;
} \Else {
append $R_f[t] \leftarrow r[t]$ to $O$ \;
}
}
\BlankLine
\Return $O$ \;
}
\vspace{2em}
\nonl\Fn {$\underline{regop \Xund rhs \big( r, h_t, t \big)} \smallskip$} {
\If {$t$ is a multi-valued tag} {
\lIf {$t$ is a multi-tag} {
\Return $r[t] \cdot h_t$
} \Else {
} \lElse {
\Return the last element of $h_t$
}
}
@@ -1380,7 +1378,7 @@ RE2C uses the following optimization passes for the number of repetitions $N=2$
\For {each operation in $b$} {
\If {copy or append $i \leftarrow j ...$ and $i \neq j$} {
$x = B[i], \; y = B[j]$ \;
\If {$x = -1$ and $y = -1$} {
\If {$x = -1$ and $y = -1$ and $\neg I[i][j]$} {
$B[i] = B[j] = i$ \;
$S[i] = \{i, j\}$ \;
} \ElseIf {$x \neq -1$ and $y = -1$} {
@@ -1412,6 +1410,9 @@ RE2C uses the following optimization passes for the number of repetitions $N=2$
\If {$\exists j$ in $G: B[j] = j$ and $\forall k \in S[j]: \neg I[i][k]$} {
$B[i] = j$ \;
$S[j] = S[j] \cup \{i\}$ \;
} \Else {
$B[i] = i$ \;
$S[i] = \{i\}$ \;
}
}
\BlankLine
@@ -268,17 +268,17 @@
\multicolumn{12}{c}{Interference} \\[0.3em]
& $r_1$ & $r_2$ & $r_3$ & $r_4$ & $r_5$ & $r_6$ & $r_7$ & $r_8$ & $r_9$ & $\!r_{10}\!$ & $\!r_{11}\!$ \\
\hline
$r_1$ & $.$ & $*$ & $*$ & $*$ & $*$ & $.$ & $.$ & $.$ & $.$ & $.$ & $.$ \\
$r_2$ & $*$ & $.$ & $*$ & $*$ & $*$ & $.$ & $*$ & $.$ & $.$ & $.$ & $.$ \\
$r_3$ & $*$ & $*$ & $.$ & $*$ & $*$ & $.$ & $*$ & $*$ & $.$ & $.$ & $.$ \\
$r_4$ & $*$ & $*$ & $*$ & $.$ & $*$ & $.$ & $*$ & $*$ & $*$ & $.$ & $.$ \\
$r_5$ & $*$ & $*$ & $*$ & $*$ & $.$ & $.$ & $*$ & $*$ & $*$ & $*$ & $.$ \\
$r_1$ & $.$ & $*$ & $*$ & $*$ & $*$ & $.$ & $.$ & $*$ & $*$ & $*$ & $*$ \\
$r_2$ & $*$ & $.$ & $*$ & $*$ & $*$ & $.$ & $.$ & $.$ & $*$ & $*$ & $*$ \\
$r_3$ & $*$ & $*$ & $.$ & $*$ & $*$ & $.$ & $.$ & $.$ & $.$ & $*$ & $*$ \\
$r_4$ & $*$ & $*$ & $*$ & $.$ & $*$ & $.$ & $.$ & $.$ & $.$ & $.$ & $*$ \\
$r_5$ & $*$ & $*$ & $*$ & $*$ & $.$ & $.$ & $.$ & $.$ & $.$ & $.$ & $.$ \\
$r_6$ & $.$ & $.$ & $.$ & $.$ & $.$ & $.$ & $*$ & $*$ & $.$ & $.$ & $.$ \\
$r_7$ & $.$ & $*$ & $*$ & $*$ & $*$ & $*$ & $.$ & $*$ & $*$ & $*$ & $*$ \\
$r_8$ & $.$ & $.$ & $*$ & $*$ & $*$ & $*$ & $*$ & $.$ & $*$ & $*$ & $*$ \\
$r_9$ & $.$ & $.$ & $.$ & $*$ & $*$ & $.$ & $*$ & $*$ & $.$ & $.$ & $*$ \\
$r_{10}$ & $.$ & $.$ & $.$ & $.$ & $*$ & $.$ & $*$ & $*$ & $.$ & $.$ & $*$ \\
$r_{11}$ & $.$ & $.$ & $.$ & $.$ & $.$ & $.$ & $*$ & $*$ & $*$ & $*$ & $.$ \\
$r_7$ & $.$ & $.$ & $.$ & $.$ & $.$ & $*$ & $.$ & $*$ & $*$ & $*$ & $*$ \\
$r_8$ & $*$ & $.$ & $.$ & $.$ & $.$ & $*$ & $*$ & $.$ & $*$ & $*$ & $*$ \\
$r_9$ & $*$ & $*$ & $.$ & $.$ & $.$ & $.$ & $*$ & $*$ & $.$ & $.$ & $*$ \\
$r_{10}$ & $*$ & $*$ & $*$ & $.$ & $.$ & $.$ & $*$ & $*$ & $.$ & $.$ & $*$ \\
$r_{11}$ & $*$ & $*$ & $*$ & $*$ & $.$ & $.$ & $*$ & $*$ & $*$ & $*$ & $.$ \\
\end{tabular}
$};
\end{scope}
@@ -307,8 +307,8 @@
\begin{aligned}
& \underline{live\!: r_1\, r_2\, r_3} \\[-0.5em]
& r_{1} \leftarrow r_{3} \\[-0.6em]
& r_{1} \leftarrow \pos \\[-0.6em]
& r_{2} \leftarrow \pos
& r_{2} \leftarrow \pos \\[-0.6em]
& r_{3} \leftarrow \pos
\end{aligned}
$};
\draw [rounded corners=0.5em] (x3.north west) rectangle (x3.south east);
+2 -3
View File
@@ -2,11 +2,10 @@
// re2c $INPUT -o $OUTPUT -i --case-ranges
#include <assert.h>
int lex(const char *s) {
const char *YYCURSOR = s;
int lex(const char* YYCURSOR) {
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case '1' ... '9': goto yy2;
+2 -3
View File
@@ -1,11 +1,10 @@
// re2c $INPUT -o $OUTPUT -i --case-ranges
#include <assert.h>
int lex(const char *s) {
const char *YYCURSOR = s;
int lex(const char* YYCURSOR) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = "unsigned char";
[1-9][0-9]* { return 0; }
* { return 1; }
+1 -1
View File
@@ -22,7 +22,7 @@ for f in $(find -name '*.re'); do
head -n $l "$ctest" > "$ctest".mod && mv "$ctest".mod "$ctest"
fi
g++ -fsanitize=leak -fsanitize=address -g -Wall -oexample "$ctest" \
g++ -fsanitize=leak -fsanitize=address -g -Wall -Wextra -oexample "$ctest" \
&& ./example 2>/dev/null || { echo "*** error ***"; exit 1; }
rm -f "$ctest" example
+5 -5
View File
@@ -14,7 +14,7 @@ static uint64_t parse_u32(const char *s) {
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case '0': goto yy2;
@@ -97,7 +97,7 @@ yy9:
bin:
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case 0x00: goto yy11;
@@ -119,7 +119,7 @@ yy13:
oct:
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case 0x00: goto yy15;
@@ -147,7 +147,7 @@ yy17:
dec:
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case 0x00: goto yy19;
@@ -177,7 +177,7 @@ yy21:
hex:
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case 0x00: goto yy23;
+1 -1
View File
@@ -13,7 +13,7 @@ static uint64_t parse_u32(const char *s) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = "unsigned char";
end = "\x00";
+1 -1
View File
@@ -21,7 +21,7 @@ static uint64_t parse_u32(const char *s) {
{
char yych;
unsigned char yych;
switch (c) {
case yycinit: goto yyc_init;
case yycbin: goto yyc_bin;
@@ -13,9 +13,9 @@ static uint64_t parse_u32(const char *s) {
/*!re2c
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYGETCONDITION = "c";
re2c:define:YYSETCONDITION = "c = @@;";
re2c:YYCTYPE = "unsigned char";
re2c:YYGETCOND = "c";
re2c:YYSETCOND = "c = @@;";
re2c:yyfill:enable = 0;
<*> * { return ERROR; }
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -7,7 +7,7 @@
static int lex(const char *s) {
const char *YYCURSOR = s, *YYMARKER;
/*!re2c
re2c:define:YYCTYPE = 'unsigned char';
re2c:YYCTYPE = "unsigned char";
re2c:yyfill:enable = 0;
// Simplified "Unicode Identifier and Pattern Syntax"
+1 -1
View File
@@ -11,7 +11,7 @@ static int lex(const char *YYCURSOR) {
#line 13 "c/eof/01_sentinel.c"
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case 0x00: goto yy1;
+1 -1
View File
@@ -7,7 +7,7 @@ static int lex(const char *YYCURSOR) {
for (;;) {
/*!re2c
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = "unsigned char";
re2c:yyfill:enable = 0;
* { return -1; }
+1 -1
View File
@@ -23,7 +23,7 @@ loop:
#line 25 "c/eof/02_bounds_checking.c"
{
char yych;
unsigned char yych;
if (YYLIMIT <= YYCURSOR) goto fail;
yych = *YYCURSOR;
switch (yych) {
+2 -2
View File
@@ -17,8 +17,8 @@ static int lex(const char *str, unsigned int len) {
loop:
/*!re2c
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYFILL = "goto fail;";
re2c:YYCTYPE = "unsigned char";
re2c:YYFILL = "goto fail;";
str = ['] ([^'\\] | [\\][^])* ['];
+1 -1
View File
@@ -12,7 +12,7 @@ static int lex(const char *str, unsigned int len) {
#line 14 "c/eof/03_eof_rule.c"
{
char yych;
unsigned char yych;
yych = *YYCURSOR;
switch (yych) {
case ' ': goto yy3;
+1 -1
View File
@@ -8,7 +8,7 @@ static int lex(const char *str, unsigned int len) {
for (;;) {
/*!re2c
re2c:define:YYCTYPE = char;
re2c:YYCTYPE = "unsigned char";
re2c:yyfill:enable = 0;
re2c:eof = 0;
+1 -1
View File
@@ -17,7 +17,7 @@ static int lex(const char *str, unsigned int len) {
#line 19 "c/eof/04_fake_sentinel.c"
{
char yych;
unsigned char yych;
yych = cur < lim ? *cur : 0;
switch (yych) {
case 0x00: goto yy1;
+4 -4
View File
@@ -14,11 +14,11 @@ static int lex(const char *str, unsigned int len) {
for (;;) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:api = custom;
re2c:api = generic;
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYPEEK = "cur < lim ? *cur : 0"; // fake null
re2c:define:YYSKIP = "++cur;";
re2c:YYCTYPE = "unsigned char";
re2c:YYPEEK = "cur < lim ? *cur : 0"; // fake null
re2c:YYSKIP = "++cur;";
* { count = -1; break; }
[\x00] { break;; }
+1 -1
View File
@@ -17,7 +17,7 @@ static int lex(const char *str, unsigned int len) {
#line 19 "c/eof/05_fake_sentinel_eof_rule.c"
{
char yych;
unsigned char yych;
yych = cur < lim ? *cur : 0;
switch (yych) {
case ' ': goto yy3;
+7 -7
View File
@@ -15,14 +15,14 @@ static int lex(const char *str, unsigned int len) {
/*!re2c
re2c:yyfill:enable = 0;
re2c:eof = 0;
re2c:api = custom;
re2c:api = generic;
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYLESSTHAN = "cur >= lim";
re2c:define:YYPEEK = "cur < lim ? *cur : 0"; // fake null
re2c:define:YYSKIP = "++cur;";
re2c:define:YYBACKUP = "mar = cur;";
re2c:define:YYRESTORE = "cur = mar;";
re2c:YYCTYPE = "unsigned char";
re2c:YYLESSTHAN = "cur >= lim";
re2c:YYPEEK = "cur < lim ? *cur : 0"; // fake null
re2c:YYSKIP = "++cur;";
re2c:YYBACKUP = "mar = cur;";
re2c:YYRESTORE = "cur = mar;";
str = ['] ([^'\\] | [\\][^])* ['];
+1 -1
View File
@@ -43,7 +43,7 @@ loop:
#line 45 "c/fill/01_fill.c"
{
char yych;
unsigned char yych;
yyFillLabel0:
yych = *in->cur;
switch (yych) {
+5 -5
View File
@@ -40,11 +40,11 @@ loop:
in->tok = in->cur;
/*!re2c
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = in->cur;
re2c:define:YYMARKER = in->mar;
re2c:define:YYLIMIT = in->lim;
re2c:define:YYFILL = "fill(in) == 0";
re2c:YYCTYPE = "unsigned char";
re2c:YYCURSOR = in->cur;
re2c:YYMARKER = in->mar;
re2c:YYLIMIT = in->lim;
re2c:YYFILL = "fill(in) == 0";
re2c:eof = 0;
str = ['] ([^'\\] | [\\][^])* ['];
+1 -1
View File
@@ -53,7 +53,7 @@ loop:
#line 55 "c/fill/02_fill.c"
{
char yych;
unsigned char yych;
if (in->lim <= in->cur) if (fill(in, 1) != 0) return -1;
yych = *in->cur;
switch (yych) {
+4 -4
View File
@@ -47,10 +47,10 @@ loop:
in->tok = in->cur;
/*!re2c
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = in->cur;
re2c:define:YYLIMIT = in->lim;
re2c:define:YYFILL = "if (fill(in, @@) != 0) return -1;";
re2c:YYCTYPE = "unsigned char";
re2c:YYCURSOR = in->cur;
re2c:YYLIMIT = in->lim;
re2c:YYFILL = "if (fill(in, @@) != 0) return -1;";
str = ['] ([^'\\] | [\\][^])* ['];
+1 -1
View File
@@ -12,7 +12,7 @@ static void convert_newlines(std::ifstream &in, std::ostringstream &out) {
#line 14 "c/generic_api/ifstream.c"
{
char yych;
unsigned char yych;
yych = in.peek();
switch (yych) {
case '\r': goto yy3;
+6 -6
View File
@@ -8,13 +8,13 @@ static void convert_newlines(std::ifstream &in, std::ostringstream &out) {
std::streampos mar;
for (;;) {
/*!re2c
re2c:api= custom;
re2c:api = generic;
re2c:api:style = free-form;
re2c:define:YYCTYPE = char;
re2c:define:YYPEEK = "in.peek()";
re2c:define:YYSKIP = "{ in.ignore(); if (in.eof()) return; }";
re2c:define:YYBACKUP = "mar = in.tellg();";
re2c:define:YYRESTORE = "in.seekg(mar);";
re2c:YYCTYPE = "unsigned char";
re2c:YYPEEK = "in.peek()";
re2c:YYSKIP = "{ in.ignore(); if (in.eof()) return; }";
re2c:YYBACKUP = "mar = in.tellg();";
re2c:YYRESTORE = "in.seekg(mar);";
re2c:yyfill:enable = 0;
* { out.put(yych); continue; }
+1 -1
View File
@@ -10,7 +10,7 @@ long lex(LexerState* st) {
const char *t;
{
char yych;
unsigned char yych;
goto yy0;
yy1:
++st->cur;

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