Compare commits

...
632 Commits
Author SHA1 Message Date
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
Ulya Trofimovich 7bc7c1980a Release 4.2. 2025-04-23 11:26:04 +01:00
Ulya Trofimovich d5484f0443 Update changelog for release 4.2. 2025-04-23 11:16:07 +01:00
Ulya Trofimovich 74be826d3a Update docs: add code:type_yyctable description. 2025-04-23 11:11:07 +01:00
Ulya Trofimovich 49c1417d12 Make build directory name explicit in the instructions.
This is to avoid confusion as in
https://github.com/skvadrik/re2c/issues/541#issuecomment-2816606364
2025-04-21 06:46:12 +01:00
Ulya Trofimovich 17905e7bf5 GitHub Actions: update Java version 11 -> 24. 2025-04-21 06:46:12 +01:00
Ulya Trofimovich 4c7c00c9d2 Update docs: add description of YYFN throw specs in syntax files.
Also, fix a small formatting issue from the previous commit.
2025-04-18 16:04:54 +01:00
Ulya Trofimovich cf8788cc18 Rework syntax file templates for computed goto (again).
Replace `code:cgoto_target` (which was the target expression in the computed
`goto` statement) with `code:cgoto` (which is the full statement).

Rename `code:cgoto_init` to `code:cgoto_data`.

Add `code:yytarget_filter` (similar to existing `code:yybm_filter`).
2025-04-17 06:38:07 +01:00
Ulya Trofimovich 9ab6a13cb3 Update docs for computed goto options / configurations. 2025-04-14 16:23:58 +01:00
Ulya Trofimovich a37a530555 Fix -Wreorder warning. 2025-04-14 16:23:36 +01:00
Ulya Trofimovich 420a976fdb Fix stack-use-after-scope error found by AddressSanitizer.
Local varaible of type `const char*` was passed as `const std::string&`
constructor parameter (so a temporary `std::string` had to be created)
and stored in a class. Fixed by storing the `const char*` pointer directly.
2025-04-13 16:45:10 +01:00
Ulya Trofimovich 52fa88db7b Rework syntax file templates for computed goto.
Previously we had `code:yytarget_goto`, `code:yyctable_goto` for computed
`goto` target expression, and  `code:yytarget_elem`, `code:yyctable_elem`
for table initializers. The defintions for `yytarget` and `yyctable` were
almost identical, and the decision to keep them separate was taken only
so that each set of code templates could specify a different underlying
type for table elements. It was impossible to pass the type using
`code:type_yyctarget`, `code:type_yyctable` because these configurations
included type qualifiers like `static const`.

For the full discussion see this thread:
https://github.com/skvadrik/re2c/pull/537#issuecomment-2693462138

Now that we've got rid of type qualifiers in commit
a94d39b112, it has become possible to merge
code templates for `yytarget` and `yyctable` and avoid the duplication.
2025-04-12 22:52:25 +01:00
Ulya Trofimovich 9498443133 Update docs for syntax file conditional .const. 2025-04-09 17:10:53 +01:00
Ulya Trofimovich a94d39b112 Add syntax file conditional .const to array definitions.
Code templates `code:array_local` and `code:array_global` can now use local
conditional `.const`, which is true if the array is immutable.

This also has the side-effect that type qualifiers such as `static const` in
C/C++ have been removed from type definitions `code:type_yybm`,
`code:type_yytarget` and `code:type_yyctable` (where they did not belong in
the first place).

Also, rename `yybm` to `YYBM` in Rust by default (this is an inner variable,
so changing default definition should not break backwards compatibility).

Rust and Java have been affected by this change, as their bitmap definitions
have been constified (which is reflected by the updated tests). Other language
backends either have used constant bitmaps already, or they don't have a notion
of immutable arrays.
2025-04-09 17:09:04 +01:00
Ulya Trofimovich a66644dad3 Docs: add configuration description for relative computed goto.
Configurations `re2c:computed-gotos:relative`, `re2c:cgoto:relative`.
2025-04-06 16:43:06 +01:00
Ulya Trofimovich 1b24830363 Add re2c:yyfn:throw to the all-config test, update docs.
While at it, fix description of `re2c:yyfn:sep` in the docs.

Regenerate bootstrap manpages and help (incorporates some earlier updates
for Java manpage that were omitted by mistake in commit
47afb07f90 that updated manpages for other
languages).
2025-04-06 16:27:59 +01:00
Ulya Trofimovich cac9f0e75e Swift: make examples compile with Swift 5.8.
Temporarily drop `@retroactive` attribute that was added in Swift 6.
2025-04-05 06:58:11 +01:00
Ulya Trofimovich 58b687e527 Zig: support yyfn:throw configuration.
This is useful for --recursive-functions code model, as it's necessary to use
different syntax for function calls with an additional `try` keyword before the
call expression (which would be impossible to do before this change).

The test/codegen/zig/recursive_functions/basic.re test has been updated to
demonstrate the new functionality.
2025-03-24 16:56:39 +00:00
Ulya Trofimovich 7f624d2a42 Clean up some minor formatting issues in Swift syntax file. 2025-03-24 16:30:14 +00:00
a dinosaur ac37222644 swift: Support yyfn:throw
Adds support for yyfn:throw to the Swift syntax, allowing the user to throw
types that conform to the Error protocol within functions generated by the
recursive-functions code model. Non-empty settings of the `re2c:yyfn:throw`
property are appended to generated function definitions between parameters
and the return type, and generated function calls are prefixed with "try ".

The 'test/codegen/swift/recursive_functions/advanced.re' test has been updated
to test the new functionality as well as demonstrate practical use of throwing
functions in the recursive-functions model for handling runtime errors.
2025-03-23 21:36:12 +00:00
Ulya Trofimovich 73636c66c5 Add configuration re2c:yyfn:throw.
Also, add syntax variable `throw` and conditional `.yyfn.throw` to be used by
code templates for function definitions and function calls.
2025-03-22 23:05:12 +00:00
Ulya Trofimovich e536d7129f Revert "Add syntax variable attrs for code:fndecl and code:fndef configurations."
This reverts commit 85d9384b2f.

Reason for revert: the main motivation for this change was to support Swift
`throw` annotations. However, it turns out that attributes are unfit for the
purpose, since functions that throw also require slightly different call
expressions (they need to be prefixed with `try`). Although attributes may be
useful, let's remove them until we find a real-world use case.

For details, see the full conversation:
https://github.com/skvadrik/re2c/pull/538#discussion_r2008079095
2025-03-22 16:41:03 +00:00
Ulya Trofimovich 85d9384b2f Add syntax variable attrs for code:fndecl and code:fndef configurations.
Use it for C/C++ fuction attributes as an example.

The main motivation for doing this was discussed in
https://github.com/skvadrik/re2c/pull/538#discussion_r2005503221.
2025-03-21 17:10:05 +00:00
a dinosaur f60219b6e1 Add support for Swift 2025-03-20 22:32:00 +01:00
a dinosaur 47afb07f90 Regenerate bootstrap from master 2025-03-20 22:32:00 +01:00
Ulya Trofimovich 8f9c628201 Benchmarks(C/C++): use the same benchmark names as filename infixes.
run.py depends on it when it generates .json report, as it uses filenames for
binary size measurements and symbolic names for CPU time measurements.
2025-03-18 16:50:44 +00:00
Tai Chi Minh Ralph Eastwood 2cf658310c Add code:yytarget_elem, code:yytarget_goto to syntax files.
code:yytarget_elem specifies the how the table elements for computed
goto tables are generated.  If cgoto:relative = 1, then the table
entries contain an offset from a calculated base address.
code:yytarget_goto specifies the computed goto tables are generated.

code:yyctable_elem and code:yyctable_goto are used for the
corresponding computed gotos for conditions.

Bootstrap code has been regenerated.
2025-03-15 23:00:09 +00:00
Ulya Trofimovich feb94108f3 Benchmarks(C/C++): add a few benchmarks without submatch. 2025-03-02 16:25:13 +00:00
Tai Chi Minh Ralph Eastwood afabf6e416 Generalize the computed-gotos code generation for C/C++ backend
Previously the code-generation did similar table generation across
the normal states, accept states and condtional variables.
This refactor introduces some utility functions that provides the same
logic across the different tables.
2025-02-27 06:32:55 +00:00
Tai Chi Minh Ralph Eastwood f505631d46 Regenerate bootstrap for relative computed gotos. 2025-02-25 19:48:55 +00:00
Tai Chi Minh Ralph Eastwood 25fe63beb6 Update the docs about cgoto:relative and --computed-gotos-relative 2025-02-25 19:48:55 +00:00
Tai Chi Minh Ralph Eastwood 1f60bcf49f Add cgoto:relative to enable generating relative offset tables
Instead of using absolute pointers are used in the cgoto tables,
we generate relative offsets from the earliest label offset
within the code.  This offset type is hardcoded as `int' currently.
2025-02-25 19:48:55 +00:00
Ulya Trofimovich 8baaca5774 Release 4.1. 2025-02-16 16:49:48 +00:00
Ulya Trofimovich bdf3e8958a Update Zig examples for newer compiler version. 2025-02-16 16:41:00 +00:00
Ulya Trofimovich ee033adfb6 Update CHANGELOG for release 4.1 (plus a small fix in the manual). 2025-02-15 22:35:14 +00:00
Ulya Trofimovich d3db8a17a5 Update docs (add description of actions). 2025-02-15 10:19:36 +00:00
Ulya Trofimovich 28cb6b8572 Benchmarks(C/C++): use pkg-config in CMake to link with google benchmark. 2025-02-10 08:29:01 +00:00
Ulya Trofimovich 5d4b79275b Benchmarks(C/C++): fix linkage with google benchmark. 2025-02-07 22:20:32 +00:00
Ulya Trofimovich bbf1cb2604 Benchmakrs(C/C++): fix CMake build system.
This was necessary following the rewrite using google-benchmark.
2025-02-05 22:36:56 +00:00
Ulya Trofimovich 6b67aac3e9 Benchmarks(C/C++): update benchmark results. 2025-02-05 22:36:56 +00:00
Ulya Trofimovich cca3ca4151 Benchmarks(C/C++): don't use bit vectors for re2c.
This is because bit vectors are not suppotred with.end of input rule $,
to make the comparison fair between re2c variants.
2025-02-05 22:36:56 +00:00
Ulya Trofimovich de8bf67c32 Benchmarks(C/C++): add simple variants without buffer refill. 2025-02-05 22:36:56 +00:00
Ulya Trofimovich ca18e43710 Benchmarks (C/C++): rewrite using google-benchmark.
This way we can have more reliable measurements for the future benchmarks that
read input from a string rather than a file, and so run much faster and are
more affected by measurement errors.
2025-02-05 22:36:56 +00:00
Ulya Trofimovich 17d7d8c618 Benchmarks (C/C++): remove Kleenex benchmarks.
They are interesting from the academic standoint (to compare DSST vs. TDFA),
but Kleenex is not flexible enough: it assumes fixed program template. The
generated code cannot be adapted to google-benchmark, which it important to
get precise time measurements.

Kleenex benchmarks results are available in the paper by Borsotti and
Trafimovich "A Closer Look at TDFA" (https://arxiv.org/abs/2206.01398).
2025-02-05 22:36:56 +00:00
Ulya Trofimovich ec64527e36 Benchmarks (C/C++): limit Kleenex benchmarks to submatch-only. 2025-02-05 22:36:56 +00:00
Ulya Trofimovich 7e25fb759f Benchmarks (C/C++): remove deprecated TDFA(0) and StaDFA algorithms.
For anyone interested, see the paper by Borsotti and Trafimovich
"A Closer Look at TDFA" (https://arxiv.org/abs/2206.01398). It has benchmark
results that cover the removed algorithms.
2025-02-05 22:36:56 +00:00
Ulya Trofimovich ba31855356 Zig backend: use const for yych declaration in rec/func mode.
Previously re2zig generated `var`, but `yych` is not modified in this mode and
newer Zig versions fail with `error: local variable is never mutated`.
2025-02-05 16:13:48 +00:00
Ulya Trofimovich 6c0d89a238 Allow escaped double quote in the generic lexer rules for char literals.
Some languages have special escape `\"` in character literals, so re2c should
recognize it as well.

This addresses bug #529 "[Rust] Escaped double-quotes in character literal
results in EOF error".
2025-02-04 22:48:10 +00:00
Gregg Reynolds 705a029b8f delete bazel lock file 2025-02-03 09:23:33 +00:00
Gregg Reynolds 7c5eac5982 support WORKSPACE; use lastest skylib
* tested with Bazel 8.0.1 and 7.0.0 on linux and macos
2025-02-03 09:23:33 +00:00
Gregg Reynolds f2e6668e9a migrate to Bazel 8 using bzlmod 2025-02-03 09:23:33 +00:00
Ulya Trofimovich 0e97d4917b Add !pre_rule and !post_rule actions. Add tests for actions.
!pre_rule action is emitted immediately *before* any semantic action in the
current block / condition (it can be useful to have some common initialization
code). !post_rule action is the same, except that it is emitted *after* every
semantic action (it can be useful e.g. to emit unreachability checks).

This addresses bug #521 "Add special entry/exit rules".
2025-01-24 16:28:13 +00:00
Ulya Trofimovich 5a9be34734 BUILD.md: add a list of prebuilt packages on Repology.
This addresses bug #526 "[doc]: Add other install methods on official webpage".
2025-01-21 17:01:11 +00:00
Ulya Trofimovich 71517f1bf9 Change syntax for the entry action: use !entry instead of ^.
This way it is possible to add new named special actions without having
to worry about exhausting all special symbols. Also, if we add mid-rule
actions in the future, this syntax can be used for them as well.
2025-01-20 22:37:58 +00:00
Ulya Trofimovich 787a7a306a Rename "initial" state to "start" state.
Rename `initial_state` to `start_state` and `initial_label` to
`custom_start_label` (so that it's clear that it is a special case).
Update comments.
2025-01-19 16:10:45 +00:00
Ulya Trofimovich e2a2eca01b Rename class field for clarity. 2025-01-18 16:10:12 +00:00
Ulya Trofimovich 596c3d9484 Clean up code that sets default state.
Remove incorrect assignment of default state to default rule state; it was
overwritten later, so it had no effect at all. Rule state should be kept
separate, as default state may be used for different things (e.g. it may be
used as the accept state that has `yyaccept` dispatch).

No changes in the generated code.
2025-01-18 10:35:23 +00:00
Ulya Trofimovich a65419d89a Simplify handling of state actions. Set initial state for all code models.
Previously initial state was marked using special initial action, which was set
only in rec/func mode. Now we explicitly store a pointer to initial state and
set it for all code models.
2025-01-18 07:03:31 +00:00
Ulya Trofimovich f52b642f8e Swap YYBACKUP and YYFILL in the initial state to unify it with other states.
The order of these operations doesn't matter, provided that YYFILL is correct.
2025-01-16 21:43:06 +00:00
Ulya Trofimovich b8406137d6 Tweak precondition for marking used labels with end-of-input rule $.
It's unclear where the previous condition came from; the intention seems to be
to exclude final states that have no outgoing transitions on symbols. With the
end-of-input rule `$` even if all characters fall into the same range as in
`[^]`, a separate range is split for the sentinel symbol, so the previous
condition could not capture any match states.
2025-01-15 16:04:10 +00:00
Ulya Trofimovich 4fedb068c1 When using end-of-input rule $, mark targets of rematch transitions as used.
This is only needed in loop/switch and rec/func modes, as goto/label mode uses
special YYFILL labels, not the state labels. And most of the states were already
marked as used due to other transitions going into them. So the bug was not
revealed until the recent addition of the entry rule.

This addresses bug #521 "Add special entry/exit rules".
2025-01-15 10:54:40 +00:00
Ulya Trofimovich c1537de331 Check that tags on all transitions going to bitmap state are the same.
Previously we only checked that tags are parwise equal between two mapped
transitions, not between all transitions going to the bitmap state. This was a
regression caused by optimization 98f2a41393.

This fixes #523 "Possible regression with bit-vector optimizations between 3.x
and 4.x".
2025-01-14 17:00:39 +00:00
Ulya Trofimovich f3dc6fe0e9 Don't pass invalid location to error reporting function.
When all rules were inherited from other blocks, re2c failed to find correct
rule location and passed an invalid location, which caused a SIGSEGV in the
error reporting function.

This fixes bug #522 "Segfault when !use is present in a block with conditions".
2025-01-14 10:07:32 +00:00
Ulya Trofimovich 19d771fd3d Don't lose jump to the initial state when the entry rule is used.
In goto/label mode, if there is a loop via initial state, YYSKIP must be
bypassed when entering the DFA (visiting initial state for the first time).
Other modes generate YYSKIP on transitions, so they were not affected.

The bug was found by skeleton tests.

This addresses bug #521 "Add special entry/exit rules".
2025-01-12 23:05:07 +00:00
Ulya Trofimovich 4afd9776dc Add entry rule ^ that allows one to execute code at lexer entry.
Also, rename "setup" to "exit action" to match the added "entry action"
(and also because it makes more sense).

This addresses bug #521 "Add special entry/exit rules".

Drop some not very useful debug checks.
2025-01-12 16:40:00 +00:00
Ulya Trofimovich 41411f5c8a Don't write null for missing YYFN type, as it makes output truncated. 2025-01-12 16:39:48 +00:00
Ulya Trofimovich 543aaab356 A few clean-ups.
- remove obsolete `if` branch
- make assertins more precise
- factor out codegen function for semantic actions
- rename variables
2025-01-10 22:07:21 +00:00
Ulya Trofimovich 814a544eff Don't use YYGETCOND() for yystate initialization in non-conditional blocks. 2025-01-10 15:55:27 +00:00
Ulya Trofimovich 5fa1dbd576 Clean up code that handles zero condition <>. 2024-12-30 10:10:46 +00:00
Ulya Trofimovich 90bd3158e1 Don't fail when zero condition <> has no end-of-inpt rule $.
Previously re2c failed with an error in the case when end-of-input rule `$` was
enabled and the special zero condition `<>` was used. Now it no longer fails and
generates code withot end-of-input check for the zero condition (which is
handled in a special way by the code, bypassing some of the transformations that
rely on the presence of end-of-input rule).
2024-12-28 10:25:49 +00:00
Ulya Trofimovich 2b80343e4d Don't try to generate names for fictive tags.
With captvars (either leftmost or POSIX ones) we need to generate names for the
variables that correspond to capturing parentheses. The difference between
leftmost and POSIX cases is that POSIX disambiguation algorithm is more complex
and it requres additional imlicit tags inserted in the regular expression.
These so-called "fictive" tags don't have valid submatch group indices, so
trying to use them caused integer overflow and a very long loop.

This is a fix for issue #519 "re2c hangs if posix-captvars is used".
2024-12-27 16:15:32 +00:00
Ulya Trofimovich 972d7874e2 Add a test for condition with the end-of-input rule $.
Currently re2c fails with error, as the special zero condition `<>` has no
end-of-inpt rule `$`.
2024-12-27 11:09:48 +00:00
Ulya Trofimovich 83b135699f Allow using lookahead operator with captures.
This is a fix for #518.
2024-12-27 10:18:00 +00:00
Ulya Trofimovich 2ecbbce7d9 Fix error message for the case when standalone tags are mixed with captures.
We now have many options for captures, so we cannot assume that the
--posix-captures option is the one causing conflicts.

This partially addresses issue #518.
2024-12-27 09:54:16 +00:00
Ulya Trofimovich e2d249f839 OCaml: use unsafe_get instead of get as the default YYPEEK implementation.
The generated code already handles the end of input, so it should use
`unsafe_get` to avoid redundant bounds checks. If the user wants to use `get`,
they can always do so by overriding YYPEEK.

Update all examples and remove '\x00' character at the end of string literals,
as they are already NULL-terminated.
2024-12-25 16:42:26 +00:00
Ulya Trofimovich 54d0eaa4b5 Generate correct escape sequences for each language.
Previously C escape sequences were used for all languages, which resulted in
incorrect escapes generated for some languages, e.g. `\f` in OCaml is not a
valid escape, while in C it is.

This commit adds syntax configuration `special_escapes` to all syntax files.
Its value is a string of all special characters that require escaping.

This is a fix for #516 "re2ocaml can generate invalid escape sequences".
2024-12-24 16:56:15 +00:00
Ulya Trofimovich cf302ed2bd Add a test for raw newlines in syntax files. 2024-12-23 16:40:16 +00:00
Ulya Trofimovich 32e11d9904 Do not consider space characters printable.
0x20 (space ' ') is printable, but others like '\f' are not. And 0x20 is already
covered by the `is_print` part of the check.

This patch does not change existing behavior, as the code handled all
non-printable space characters as escape sequences before the check, so they
were printed correctly.
2024-12-22 16:42:11 +00:00
Ulya Trofimovich 2fc1f0b0bc Release 4.0.2. 2024-12-11 15:56:41 +00:00
Ulya Trofimovich 4d5f6d6722 Restructure benchmark layout (prepare to add new benchmarks).
Update pre-generated benchmark files (trivial line directive changes).

Disable regeneration of Kleenex files, as Kleenex is not actively maintained and
fails to build with the recent cabal and Haskell ecosystem.
2024-12-11 07:38:40 +00:00
Ulya Trofimovich bec027b7ae build/__distcheck.sh: add missing -j $(nproc) to some build commands. 2024-12-11 07:21:27 +00:00
Ulya Trofimovich a780025238 Update changelog. 2024-12-11 07:20:14 +00:00
Ulya Trofimovich 05298b1210 Makefile.am: don't forget to clean up autogenerated syntax files. 2024-12-10 22:01:45 +00:00
Ulya Trofimovich 70409e3966 Makefile.am: remove non-syntax headers from BUILT_SOURCES.
Only syntax headers have rules that autogenerate them.
2024-12-10 18:12:00 +00:00
Ulya Trofimovich c65b9766ac Update changelog for 4.0.2. 2024-12-10 18:01:01 +00:00
Ulya Trofimovich 6aa98843c7 Automake.am: use headers instead of source files for default syntax configs.
This is a follow-up on the change needed to fix CMake (bug #511).
2024-12-10 18:00:41 +00:00
Ulya Trofimovich 0b7be55aec CMake: pick correct default syntax config for language specific binaries.
2nd attempt to fix issue #515 "version 4.0.1 re2rust default generate C code".
This time, instead of trying to split the object library, the code that needs
the split has been moved out of the problematic library.

Also there are some small improvements in the way default syntax strings are
declared (added `static constexpr`) and linked (moved them to header files).
Generation script has been fixed to generate correct string names.
2024-12-10 18:00:34 +00:00
Ulya Trofimovich 436a6cbeaa Revert "CMake: split object library by language, pass correct options to each."
This reverts commit 9cfb87edaf.

Reason for revert: it's no good trying to build multiple object libraries for
different languages in parallel, as they all try to copy files to the same
bootstrap directory, causing conflicts and build errors. Avoiding such conflicts
was the reason the object library got added in the first place (so that
autogenerated sources could be built once before all other sources).
2024-12-10 16:49:50 +00:00
Ulya Trofimovich 9cfb87edaf CMake: split object library by language, pass correct options to each.
Previously target compile definitions weren't properly added to the
autogenerated sources, as they were built into a separate object library
(to ensure that they are built before the rest of the sources). Now the
object library is built separately for each language with proper options.

This addresses issue #515 "version 4.0.1 re2rust default generate C code".
2024-12-10 16:18:28 +00:00
Ulya Trofimovich 170ffa39b8 Restructured benchmark layout (preparing to add new benchmarks). 2024-12-03 17:21:47 +00:00
Ulya Trofimovich e5cb9a1ebd Release 4.0.1. 2024-11-25 07:20:45 +00:00
Ulya Trofimovich 1357b3c3d9 Update CHANGELOG for release 4.0.1. 2024-11-25 06:56:34 +00:00
Ulya Trofimovich 61c88fbf5a Rebuild syntax files when checking the distribution. 2024-11-24 16:30:29 +00:00
PolarGoose 162b9c5a8b Increase the Cmake minimum version to allow using CMAKE_MSVC_RUNTIME_LIBRARY flag 2024-11-24 06:42:14 +00:00
Ulya Trofimovich 5eb464f8e8 Docs: update contributors list. 2024-11-23 17:21:04 +00:00
Ulya Trofimovich e1148b4a7b Makefile.am: add dependency on RST sources and custom build scripts.
The added rule has no command part, so it does not conflict with existing
suffix rules that build docs.
2024-11-23 17:19:17 +00:00
Ulya Trofimovich 3a40b3d4bb Make most of the C/C++ examples truly C compatible.
Some of the examples use C++ data structures like `std::ifstream`, `std::vector`
etc. Leave them as is for now.

Update docs.

This addresses bug #484 "Example is not C".
2024-11-23 11:39:57 +00:00
Ulya Trofimovich a75eb2b3fd Avoid C++ templates in some examples to make them work in C.
This addresses bug #484 "Example is not C".
2024-11-22 16:17:54 +00:00
Ulya Trofimovich 5cea17c8fe Avoid new features added in 4.0 in C/C++ examples.
Keep examples compatible with older re2c versions until most of the world has
updated to re2c-4.0 or later. When it happens, this commit should be reverted.
2024-11-22 07:17:01 +00:00
Ulya Trofimovich b4dc9f69b1 Regenerate docs with typo fixes.
This picks up typo fixes in commit 92c3ae5a99.
2024-11-22 07:16:35 +00:00
jcfp 92c3ae5a99 fix typos 2024-11-21 17:22:38 +00:00
Ulya Trofimovich a1c42047da Makefile.am: add some missing doc sources to distribution tarball.
This fixes bug #503 "[4.0] build failure with --enable-docs".
2024-11-21 17:14:00 +00:00
Ulya Trofimovich b8a4cddf80 Release 4.0. 2024-11-19 07:00:21 +00:00
Ulya Trofimovich 7f26edd716 Makefile.am: avoid POSIX-incompatible pattern rules.
This is to fix building with bmake on FreeBSD.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Now it generates a sequence of simple statements:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

against theit unix-like form of

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

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

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

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

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

This regression was found because one of the examples for Go didn't
compile (examples/state/push.go). Now it does.
2023-12-06 21:51:35 +00:00
Ulya Trofimovich 22721f0b0e release.sh: check that examples work. 2023-12-06 21:45:34 +00:00
Ulya Trofimovich 0b6d0b510e CMake: set C++17 standard for benchmarks that use re2. 2023-07-25 07:10:51 +01:00
3531 changed files with 1230869 additions and 1517464 deletions
+1
View File
@@ -1,2 +1,3 @@
* text=auto
test/newlines/** -text
test/codegen/python/indentation_sensitive_crlf.re -text
+12
View File
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: "github-actions"
commit-message:
include: "scope"
prefix: "Actions"
directory: "/"
labels:
- "enhancement"
schedule:
interval: "weekly"
+20 -11
View File
@@ -33,18 +33,18 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v3
uses: actions/setup-python@v7
with:
python-version: '3.8'
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v5
with:
distribution: 'adopt'
java-version: '11'
java-version: '24'
- name: Setup Common Prerequisites
run: |
@@ -71,8 +71,17 @@ jobs:
cmake -S . -B .build \
-G "Unix Makefiles" \
-DRE2C_BUILD_LIBS=ON \
-DRE2C_BUILD_RE2D=OFF \
-DRE2C_BUILD_RE2GO=OFF \
-DRE2C_BUILD_RE2HS=OFF \
-DRE2C_BUILD_RE2JAVA=OFF \
-DRE2C_BUILD_RE2JS=OFF \
-DRE2C_BUILD_RE2OCAML=OFF \
-DRE2C_BUILD_RE2PY=OFF \
-DRE2C_BUILD_RE2RUST=OFF \
-DRE2C_BUILD_RE2SWIFT=OFF \
-DRE2C_BUILD_RE2V=OFF \
-DRE2C_BUILD_RE2ZIG=OFF \
-DRE2C_BUILD_BENCHMARKS=ON \
-DCMAKE_CXX_FLAGS="-O3"
@@ -80,20 +89,20 @@ jobs:
run: cmake --build .build
- name: Run submatch DFA AOT benchmark
working-directory: .build/benchmarks/submatch_dfa_aot
working-directory: .build/benchmarks/c
run: |
./run.py --quickverify \
&& ./run.py --repetitions 5 --output results.json \
./run.py --verify \
&& ./run.py --output results.json \
&& cat results.json
- name: Run submatch DFA JIT benchmark
working-directory: .build/benchmarks/submatch_dfa_jit
run: ./bench_submatch_dfa_jit
working-directory: .build/benchmarks/c/libre2c/jit
run: ./bench_submatch_jit
- name: Run submatch Java benchmark (ReTdfa)
working-directory: .build/benchmarks/submatch_java
working-directory: .build/benchmarks/c/libre2c/java
run: ./run.py
- name: Run submatch NFA benchmark
working-directory: .build/benchmarks/submatch_nfa
working-directory: .build/benchmarks/c/libre2c/nfa
run: ./bench_submatch_nfa
+13 -4
View File
@@ -36,11 +36,11 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v7
- name: Setup apt cache (Linux)
if: startsWith(runner.os, 'Linux')
uses: actions/cache@v3
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@v3
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@v3
uses: actions/upload-artifact@v7
with:
# To ensure that jobs don't overwrite existing artifacts,
# use a different name per job.
+12 -8
View File
@@ -62,11 +62,11 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v7
- name: Setup chocolatey Cache (Windows)
if: startsWith(runner.os, 'Windows')
uses: actions/cache@v3
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@v3
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@v3
uses: actions/setup-python@v7
with:
python-version: 3.x
architecture: x64
@@ -135,9 +135,9 @@ jobs:
id: build-info
run: |
if echo "${{ matrix.name }}" | grep -q "ootree"; then
BUILD_DIR="$(pwd)/.build/${{ matrix.name }}-full"
BUILD_DIR="${{ github.workspace }}/.build/${{ matrix.name }}-full"
else
BUILD_DIR="$(pwd)"
BUILD_DIR="${{ github.workspace }}"
fi
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_OUTPUT
@@ -165,13 +165,17 @@ jobs:
- name: Archive test artifacts
# Run this step only if tests failed (otherwise there is nothing to upload).
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v7
with:
# To ensure that jobs don't overwrite existing artifacts,
# use a different name per job.
name: test-${{ matrix.name }}
# Tests run in a temporary directory that has a name test_<timestamp>.
path: ${{ steps.build-info.outputs.BUILD_DIR }}/test_[0-9]*
# Provide both relative and absolute paths. Absolute path should work for all builds,
# but it doesn't work on Windows. Relative path works for in-tree Windows builds.
path: |
test_[0-9]*
${{ steps.build-info.outputs.BUILD_DIR }}/test_[0-9]*
# Artifacts are retained for 90 days by default.
# In fact, we don't need such long period.
retention-days: 30
+2 -2
View File
@@ -1,3 +1,3 @@
[submodule "benchmarks/submatch_java/REgen"]
path = benchmarks/submatch_java/REgen
[submodule "benchmarks/c/libre2c/java/REgen"]
path = benchmarks/c/libre2c/java/REgen
url = https://github.com/skvadrik/REgen.git
+2 -1
View File
@@ -1,4 +1,5 @@
package(default_visibility = ["//visibility:private"])
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
genrule(
name = "re2c_config",
@@ -31,7 +32,7 @@ cc_library(
srcs = glob([
"bootstrap/src/**/*.cc",
"src/**/*.cc",
]),
], exclude = ["src/test/**/*.cc"]),
deps = [
"re2c_config_cc", # Needed for 're2c_config_cc' data files
],
+86 -4
View File
@@ -1,5 +1,10 @@
How to build
============
Build & install
===============
If you want to install re2c from a prebuilt package, skip to the bottom of the
page for a list of all packages available on different systems. Below is a guide
how to build re2c from source code.
Dependencies
@@ -34,7 +39,8 @@ An in-tree build (objects are generated side by side with sources):
```
$ ./configure && make && make install
```
An out-of-tree build (objects are generated in a separate directory):
An out-of-tree build (objects are generated in a separate directory
named `.build`):
```
$ mkdir .build && cd .build && ../configure && make && make install
```
@@ -45,12 +51,39 @@ The configure script has many options (to see them all, run
* `--enable-debug`
Enable debug checks in the re2c source code. Also enables debug options.
* `--enable-dlang`
Build re2d (identical to `re2c --lang d`). This is on by default.
* `--enable-golang`
Build re2go (identical to `re2c --lang go`). This is on by default.
* `--enable-haskell`
Build re2hs (identical to `re2c --lang haskell`). This is on by default.
* `--enable-java`
Build re2java (identical to `re2c --lang java`). This is on by default.
* `--enable-js`
Build re2js (identical to `re2c --lang js`). This is on by default.
* `--enable-ocaml`
Build re2ocaml (identical to `re2c --lang ocaml`). This is on by default.
* `--enable-python`
Build re2py (identical to `re2c --lang python`). This is on by default.
* `--enable-rust`
Build re2rust (identical to `re2c --lang rust`). This is on by default.
* `--enable-swift`
Build re2swift (identical to `re2c --lang swift`). This is on by default.
* `--enable-vlang`
Build re2v (identical to `re2c --lang v`). This is on by default.
* `--enable-zig`
Build re2zig (identical to `re2c --lang zig`). This is on by default.
* `--enable-lexers`
Enable regeneration of lexers from *.re* files (as opposed to using
pre-generated bootstrap files). This requires setting `RE2C_FOR_BUILD` to
@@ -60,6 +93,10 @@ The configure script has many options (to see them all, run
Enable regeneration of parsers from *.ypp* files with bison (as opposed to
using pre-generated bootstrap files).
* `--enable-syntax`
Enable regeneration of default syntax files from the ones provided in
include/ directory (as opposed to using pre-generated bootstrap files).
* `--enable-docs`
Enable regeneration of documentation (requires Python 3 Docutils).
@@ -140,7 +177,8 @@ The following modes are supported:
the code with Undefined Behavior Sanitizer to check for undefined behavior
errors.
A simple build (objects are generated in a separate build directory):
A simple build (objects are generated in a separate build directory named
`.build`):
```
$ mkdir .build && cd .build && cmake .. && cmake --build .
```
@@ -148,13 +186,45 @@ A simple build (objects are generated in a separate build directory):
CMake supports a lot of configuration options. Here is the list of options
specific to re2c:
* `-DRE2C_BUILD_RE2D=yes`
Build re2d executable (an alias to `re2c --lang d`). Enabled by default.
* `-DRE2C_BUILD_RE2GO=yes`
Build re2go executable (an alias to `re2c --lang go`). Enabled by default.
* `-DRE2C_BUILD_RE2HS=yes`
Build re2hs executable (an alias to `re2c --lang haskell`). Enabled by
default.
* `-DRE2C_BUILD_RE2JAVA=yes`
Build re2java executable (an alias to `re2c --lang java`). Enabled by
default.
* `-DRE2C_BUILD_RE2JS=yes`
Build re2js executable (an alias to `re2c --lang js`). Enabled by default.
* `-DRE2C_BUILD_RE2OCAML=yes`
Build re2ocaml executable (an alias to `re2c --lang ocaml`). Enabled by
default.
* `-DRE2C_BUILD_RE2PY=yes`
Build re2py executable (an alias to `re2c --lang python`). Enabled by
default.
* `-DRE2C_BUILD_RE2RUST=yes`
Build re2rust executable (an alias to `re2c --lang rust`). Enabled by
default.
* `-DRE2C_BUILD_RE2SWIFT=yes`
Build re2swift executable (an alias to `re2c --lang swift`). Enabled by
default.
* `-DRE2C_BUILD_RE2V=yes`
Build re2v executable (an alias to `re2c --lang v`). Enabled by default.
* `-DRE2C_BUILD_RE2ZIG=yes`
Build re2zig executable (an alias to `re2c --lang zig`). Enabled by default.
* `-DRE2C_REBUILD_LEXERS=yes`
Enable regeneration of lexers from *.re* files (as opposed to using
pre-generated bootstrap files). This requires setting `-DRE2C_FOR_BUILD` to
@@ -164,6 +234,10 @@ specific to re2c:
Enable regeneration of parsers from *.ypp* files with bison (as opposed to
using pre-generated bootstrap files).
* `-DRE2C_REBUILD_SYNTAX=yes`
Enable regeneration of default syntax files from the ones provided in
include/ directory (as opposed to using pre-generated bootstrap files).
* `-DRE2C_REBUILD_DOCS=yes`
Enable regeneration of documentation (requires Python 3 Docutils).
@@ -224,3 +298,11 @@ fuzz-testing Haskell scripts in the *fuzz* subdirectory; they are based on the
QuickCheck library and can be easily modified to fuzz-test various aspects of
re2c by comparing current re2c version against older versions or against other
regular expression libraries.
Packages
--------
[Repology](https://repology.org/project/re2c/versions)
has a list of re2c packages for different systems:
![re2c](https://repology.org/badge/vertical-allrepos/re2c.svg)
+409 -59
View File
@@ -2,9 +2,414 @@ Changelog
=========
----
3.0x
----
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)
~~~~~~~~~~~~~~~~
- Added Swift backend
(`#506 <https://github.com/skvadrik/re2c/issues/506>`_).
- Added options:
+ ``--lang swift``
+ ``--computed-gotos-relative``
- Added configurations:
+ ``re2c:cgoto:relative``, ``re2c:computed-gotos:relative``
+ ``re2c:yyfn:throw``
- Added syntax file code templates:
+ ``code:cgoto``
+ ``code:cgoto_data``
+ ``code:yytarget_filter``
+ ``code:type_yyctable``
- Added syntax file conditionals:
+ ``.cgoto.relative``
+ ``.yyfn.throw``
- Added some C++ benchmarks without submatch extraction.
4.1 (2025-02-16)
~~~~~~~~~~~~~~~~
- Added new syntax for actions
(`#521 <https://github.com/skvadrik/re2c/issues/521>`_).
- Added entry, pre-rule and post-rule actions
(`#521 <https://github.com/skvadrik/re2c/issues/521>`_):
+ ``!entry`` action binds code at the start of the current finite state machine
+ ``!pre_rule`` action prepernds code to semantic actions of all rules in the
current block or condiiton.
+ ``!post_rule`` action appernds code to semantic actions of all rules in the
current block or condiiton.
- Added syntax file option ``special_escapes`` that describes allowed escape
sequences (`#516 <https://github.com/skvadrik/re2c/issues/516>`_).
- Fixed bugs:
+ `#518 <https://github.com/skvadrik/re2c/issues/518>`_
(allow using lookahead operator with captures).
+ `#519 <https://github.com/skvadrik/re2c/issues/519>`_
(integer overflow caused a very long loop when generating tag names).
+ `#522 <https://github.com/skvadrik/re2c/issues/522>`_
(segfault on ``!use`` directive in a block with conditions).
+ `#523 <https://github.com/skvadrik/re2c/issues/523>`_
(regression with bit-vector optimization).
+ `#529 <https://github.com/skvadrik/re2c/issues/529>`_
(failure to recognize escaped double quotes in character literals).
- OCaml backend now uses ``unsafe_get`` instead of ``get`` as the default ``YYPEEK``
implementation.
- Zig backend now uses ``const`` for ``yych`` declaration in
``--recursive-functions`` mode.
- Benchmarks (C/C++):
+ Reimplemented benchmarks using google-benchmark library.
+ Added simple variants without buffer refill.
+ Removed Kleenex benchmarks.
+ Removed deprecated TDFA(0) and StaDFA algorithms.
+ Updated benchmark results.
- Build system:
+ Migrated to Bazel 8 using bzlmod.
4.0.2 (2024-12-11)
~~~~~~~~~~~~~~~~~~
- CMake build system: fixed bug
`#515 <https://github.com/skvadrik/re2c/issues/515>`_ where language-specific
binaries erroneously defaulted to generating code for C.
- Playground: address bar now reflects navigation between examples, editors use
a more high-contrast CSS theme.
4.0.1 (2024-11-25)
~~~~~~~~~~~~~~~~~~
- Added missing doc sources to the distribution tarball
(`#503 <https://github.com/skvadrik/re2c/issues/503>`_)
- Reworked C/C++ examples to avoid using new configuration aliases until the
world has updated to re2c 4.0, made them compatible with C.
- A few build system changes: increased CMake minimum required version to 3.15,
added missing dependencies on doc sources in Makefile.am.
- Fixed typos in docs.
4.0 (2024-11-19)
~~~~~~~~~~~~~~~~
- Added a generic technique for describing language backends based on the idea
of syntax files (`#450 <https://github.com/skvadrik/re2c/issues/450>`_).
- Added support for new languages: D, Haskell, Java, JavaScript, OCaml, Python,
V, Zig.
- Added new record API for all languages (enabled with ``--api record``,
``re2c:api = record``) and made it the default API for Haskell and OCaml.
- Renamed former "default API" to "simple API", implemented it for all backends
except Haskell and OCaml, and enabled by default API for C, D, Java,
JavaScript, Python, V and Zig.
- Added new code generation model - recursive functions (enabled with
``--recursive-functions``), primarily to be used for functional languages.
- Added options:
+ ``--syntax <file>``
+ ``--api simple``
+ ``--api generic``
+ ``--api record``
+ ``--goto-label``
+ ``--recursive-functions``
+ ``--lang none``
+ ``--lang d``
+ ``--lang haskell``
+ ``--lang java``
+ ``--lang js``
+ ``--lang ocaml``
+ ``--lang python``
+ ``--lang v``
+ ``--lang zig``
+ ``--leftmost-captvars``
+ ``--posix-captvars``
+ ``--captvars`` (alias for ``--leftmost-captvars``)
+ ``--captures`` (alias for ``--leftmost-captures``)
- Added configurations:
+ ``re2c:api = simple`` (alias for ``re2c:api = default``)
+ ``re2c:api = generic`` (alias for ``re2c:api = custom``)
+ ``re2c:api = record``
+ ``re2c:computed-gotos`` (alias for ``re2c:cgoto``)
+ ``re2c:cond:abort``
+ ``re2c:tags:negative``
+ ``re2c:leftmost-captvars``
+ ``re2c:posix-captvars``
+ ``re2c:captvars`` (alias for ``re2c:leftmost-captvars``)
+ ``re2c:captures`` (alias for ``re2c:leftmost-captures``)
+ ``re2c:monadic``
+ ``re2c:fn:sep``
+ ``re2c:[define:]YYFN``
+ ``re2c:[define:]YYINPUT``
+ ``re2c:[define:]YYGETACCEPT``
+ ``re2c:[define:]YYSETACCEPT``
+ ``re2c:[define:]YYCOPYSTAG``
+ ``re2c:[define:]YYCOPYMTAG``
+ ``re2c:[define:]YYGETCOND`` (alias for ``re2c:[define:]YYGETCONDITION``)
+ ``re2c:[define:]YYSETCOND`` (alias for ``re2c:[define:]YYSETCONDITION``)
+ ``re2c:[variable:]yyfill``
+ ``re2c:[variable:]yynmatch``
+ ``re2c:[variable:]yypmatch``
+ ``re2c:[variable:]yych:literals``
- All configurations that have ``define:`` or ``variable:`` part in their name
now have an alias without this part.
- Added new block types:
+ ``/*!svars:re2c ... */``
+ ``/*!mvars:re2c ... */``
- Flex-style opening/closing braces ``%{`` and ``%}`` for block start/end
markers now work for all block types.
- Added syntax file feature lists:
+ ``supported_apis`` with values from the list:
``simple``, ``generic``, ``record``
+ ``supported_api_styles`` with values from the list:
``free-form``, ``functions``
+ ``supported_code_models`` with values from the list:
``goto-label``, ``loop-switch``, ``recursive-functions``
+ ``supported_targets`` with values from the list:
``code``, ``dot``, ``skeleton``
+ ``supported_features`` with values from the list:
``nested-ifs``, ``bitmaps``, ``computed-gotos``, ``case-ranges``,
``tags``, ``captures``, ``captvars``, ``monadic``, ``unsafe``
- Added syntax file language-specific options:
+ ``semicolons``
+ ``backtick_quoted_strings``
+ ``single_quoted_strings``
+ ``indentation_sensitive``
+ ``wrap_blocks_in_braces``
- Added syntax file code templates:
+ ``code:var_local``
+ ``code:var_global``
+ ``code:const_local``
+ ``code:const_global``
+ ``code:array_local``
+ ``code:array_global``
+ ``code:array_elem``
+ ``code:enum``
+ ``code:enum_elem``
+ ``code:assign``
+ ``code:type_int``
+ ``code:type_uint``
+ ``code:type_cond_enum``
+ ``code:type_yybm``
+ ``code:type_yytarget``
+ ``code:cmp_eq``
+ ``code:cmp_ne``
+ ``code:cmp_lt``
+ ``code:cmp_gt``
+ ``code:cmp_le``
+ ``code:cmp_ge``
+ ``code:if_then_else``
+ ``code:if_then_else_oneline``
+ ``code:switch``
+ ``code:switch_cases``
+ ``code:switch_cases_oneline``
+ ``code:switch_case_range``
+ ``code:switch_case_default``
+ ``code:loop``
+ ``code:continue``
+ ``code:goto``
+ ``code:fndecl``
+ ``code:fndef``
+ ``code:fncall``
+ ``code:tailcall``
+ ``code:recursive_functions``
+ ``code:fingerprint``
+ ``code:line_info``
+ ``code:abort``
+ ``code:yydebug``
+ ``code:yypeek``
+ ``code:yyskip``
+ ``code:yybackup``
+ ``code:yybackupctx``
+ ``code:yyskip_yypeek``
+ ``code:yypeek_yyskip``
+ ``code:yyskip_yybackup``
+ ``code:yybackup_yyskip``
+ ``code:yybackup_yypeek``
+ ``code:yyskip_yybackup_yypeek``
+ ``code:yybackup_yypeek_yyskip``
+ ``code:yyrestore``
+ ``code:yyrestorectx``
+ ``code:yyrestoretag``
+ ``code:yyshift``
+ ``code:yyshiftstag``
+ ``code:yyshiftmtag``
+ ``code:yystagp``
+ ``code:yymtagp``
+ ``code:yystagn``
+ ``code:yymtagn``
+ ``code:yycopystag``
+ ``code:yycopymtag``
+ ``code:yygetaccept``
+ ``code:yysetaccept``
+ ``code:yygetcond``
+ ``code:yysetcond``
+ ``code:yygetstate``
+ ``code:yysetstate``
+ ``code:yylessthan``
+ ``code:yybm_filter``
+ ``code:yybm_match``
- Added global variables in syntax files:
+ ``nl``
+ ``indent``
+ ``dedent``
+ ``topindent``
- Added global conditionals in syntax files:
+ ``.api.simple``
+ ``.api.generic``
+ ``.api.record``
+ ``.api_style.functions``
+ ``.api_style.freeform``
+ ``.case_ranges``
+ ``.code_model.goto_label``
+ ``.code_model.loop_switch``
+ ``.code_model.recursive_functions``
+ ``.date``
+ ``.loop_label``
+ ``.monadic``
+ ``.start_conditions``
+ ``.storable_state``
+ ``.unsafe``
+ ``.version``
- Added warning ``-Wundefined-syntax-config``.
- Warnings that indicate serious issues are now turned on by default
(and can be disabled with ``-Wno-<warning>`` options.
- Added configure options:
+ ``--enable-syntax`` (Autoconf)
+ ``RE2C_REBUILD_SYNTAX`` (CMake)
- Dropped support for function-like API style for Rust.
(it was hard to use, if at all possible)
- Added online playground that allows one to run re2c in a web browser:
https://re2c.org/playground.
- Infra work on Github Actions CI.
3.1 (2023-07-19)
~~~~~~~~~~~~~~~~
@@ -211,10 +616,6 @@ Changelog
`039c1894 <https://github.com/skvadrik/re2c/commit/039c1894>`_.
----
2.2x
----
2.2 (2021-08-01)
~~~~~~~~~~~~~~~~
@@ -250,9 +651,6 @@ Changelog
- Updated documentation.
----
2.1x
----
2.1.1 (2021-03-27)
~~~~~~~~~~~~~~~~~~
@@ -308,9 +706,6 @@ Changelog
- Updated documentation for end of input handling and submatch extraction.
----
2.0x
----
2.0.3 (2020-08-22)
~~~~~~~~~~~~~~~~~~
@@ -418,9 +813,6 @@ Changelog
- Major revision of the paper "Efficient POSIX submatch extraction on NFA".
----
1.3x
----
1.3 (2019-12-14)
~~~~~~~~~~~~~~~~
@@ -444,9 +836,6 @@ Changelog
(`#258 <https://github.com/skvadrik/re2c/pull/258>`_:
Make the build reproducible).
----
1.2x
----
1.2.1 (2019-08-11)
~~~~~~~~~~~~~~~~~~
@@ -628,9 +1017,6 @@ Changelog
- Updated documentation and website.
----
1.1x
----
1.1.1 (2018-08-30)
~~~~~~~~~~~~~~~~~~
@@ -648,9 +1034,6 @@ Changelog
Bugs with option: ``re2c:flags:no-debug-info``.
- Reworked first part of TDFA paper.
----
1.0x
----
1.0.3 (2017-11-08)
~~~~~~~~~~~~~~~~~~
@@ -816,10 +1199,6 @@ Changelog
Makefile.am: create target directory before writing into it
-----
0.16x
-----
0.16 (2016-01-21)
~~~~~~~~~~~~~~~~~
@@ -832,10 +1211,6 @@ Changelog
test failure on big endian archs with 0.15.3
-----
0.15x
-----
0.15.3 (2015-12-02)
~~~~~~~~~~~~~~~~~~~
@@ -959,10 +1334,6 @@ Changelog
keep a mirror on sourceforge.
-----
0.14x
-----
0.14.3 (2015-05-20)
~~~~~~~~~~~~~~~~~~~
@@ -996,10 +1367,6 @@ Changelog
Dot output label escaped characters
-----
0.13x
-----
0.13.7.5 (2014-08-22)
~~~~~~~~~~~~~~~~~~~~~
@@ -1110,10 +1477,6 @@ Changelog
- Fixed #1708378 segfault ``in actions.cc``.
-----
0.12x
-----
0.12.3 (2007-08-24)
~~~~~~~~~~~~~~~~~~~
@@ -1165,10 +1528,6 @@ Changelog
+ aCC: HP C/aC++ B3910B A.06.15 [Mar 28 2007] (HP-UX IA64)
-----
0.11x
-----
0.11.3 (2007-04-01)
~~~~~~~~~~~~~~~~~~~
@@ -1195,10 +1554,6 @@ Changelog
- Added ``-u`` switch to support unicode.
-----
0.10x
-----
0.10.8 (2007-04-01)
~~~~~~~~~~~~~~~~~~~
@@ -1329,10 +1684,6 @@ Changelog
- Applied #1307467 Unicode patch for 0.9.7.
----
0.9x
----
0.9.12 (2005-12-28)
~~~~~~~~~~~~~~~~~~~
@@ -1426,9 +1777,8 @@ Changelog
- Removed rcs comments in source files.
-------------------------
re2c adopted (2003-12-09)
-------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~
- Version 0.9.1 README::
+316 -171
View File
@@ -1,17 +1,25 @@
cmake_minimum_required(VERSION 3.12)
project(re2c VERSION 3.1 HOMEPAGE_URL "https://re2c.org/")
cmake_minimum_required(VERSION 3.15)
project(re2c VERSION 4.6 HOMEPAGE_URL "https://re2c.org/")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Re2cAutotoolsHelpers)
include(Re2cBootstrapLexer)
include(Re2cBootstrapParser)
include(Re2cBootstrapSyntax)
include(Re2cBuildType)
include(Re2cGenDocs)
include(Re2cCompilerFlags)
ac_subst(PACKAGE_VERSION "${PROJECT_VERSION}")
# check whether re2c is the root project
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(RE2C_IS_ROOT_PROJECT TRUE)
else()
set(RE2C_IS_ROOT_PROJECT FALSE)
endif()
option(RE2C_REBUILD_LEXERS "Regenerate lexers" OFF)
if(RE2C_REBUILD_LEXERS AND NOT RE2C_FOR_BUILD)
message(FATAL_ERROR "option RE2C_FOR_BUILD is required for RE2C_REBUILD_LEXERS")
@@ -22,22 +30,33 @@ if(RE2C_REBUILD_PARSERS AND NOT RE2C_FOR_BUILD)
find_package(BISON REQUIRED)
endif()
option(RE2C_REBUILD_SYNTAX "Regenerate default syntax files" OFF)
option(RE2C_REBUILD_DOCS "Regenerate manpage" OFF)
option(RE2C_BUILD_LIBS "Build libraries" OFF)
option(RE2C_BUILD_RE2D "Build re2d executable (an alias for `re2c --lang d`)" ON)
option(RE2C_BUILD_RE2GO "Build re2go executable (an alias for `re2c --lang go`)" ON)
option(RE2C_BUILD_RE2HS "Build re2hs executable (an alias for `re2c --lang haskell`)" ON)
option(RE2C_BUILD_RE2JAVA "Build re2java executable (an alias for `re2c --lang java`)" ON)
option(RE2C_BUILD_RE2JS "Build re2js executable (an alias for `re2c --lang js`)" ON)
option(RE2C_BUILD_RE2OCAML "Build re2ocaml executable (an alias for `re2c --lang ocaml`)" ON)
option(RE2C_BUILD_RE2PY "Build re2py executable (an alias for `re2c --lang python`)" ON)
option(RE2C_BUILD_RE2RUST "Build re2rust executable (an alias for `re2c --lang rust`)" ON)
option(RE2C_BUILD_RE2SWIFT "Build re2swift executable (an alias for `re2c --lang swift`)" ON)
option(RE2C_BUILD_RE2V "Build re2v executable (an alias for `re2c --lang v`)" ON)
option(RE2C_BUILD_RE2ZIG "Build re2zig executable (an alias for `re2c --lang zig`)" ON)
option(RE2C_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(RE2C_REGEN_BENCHMARKS "Regenerate C code for benchmarks" OFF)
# test targets are enabled by default only if re2c is the root project
option(RE2C_BUILD_TESTS "Build tests" "${RE2C_IS_ROOT_PROJECT}")
# checks for programs
find_package(Python3 COMPONENTS Interpreter)
# starting from cmake 3.19 find_package can do version check, but we are on 3.12
if(Python3_VERSION VERSION_LESS 3.7)
message(FATAL_ERROR "python version 3.7 or higher is required")
if(RE2C_REBUILD_DOCS OR RE2C_BUILD_TESTS OR RE2C_BUILD_BENCHMARKS)
find_package(Python3 3.7 REQUIRED COMPONENTS Interpreter)
endif()
if(RE2C_REBUILD_DOCS)
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c "import docutils"
@@ -54,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")
@@ -65,26 +88,53 @@ ac_check_headers("unistd.h")
ac_check_headers("io.h")
# docs (manpages and help)
set(re2c_manpage_source "${CMAKE_CURRENT_BINARY_DIR}/doc/manpage.rst")
set(re2c_help_source "${CMAKE_CURRENT_BINARY_DIR}/doc/help.rst")
set(re2c_manpage_bootstrap_c "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/doc/re2c.1")
set(re2c_manpage_bootstrap_go "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/doc/re2go.1")
set(re2c_manpage_bootstrap_rust "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/doc/re2rust.1")
set(re2c_help_bootstrap "${CMAKE_CURRENT_SOURCE_DIR}/bootstrap/src/msg/help.cc")
set(re2c_manpage_c "${CMAKE_CURRENT_BINARY_DIR}/doc/re2c.1")
set(re2c_manpage_go "${CMAKE_CURRENT_BINARY_DIR}/doc/re2go.1")
set(re2c_manpage_rust "${CMAKE_CURRENT_BINARY_DIR}/doc/re2rust.1")
set(re2c_help "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help.cc")
set(re2c_rst2man "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2man.py")
set(re2c_rst2txt "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2txt.py")
set(re2c_splitman "${CMAKE_CURRENT_SOURCE_DIR}/build/split_man.py")
set(re2c_manpage_source "${CMAKE_CURRENT_BINARY_DIR}/doc/manpage.rst")
set(re2c_help_source "${CMAKE_CURRENT_BINARY_DIR}/doc/help.rst")
set(re2c_manpage_c "${CMAKE_CURRENT_BINARY_DIR}/doc/re2c.1")
set(re2c_manpage_d "${CMAKE_CURRENT_BINARY_DIR}/doc/re2d.1")
set(re2c_manpage_go "${CMAKE_CURRENT_BINARY_DIR}/doc/re2go.1")
set(re2c_manpage_haskell "${CMAKE_CURRENT_BINARY_DIR}/doc/re2hs.1")
set(re2c_manpage_java "${CMAKE_CURRENT_BINARY_DIR}/doc/re2java.1")
set(re2c_manpage_js "${CMAKE_CURRENT_BINARY_DIR}/doc/re2js.1")
set(re2c_manpage_ocaml "${CMAKE_CURRENT_BINARY_DIR}/doc/re2ocaml.1")
set(re2c_manpage_python "${CMAKE_CURRENT_BINARY_DIR}/doc/re2py.1")
set(re2c_manpage_rust "${CMAKE_CURRENT_BINARY_DIR}/doc/re2rust.1")
set(re2c_manpage_swift "${CMAKE_CURRENT_BINARY_DIR}/doc/re2swift.1")
set(re2c_manpage_v "${CMAKE_CURRENT_BINARY_DIR}/doc/re2v.1")
set(re2c_manpage_zig "${CMAKE_CURRENT_BINARY_DIR}/doc/re2zig.1")
set(re2c_help_c "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2c.cc")
set(re2c_help_d "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2d.cc")
set(re2c_help_go "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2go.cc")
set(re2c_help_haskell "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2hs.cc")
set(re2c_help_java "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2java.cc")
set(re2c_help_js "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2js.cc")
set(re2c_help_ocaml "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2ocaml.cc")
set(re2c_help_python "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2py.cc")
set(re2c_help_rust "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2rust.cc")
set(re2c_help_swift "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2swift.cc")
set(re2c_help_v "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2v.cc")
set(re2c_help_zig "${CMAKE_CURRENT_BINARY_DIR}/src/msg/help_re2zig.cc")
set(re2c_rst2man "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2man.py")
set(re2c_rst2txt "${CMAKE_CURRENT_SOURCE_DIR}/build/rst2txt.py")
set(re2c_splitman "${CMAKE_CURRENT_SOURCE_DIR}/build/split_man.py")
set(re2c_docs
"${re2c_help}"
"${re2c_manpage_c}"
"$<$<BOOL:${RE2C_BUILD_RE2D}>:${re2c_manpage_d}>"
"$<$<BOOL:${RE2C_BUILD_RE2GO}>:${re2c_manpage_go}>"
"$<$<BOOL:${RE2C_BUILD_RE2HS}>:${re2c_manpage_haskell}>"
"$<$<BOOL:${RE2C_BUILD_RE2JAVA}>:${re2c_manpage_java}>"
"$<$<BOOL:${RE2C_BUILD_RE2JS}>:${re2c_manpage_js}>"
"$<$<BOOL:${RE2C_BUILD_RE2OCAML}>:${re2c_manpage_ocaml}>"
"$<$<BOOL:${RE2C_BUILD_RE2PY}>:${re2c_manpage_python}>"
"$<$<BOOL:${RE2C_BUILD_RE2RUST}>:${re2c_manpage_rust}>"
"$<$<BOOL:${RE2C_BUILD_RE2SWIFT}>:${re2c_manpage_swift}>"
"$<$<BOOL:${RE2C_BUILD_RE2V}>:${re2c_manpage_v}>"
"$<$<BOOL:${RE2C_BUILD_RE2ZIG}>:${re2c_manpage_zig}>"
)
# syntax files
set(re2c_stx2cpp "${CMAKE_CURRENT_SOURCE_DIR}/build/stx2cpp.py")
set(top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
set(top_builddir "${CMAKE_CURRENT_BINARY_DIR}")
set(PYTHON "${Python3_EXECUTABLE}")
@@ -92,10 +142,12 @@ set(PYTHON "${Python3_EXECUTABLE}")
configure_file(doc/manpage.rst.in doc/manpage.rst @ONLY)
configure_file(doc/help.rst.in doc/help.rst @ONLY)
configure_file(run_tests.py.in run_tests.py @ONLY)
set(RE2C_RUN_TESTS "${CMAKE_CURRENT_BINARY_DIR}/run_tests.py")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND chmod +x "${RE2C_RUN_TESTS}")
if(RE2C_BUILD_TESTS)
configure_file(run_tests.py.in run_tests.py @ONLY)
set(RE2C_RUN_TESTS "${CMAKE_CURRENT_BINARY_DIR}/run_tests.py")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND chmod +x "${RE2C_RUN_TESTS}")
endif()
endif()
ac_config_headers("config.h")
@@ -113,12 +165,26 @@ include_directories(. "${CMAKE_CURRENT_BINARY_DIR}")
# WARNING: custom target that depends on autogenerated sources won't do here
# as its dependencies get built multiple times, which ruins parallel builds.
add_library(re2c_objects_autogen OBJECT
"${CMAKE_CURRENT_BINARY_DIR}/src/options/parse_opts.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lexer.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lexer.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/parser.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/parser.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lex.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lex.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/lex_conf.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/options/parse_opts.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/conf_lexer.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/conf_parser.cc"
"${CMAKE_CURRENT_BINARY_DIR}/src/parse/conf_parser.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_c.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_d.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_go.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_haskell.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_java.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_js.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_ocaml.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_python.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_rust.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_swift.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_v.h"
"${CMAKE_CURRENT_BINARY_DIR}/src/default_syntax_zig.h"
"${re2c_docs}"
)
add_library(re2c_objects_autogen_ver_to_vernum OBJECT
@@ -164,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
@@ -189,156 +256,225 @@ set(re2c_sources
$<TARGET_OBJECTS:re2c_objects_autogen_ver_to_vernum>
)
re2c_bootstrap_lexer("src/msg/ver_to_vernum.re" "src/msg/ver_to_vernum.cc")
re2c_bootstrap_lexer("src/options/parse_opts.re" "src/options/parse_opts.cc")
re2c_bootstrap_lexer("src/parse/lexer.re" "src/parse/lexer.cc" "src/parse/lexer.h")
re2c_bootstrap_parser("src/parse/parser.ypp" "src/parse/parser.cc" "src/parse/parser.h")
re2c_bootstrap_lexer("src/parse/conf_lexer.re" "src/parse/conf_lexer.cc")
re2c_bootstrap_parser("src/parse/conf_parser.ypp" "src/parse/conf_parser.cc" "src/parse/conf_parser.h")
re2c_bootstrap_syntax("include/syntax/c" "src/default_syntax_c.h")
re2c_bootstrap_syntax("include/syntax/d" "src/default_syntax_d.h")
re2c_bootstrap_syntax("include/syntax/go" "src/default_syntax_go.h")
re2c_bootstrap_syntax("include/syntax/haskell" "src/default_syntax_haskell.h")
re2c_bootstrap_syntax("include/syntax/java" "src/default_syntax_java.h")
re2c_bootstrap_syntax("include/syntax/js" "src/default_syntax_js.h")
re2c_bootstrap_syntax("include/syntax/ocaml" "src/default_syntax_ocaml.h")
re2c_bootstrap_syntax("include/syntax/python" "src/default_syntax_python.h")
re2c_bootstrap_syntax("include/syntax/rust" "src/default_syntax_rust.h")
re2c_bootstrap_syntax("include/syntax/swift" "src/default_syntax_swift.h")
re2c_bootstrap_syntax("include/syntax/v" "src/default_syntax_v.h")
re2c_bootstrap_syntax("include/syntax/zig" "src/default_syntax_zig.h")
# docs
file(GLOB_RECURSE re2c_docs_sources CONFIGURE_DEPENDS
"examples/*"
"doc/manual/*"
"${re2c_manpage_source}"
)
re2c_gen_help("${re2c_help_source}" "${re2c_help_c}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_c}")
add_custom_target(docs DEPENDS "${re2c_docs}")
# re2c
add_executable(re2c ${re2c_sources})
add_executable(re2c ${re2c_sources} "${re2c_help_c}")
# re2d
if (RE2C_BUILD_RE2D)
re2c_gen_help("${re2c_help_source}" "${re2c_help_d}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_d}")
add_executable(re2d ${re2c_sources} "${re2c_help_d}")
target_compile_definitions(re2d PUBLIC
"RE2C_LANG=Lang::D"
"RE2C_PROG=\"re2d\""
)
endif()
# re2go
if (RE2C_BUILD_RE2GO)
add_executable(re2go ${re2c_sources})
target_compile_definitions(re2go PUBLIC "RE2C_LANG=Lang::GO")
re2c_gen_help("${re2c_help_source}" "${re2c_help_go}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_go}")
add_executable(re2go ${re2c_sources} "${re2c_help_go}")
target_compile_definitions(re2go PUBLIC
"RE2C_LANG=Lang::GO"
"RE2C_PROG=\"re2go\""
)
endif()
# re2hs
if (RE2C_BUILD_RE2HS)
re2c_gen_help("${re2c_help_source}" "${re2c_help_haskell}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_haskell}")
add_executable(re2hs ${re2c_sources} "${re2c_help_haskell}")
target_compile_definitions(re2hs PUBLIC
"RE2C_LANG=Lang::HASKELL"
"RE2C_PROG=\"re2hs\""
)
endif()
# re2java
if (RE2C_BUILD_RE2JAVA)
re2c_gen_help("${re2c_help_source}" "${re2c_help_java}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_java}")
add_executable(re2java ${re2c_sources} "${re2c_help_java}")
target_compile_definitions(re2java PUBLIC
"RE2C_LANG=Lang::JAVA"
"RE2C_PROG=\"re2java\""
)
endif()
# re2js
if (RE2C_BUILD_RE2JS)
re2c_gen_help("${re2c_help_source}" "${re2c_help_js}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_js}")
add_executable(re2js ${re2c_sources} "${re2c_help_js}")
target_compile_definitions(re2js PUBLIC
"RE2C_LANG=Lang::JS"
"RE2C_PROG=\"re2js\""
)
endif()
# re2ocaml
if (RE2C_BUILD_RE2OCAML)
re2c_gen_help("${re2c_help_source}" "${re2c_help_ocaml}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_ocaml}")
add_executable(re2ocaml ${re2c_sources} "${re2c_help_ocaml}")
target_compile_definitions(re2ocaml PUBLIC
"RE2C_LANG=Lang::OCAML"
"RE2C_PROG=\"re2ocaml\""
)
endif()
# re2py
if (RE2C_BUILD_RE2PY)
re2c_gen_help("${re2c_help_source}" "${re2c_help_python}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_python}")
add_executable(re2py ${re2c_sources} "${re2c_help_python}")
target_compile_definitions(re2py PUBLIC
"RE2C_LANG=Lang::PYTHON"
"RE2C_PROG=\"re2py\""
)
endif()
# re2rust
if (RE2C_BUILD_RE2RUST)
add_executable(re2rust ${re2c_sources})
target_compile_definitions(re2rust PUBLIC "RE2C_LANG=Lang::RUST")
re2c_gen_help("${re2c_help_source}" "${re2c_help_rust}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_rust}")
add_executable(re2rust ${re2c_sources} "${re2c_help_rust}")
target_compile_definitions(re2rust PUBLIC
"RE2C_LANG=Lang::RUST"
"RE2C_PROG=\"re2rust\""
)
endif()
re2c_bootstrap_lexer("src/parse/lex.re" "src/parse/lex.cc" "src/parse/lex.h")
re2c_bootstrap_lexer("src/parse/lex_conf.re" "src/parse/lex_conf.cc")
re2c_bootstrap_lexer("src/options/parse_opts.re" "src/options/parse_opts.cc")
re2c_bootstrap_lexer("src/msg/ver_to_vernum.re" "src/msg/ver_to_vernum.cc")
re2c_bootstrap_parser("src/parse/parser.ypp" "src/parse/parser.cc" "src/parse/parser.h")
if (RE2C_BUILD_RE2SWIFT)
re2c_gen_help("${re2c_help_source}" "${re2c_help_swift}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_swift}")
add_executable(re2swift ${re2c_sources} "${re2c_help_swift}")
target_compile_definitions(re2swift PUBLIC
"RE2C_LANG=Lang::SWIFT"
"RE2C_PROG=\"re2swift\""
)
endif()
# docs
set(re2c_docs_sources
"${re2c_manpage_source}"
"doc/manual/api/interface.rst_"
"doc/manual/conditions/blocks.rst_"
"doc/manual/conditions/conditions.rst_"
"doc/manual/configurations/configurations.rst_"
"doc/manual/directives/directives.rst_"
"doc/manual/dot/dot.rst_"
"doc/manual/encodings/encodings.rst_"
"doc/manual/eof/01_sentinel.rst_"
"doc/manual/eof/02_bounds_checking.rst_"
"doc/manual/eof/03_eof_rule.rst_"
"doc/manual/eof/04_generic_api.rst_"
"doc/manual/eof/eof.rst_"
"doc/manual/fill/01_fill.rst_"
"doc/manual/fill/02_fill.rst_"
"doc/manual/fill/fill.rst_"
"doc/manual/headers/headers.rst_"
"doc/manual/includes/includes.rst_"
"doc/manual/options/debug.rst_"
"doc/manual/options/internal.rst_"
"doc/manual/options/options.rst_"
"doc/manual/regexps/regular_expressions.rst_"
"doc/manual/reuse/reuse.rst_"
"doc/manual/skeleton/skeleton.rst_"
"doc/manual/state/state.rst_"
"doc/manual/submatch/submatch_example_mtags.rst_"
"doc/manual/submatch/submatch_example_posix.rst_"
"doc/manual/submatch/submatch_example_stags_fill.rst_"
"doc/manual/submatch/submatch_example_stags.rst_"
"doc/manual/submatch/submatch.rst_"
"doc/manual/synopsis.rst_"
"doc/manual/syntax/api1.rst_"
"doc/manual/syntax/api2_c.rst_"
"doc/manual/syntax/api2_go.rst_"
"doc/manual/syntax/api2_rust.rst_"
"doc/manual/syntax/api3.rst_"
"doc/manual/syntax/intro.rst_"
"doc/manual/syntax/syntax.rst_"
"doc/manual/warnings/warnings_general.rst_"
"doc/manual/warnings/warnings_list.rst_"
"examples/c/01_basic.re"
"examples/c/01_basic.c"
"examples/c/conditions/parse_u32_blocks.re"
"examples/c/conditions/parse_u32_conditions.re"
"examples/c/encodings/unicode_identifier.re"
"examples/c/eof/01_sentinel.re"
"examples/c/eof/02_bounds_checking.re"
"examples/c/eof/03_eof_rule.re"
"examples/c/eof/05_generic_api_eof_rule.re"
"examples/c/fill/01_fill.re"
"examples/c/fill/02_fill.re"
"examples/c/headers/header.re"
"examples/c/headers/lexer/state.h"
"examples/c/includes/include.re"
"examples/c/includes/definitions.h"
"examples/c/reuse/reuse.re"
"examples/c/reuse/usedir.re"
"examples/c/state/push.re"
"examples/c/submatch/01_stags_fill.re"
"examples/c/submatch/01_stags.re"
"examples/c/submatch/02_mtags.re"
"examples/c/submatch/03_posix.re"
"examples/go/01_basic.re"
"examples/go/01_basic.go"
"examples/go/conditions/parse_u32_blocks.re"
"examples/go/conditions/parse_u32_conditions.re"
"examples/go/encodings/unicode_identifier.re"
"examples/go/eof/01_sentinel.re"
"examples/go/eof/02_bounds_checking.re"
"examples/go/eof/03_eof_rule.re"
"examples/go/eof/05_generic_api_eof_rule.re"
"examples/go/fill/01_fill.re"
"examples/go/fill/02_fill.re"
"examples/go/headers/header.re"
"examples/go/headers/lexer/state.go"
"examples/go/includes/include.re"
"examples/go/includes/definitions.go"
"examples/go/reuse/reuse.re"
"examples/go/reuse/usedir.re"
"examples/go/state/push.re"
"examples/go/submatch/01_stags_fill.re"
"examples/go/submatch/01_stags.re"
"examples/go/submatch/02_mtags.re"
"examples/go/submatch/03_posix.re"
"examples/rust/01_basic.re"
"examples/rust/01_basic.rs"
"examples/rust/conditions/parse_u32_blocks.re"
"examples/rust/conditions/parse_u32_conditions.re"
"examples/rust/encodings/unicode_identifier.re"
"examples/rust/eof/01_sentinel.re"
"examples/rust/eof/02_bounds_checking.re"
"examples/rust/eof/03_eof_rule.re"
"examples/rust/eof/05_generic_api_eof_rule.re"
"examples/rust/fill/01_fill.re"
"examples/rust/fill/02_fill.re"
"examples/rust/headers/header.re"
"examples/rust/headers/lexer/state.rs"
"examples/rust/includes/include.re"
"examples/rust/includes/definitions.rs"
"examples/rust/reuse/reuse.re"
"examples/rust/reuse/usedir.re"
"examples/rust/state/push.re"
"examples/rust/submatch/01_stags_fill.re"
"examples/rust/submatch/01_stags.re"
"examples/rust/submatch/02_mtags.re"
"examples/rust/submatch/03_posix.re"
)
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_c}" "${re2c_manpage_bootstrap_c}" "c")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_go}" "${re2c_manpage_bootstrap_go}" "go")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_rust}" "${re2c_manpage_bootstrap_rust}" "rust")
re2c_gen_help("${re2c_help_source}" "${re2c_help}" "${re2c_help_bootstrap}")
add_custom_target(docs DEPENDS "${re2c_docs}")
# re2v
if (RE2C_BUILD_RE2V)
re2c_gen_help("${re2c_help_source}" "${re2c_help_v}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_v}")
add_executable(re2v ${re2c_sources} "${re2c_help_v}")
target_compile_definitions(re2v PUBLIC
"RE2C_LANG=Lang::V"
"RE2C_PROG=\"re2v\""
)
endif()
# install and test targets are enabled only if re2c is the root project
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# re2zig
if (RE2C_BUILD_RE2ZIG)
re2c_gen_help("${re2c_help_source}" "${re2c_help_zig}")
re2c_gen_manpage("${re2c_manpage_source}" "${re2c_manpage_zig}")
add_executable(re2zig ${re2c_sources} "${re2c_help_zig}")
target_compile_definitions(re2zig PUBLIC
"RE2C_LANG=Lang::ZIG"
"RE2C_PROG=\"re2zig\""
)
endif()
# install targets are enabled only if re2c is the root project
if(RE2C_IS_ROOT_PROJECT)
# install
install(TARGETS re2c RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_c}" DESTINATION "share/man/man1")
if(RE2C_BUILD_RE2D)
install(TARGETS re2d RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_d}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2GO)
install(TARGETS re2go RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_go}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2HS)
install(TARGETS re2hs RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_haskell}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2JAVA)
install(TARGETS re2java RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_java}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2JS)
install(TARGETS re2js RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_js}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2OCAML)
install(TARGETS re2ocaml RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_ocaml}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2PY)
install(TARGETS re2py RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_python}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2RUST)
install(TARGETS re2rust RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_rust}" DESTINATION "share/man/man1")
endif()
install(FILES include/unicode_categories.re DESTINATION "${RE2C_STDLIB_DIR}")
if(RE2C_BUILD_RE2SWIFT)
install(TARGETS re2swift RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_swift}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2V)
install(TARGETS re2v RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_v}" DESTINATION "share/man/man1")
endif()
if(RE2C_BUILD_RE2ZIG)
install(TARGETS re2zig RUNTIME DESTINATION bin)
install(FILES "${re2c_manpage_zig}" DESTINATION "share/man/man1")
endif()
install(FILES
include/syntax/c
include/syntax/d
include/syntax/go
include/syntax/haskell
include/syntax/java
include/syntax/js
include/syntax/ocaml
include/syntax/python
include/syntax/rust
include/syntax/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
add_custom_target(bootstrap
@@ -346,7 +482,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
COMMAND "${CMAKE_COMMAND}" -E remove_directory "doc"
COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}"
)
endif()
if(RE2C_BUILD_TESTS)
# tests
add_custom_target(tests
DEPENDS "${RE2C_RUN_TESTS}"
@@ -366,6 +504,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
COMMAND "${Python3_EXECUTABLE}" "${RE2C_RUN_TESTS}" --wine -j1
)
add_dependencies(wtests re2c)
add_executable(re2c_test_list
src/test/list/test.cc
)
add_executable(re2c_test_range
src/test/range/test-impl.h
src/test/range/test.cc
@@ -383,9 +524,9 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
)
add_executable(re2c_test_argsubst
src/test/argsubst/test.cc
src/codegen/helpers.cc
)
add_custom_target(check_re2c
COMMAND ./re2c_test_list
COMMAND ./re2c_test_range
COMMAND ./re2c_test_s_to_n32_unsafe
COMMAND ./re2c_test_ver_to_vernum
@@ -460,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
@@ -510,29 +652,32 @@ if (RE2C_BUILD_LIBS)
endif()
# libre2c test
add_executable(test_libre2c lib/test.cc)
target_link_libraries(test_libre2c libre2c)
target_link_libraries(test_libre2c test_libre2c_objects_autogen)
add_custom_target(check_libre2c
COMMAND ./test_libre2c
)
if(RE2C_BUILD_TESTS)
add_executable(test_libre2c lib/test.cc)
target_link_libraries(test_libre2c libre2c)
target_link_libraries(test_libre2c test_libre2c_objects_autogen)
add_custom_target(check_libre2c
COMMAND ./test_libre2c
)
endif()
if(RE2C_BUILD_BENCHMARKS)
add_subdirectory(benchmarks/submatch_nfa)
add_subdirectory(benchmarks/submatch_dfa_jit)
add_subdirectory(benchmarks/submatch_java)
add_subdirectory(benchmarks/c/libre2c/nfa)
add_subdirectory(benchmarks/c/libre2c/jit)
add_subdirectory(benchmarks/c/libre2c/java)
endif()
else()
# empty check target
add_custom_target(check_libre2c)
if(RE2C_BUILD_TESTS)
add_custom_target(check_libre2c)
endif()
endif()
if(RE2C_BUILD_BENCHMARKS)
add_subdirectory(benchmarks/submatch_dfa_aot)
add_subdirectory(benchmarks/c)
endif()
# only add check target if toplevel project
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
if(RE2C_BUILD_TESTS)
add_custom_target(check)
add_dependencies(check check_re2c check_libre2c)
endif()
+120 -12
View File
@@ -11,8 +11,17 @@
"hidden": true,
"installDir": "${sourceDir}/install-2",
"cacheVariables": {
"RE2C_BUILD_RE2D": true,
"RE2C_BUILD_RE2GO": true,
"RE2C_BUILD_RE2HS": true,
"RE2C_BUILD_RE2JAVA": true,
"RE2C_BUILD_RE2JS": true,
"RE2C_BUILD_RE2OCAML": true,
"RE2C_BUILD_RE2PY": true,
"RE2C_BUILD_RE2RUST": true,
"RE2C_BUILD_RE2SWIFT": true,
"RE2C_BUILD_RE2V": true,
"RE2C_BUILD_RE2ZIG": true,
"RE2C_BUILD_LIBS": true,
"RE2C_REBUILD_LEXERS": true,
"RE2C_REBUILD_DOCS": true,
@@ -48,8 +57,17 @@
"CMAKE_BUILD_TYPE": "Ubsan",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -67,8 +85,17 @@
"CMAKE_BUILD_TYPE": "Asan",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -86,8 +113,17 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -111,8 +147,17 @@
"CMAKE_CXX_FLAGS": "-O2 -m32",
"CMAKE_EXE_LINKER_FLAGS": "-m32",
"CMAKE_SHARED_LINKER_FLAGS": "-m32",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -128,8 +173,17 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -177,8 +231,17 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -196,8 +259,17 @@
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_FLAGS": "-O2",
"CMAKE_CXX_FLAGS": "-O2",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -213,8 +285,17 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -227,7 +308,7 @@
{
"name": "windows-config-base",
"hidden": true,
"generator": "Visual Studio 17 2022",
"generator": "Visual Studio 18 2026",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
@@ -250,8 +331,17 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -267,8 +357,17 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
@@ -284,8 +383,17 @@
"installDir": "${sourceDir}/install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"RE2C_BUILD_RE2D": false,
"RE2C_BUILD_RE2GO": false,
"RE2C_BUILD_RE2RUST": false
"RE2C_BUILD_RE2HS": false,
"RE2C_BUILD_RE2JAVA": false,
"RE2C_BUILD_RE2JS": false,
"RE2C_BUILD_RE2OCAML": false,
"RE2C_BUILD_RE2PY": false,
"RE2C_BUILD_RE2RUST": false,
"RE2C_BUILD_RE2SWIFT": false,
"RE2C_BUILD_RE2V": false,
"RE2C_BUILD_RE2ZIG": false
}
},
{
+4
View File
@@ -47,6 +47,10 @@ with options `--enable-parsers` (Autotools) or `-DRE2C_REBUILD_PARSERS=ON`
(CMake). In this case `bison` must be installed on the system. Otherwise
Autoconf or CMake will fail at configuration stage.
For changes that affect syntax files, regeneration mode is configured
with options `--enable-syntax` (Autotools) or `-DRE2C_REBUILD_SYNTAX=ON`
(CMake).
For changes that update documentation, it is necessary to rebuild the bootstrap
manpages by reconfiguring and rebuilding re2c with options `--enable-docs`
(Autotools) or `-DRE2C_REBUILD_DOCS=ON` (CMake).
+1 -1
View File
@@ -41,6 +41,6 @@ requires some research. Does TDFA present any special difficulties?
## Location support
It would be good to have something like Bison locations (automatic tracking of
line/column/filename inforamtion). This is primarily useful for tokenizers and
line/column/filename information). This is primarily useful for tokenizers and
large lexers.
+9
View File
@@ -0,0 +1,9 @@
module(
name = "re2c",
version = "4.0.2",
compatibility_level = 4,
bazel_compatibility = [">=7.0.0"]
)
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.0.17")
+537 -142
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 \
@@ -130,146 +131,345 @@ re2c_SOURCES = \
$(re2c_SRC)
# autogenerated sources
re2c_GEN_HELP = src/msg/help.cc
re2c_GEN_LEX = src/parse/lex.cc
re2c_GEN_PARSER = src/parse/parser.cc
re2c_GEN_PARSER_HDR = src/parse/parser.h
re2c_GEN_VER_TO_VERNUM = src/msg/ver_to_vernum.cc
re2c_GEN_SRC = \
$(re2c_GEN_HELP) \
$(re2c_GEN_LEX) \
$(re2c_GEN_PARSER) \
$(re2c_GEN_VER_TO_VERNUM) \
src/parse/lex_conf.cc \
src/options/parse_opts.cc
src/msg/ver_to_vernum.cc \
src/options/parse_opts.cc \
src/parse/lexer.cc \
src/parse/parser.cc \
src/parse/conf_lexer.cc \
src/parse/conf_parser.cc
re2c_GEN_HDR = \
src/parse/lex.h \
$(re2c_GEN_PARSER_HDR)
src/parse/parser.h \
src/parse/conf_parser.h \
src/parse/lexer.h
re2c_GEN_STX = \
src/default_syntax_c.h \
src/default_syntax_d.h \
src/default_syntax_go.h \
src/default_syntax_haskell.h \
src/default_syntax_java.h \
src/default_syntax_js.h \
src/default_syntax_ocaml.h \
src/default_syntax_python.h \
src/default_syntax_rust.h \
src/default_syntax_swift.h \
src/default_syntax_v.h \
src/default_syntax_zig.h
re2c_GEN = \
$(re2c_GEN_SRC) \
$(re2c_GEN_HDR)
nodist_re2c_SOURCES = $(re2c_GEN)
$(re2c_GEN_HDR) \
$(re2c_GEN_STX)
nodist_re2c_SOURCES = \
$(re2c_GEN) \
src/msg/help_re2c.cc
# custom rules create headers and must go before normal rules
BUILT_SOURCES = $(re2c_GEN_SRC)
BUILT_SOURCES = $(re2c_GEN_SRC) $(re2c_GEN_STX)
# bootstrap sources
re2c_BOOT_PARSER = bootstrap/src/parse/parser.cc
re2c_BOOT_PARSER_HDR = bootstrap/src/parse/parser.h
re2c_BOOT_DOC_C = bootstrap/doc/re2c.1
re2c_BOOT_DOC_GO = bootstrap/doc/re2go.1
re2c_BOOT_DOC_RUST = bootstrap/doc/re2rust.1
re2c_BOOT_HELP = bootstrap/src/msg/help.cc
re2c_BOOT = \
$(re2c_BOOT_DOC_C) \
$(re2c_BOOT_DOC_GO) \
$(re2c_BOOT_DOC_RUST) \
$(re2c_BOOT_HELP) \
$(re2c_BOOT_PARSER) \
$(re2c_BOOT_PARSER_HDR) \
bootstrap/src/parse/lex.cc \
bootstrap/src/parse/lex.h \
bootstrap/src/parse/lex_conf.cc \
bootstrap/doc/re2c.1 \
bootstrap/doc/re2d.1 \
bootstrap/doc/re2go.1 \
bootstrap/doc/re2hs.1 \
bootstrap/doc/re2java.1 \
bootstrap/doc/re2js.1 \
bootstrap/doc/re2ocaml.1 \
bootstrap/doc/re2py.1 \
bootstrap/doc/re2rust.1 \
bootstrap/doc/re2swift.1 \
bootstrap/doc/re2v.1 \
bootstrap/doc/re2zig.1 \
bootstrap/src/default_syntax_c.h \
bootstrap/src/default_syntax_d.h \
bootstrap/src/default_syntax_go.h \
bootstrap/src/default_syntax_haskell.h \
bootstrap/src/default_syntax_java.h \
bootstrap/src/default_syntax_js.h \
bootstrap/src/default_syntax_ocaml.h \
bootstrap/src/default_syntax_python.h \
bootstrap/src/default_syntax_rust.h \
bootstrap/src/default_syntax_swift.h \
bootstrap/src/default_syntax_v.h \
bootstrap/src/default_syntax_zig.h \
bootstrap/src/msg/help_re2c.cc \
bootstrap/src/msg/help_re2d.cc \
bootstrap/src/msg/help_re2go.cc \
bootstrap/src/msg/help_re2hs.cc \
bootstrap/src/msg/help_re2java.cc \
bootstrap/src/msg/help_re2js.cc \
bootstrap/src/msg/help_re2ocaml.cc \
bootstrap/src/msg/help_re2py.cc \
bootstrap/src/msg/help_re2rust.cc \
bootstrap/src/msg/help_re2swift.cc \
bootstrap/src/msg/help_re2v.cc \
bootstrap/src/msg/help_re2zig.cc \
bootstrap/src/msg/ver_to_vernum.cc \
bootstrap/src/options/parse_opts.cc \
bootstrap/src/msg/ver_to_vernum.cc
bootstrap/src/parse/lexer.cc \
bootstrap/src/parse/lexer.h \
bootstrap/src/parse/parser.cc \
bootstrap/src/parse/parser.h \
bootstrap/src/parse/conf_lexer.cc \
bootstrap/src/parse/conf_parser.h \
bootstrap/src/parse/conf_parser.cc
# custom sources
re2c_CUSTOM_PARSER = src/parse/parser.ypp
re2c_CUSTOM_HELP = doc/help.rst
re2c_CUSTOM = \
$(re2c_CUSTOM_PARSER) \
$(re2c_CUSTOM_HELP) \
src/parse/lex.re \
src/parse/lex_conf.re \
src/msg/ver_to_vernum.re \
src/options/parse_opts.re \
src/msg/ver_to_vernum.re
src/parse/lexer.re \
src/parse/parser.ypp \
src/parse/conf_lexer.re \
src/parse/conf_parser.ypp
# docs
re2c_SRC_DOC = doc/manpage.rst
# To build the list of examples for all backends, run:
# find examples -regex '.*\.re\|.*\(state\|01_basic\|definitions\)\..*' -printf '\t%p \\\n' | sort
re2c_SRC_DOC_EXT = \
doc/manual/api/interface.rst_ \
doc/manual/conditions/blocks.rst_ \
doc/manual/conditions/conditions.rst_ \
doc/manual/configurations/configurations.rst_ \
doc/manual/directives/directives.rst_ \
doc/manual/dot/dot.rst_ \
doc/manual/encodings/encodings.rst_ \
doc/manual/basics/api/api1.rst_ \
doc/manual/basics/api/api2_c.rst_ \
doc/manual/basics/api/api2_d.rst_ \
doc/manual/basics/api/api2_go.rst_ \
doc/manual/basics/api/api2_haskell.rst_ \
doc/manual/basics/api/api2_java.rst_ \
doc/manual/basics/api/api2_js.rst_ \
doc/manual/basics/api/api2_ocaml.rst_ \
doc/manual/basics/api/api2_python.rst_ \
doc/manual/basics/api/api2_rust.rst_ \
doc/manual/basics/api/api2_swift.rst_ \
doc/manual/basics/api/api2_v.rst_ \
doc/manual/basics/api/api2_zig.rst_ \
doc/manual/basics/api/api3.rst_ \
doc/manual/basics/actions.rst_ \
doc/manual/basics/blocks.rst_ \
doc/manual/basics/directives.rst_ \
doc/manual/basics/configurations.rst_ \
doc/manual/basics/regular_expressions.rst_ \
doc/manual/basics/syntax.rst_ \
doc/manual/basics/syntax_files.rst_ \
doc/manual/basics/options/debug.rst_ \
doc/manual/basics/options/internal.rst_ \
doc/manual/basics/options/options.rst_ \
doc/manual/basics/warnings/warnings_general.rst_ \
doc/manual/basics/warnings/warnings_list.rst_ \
doc/manual/eof/01_sentinel.rst_ \
doc/manual/eof/02_bounds_checking.rst_ \
doc/manual/eof/03_eof_rule.rst_ \
doc/manual/eof/04_generic_api.rst_ \
doc/manual/eof/04_fake_sentinel.rst_ \
doc/manual/eof/eof.rst_ \
doc/manual/features/conditions/blocks.rst_ \
doc/manual/features/conditions/conditions.rst_ \
doc/manual/features/dot/dot.rst_ \
doc/manual/features/encodings/encodings.rst_ \
doc/manual/features/headers/headers.rst_ \
doc/manual/features/includes/includes.rst_ \
doc/manual/features/reuse/reuse.rst_ \
doc/manual/features/skeleton/skeleton.rst_ \
doc/manual/features/state/state.rst_ \
doc/manual/features/submatch/submatch_example_mtags.rst_ \
doc/manual/features/submatch/submatch_example_captures.rst_ \
doc/manual/features/submatch/submatch_example_stags_fill.rst_ \
doc/manual/features/submatch/submatch_example_stags.rst_ \
doc/manual/features/submatch/submatch.rst_ \
doc/manual/fill/01_fill.rst_ \
doc/manual/fill/02_fill.rst_ \
doc/manual/fill/fill.rst_ \
doc/manual/headers/headers.rst_ \
doc/manual/includes/includes.rst_ \
doc/manual/options/debug.rst_ \
doc/manual/options/internal.rst_ \
doc/manual/options/options.rst_ \
doc/manual/regexps/regular_expressions.rst_ \
doc/manual/reuse/reuse.rst_ \
doc/manual/skeleton/skeleton.rst_ \
doc/manual/state/state.rst_ \
doc/manual/submatch/submatch_example_mtags.rst_ \
doc/manual/submatch/submatch_example_posix.rst_ \
doc/manual/submatch/submatch_example_stags_fill.rst_ \
doc/manual/submatch/submatch_example_stags.rst_ \
doc/manual/submatch/submatch.rst_ \
doc/manual/authors.rst_ \
doc/manual/intro.rst_ \
doc/manual/synopsis.rst_ \
doc/manual/syntax/api1.rst_ \
doc/manual/syntax/api2_c.rst_ \
doc/manual/syntax/api2_go.rst_ \
doc/manual/syntax/api2_rust.rst_ \
doc/manual/syntax/api3.rst_ \
doc/manual/syntax/intro.rst_ \
doc/manual/syntax/syntax.rst_ \
doc/manual/warnings/warnings_general.rst_ \
doc/manual/warnings/warnings_list.rst_ \
examples/c/01_basic.re \
examples/c/01_basic.c \
examples/c/01_basic.re \
examples/c/conditions/parse_u32_blocks.re \
examples/c/conditions/parse_u32_conditions.re \
examples/c/encodings/unicode_identifier.re \
examples/c/eof/01_sentinel.re \
examples/c/eof/02_bounds_checking.re \
examples/c/eof/03_eof_rule.re \
examples/c/eof/05_generic_api_eof_rule.re \
examples/c/eof/04_fake_sentinel.re \
examples/c/eof/05_fake_sentinel_eof_rule.re \
examples/c/fill/01_fill.re \
examples/c/fill/02_fill.re \
examples/c/generic_api/ifstream.re \
examples/c/headers/header.re \
examples/c/headers/lexer/state.h \
examples/c/includes/include.re \
examples/c/includes/definitions.h \
examples/c/includes/include.re \
examples/c/real_world/cxx98.re \
examples/c/reuse/braille.re \
examples/c/reuse/reuse.re \
examples/c/reuse/usedir.re \
examples/c/state/push.re \
examples/c/submatch/01_stags_fill.re \
examples/c/submatch/01_stags.re \
examples/c/submatch/02_mtags.re \
examples/c/submatch/03_posix.re \
examples/go/01_basic.re \
examples/c/submatch/03_captures.re \
examples/c/submatch/04_posix_captures.re \
examples/c/submatch/http_rfc7230.re \
examples/c/submatch/parse_etc_passwd.re \
examples/c/submatch/parse_options.re \
examples/c/submatch/parse_records.re \
examples/c/submatch/uri_rfc3986.re \
examples/d/01_basic.d \
examples/d/01_basic.re \
examples/d/conditions/parse_u32_blocks.re \
examples/d/conditions/parse_u32_conditions.re \
examples/d/encodings/unicode_identifier.re \
examples/d/eof/01_sentinel.re \
examples/d/eof/02_bounds_checking.re \
examples/d/eof/03_eof_rule.re \
examples/d/eof/04_fake_sentinel.re \
examples/d/fill/01_fill.re \
examples/d/fill/02_fill.re \
examples/d/headers/header.re \
examples/d/headers/lexer/state.d \
examples/d/includes/definitions.d \
examples/d/includes/include.re \
examples/d/reuse/reuse.re \
examples/d/reuse/usedir.re \
examples/d/state/push.re \
examples/d/submatch/01_stags_fill.re \
examples/d/submatch/01_stags.re \
examples/d/submatch/02_mtags.re \
examples/d/submatch/03_captures.re \
examples/d/submatch/04_posix_captures.re \
examples/go/01_basic.go \
examples/go/01_basic.re \
examples/go/conditions/parse_u32_blocks.re \
examples/go/conditions/parse_u32_conditions.re \
examples/go/encodings/unicode_identifier.re \
examples/go/eof/01_sentinel.re \
examples/go/eof/02_bounds_checking.re \
examples/go/eof/03_eof_rule.re \
examples/go/eof/05_generic_api_eof_rule.re \
examples/go/eof/04_fake_sentinel.re \
examples/go/fill/01_fill.re \
examples/go/fill/02_fill.re \
examples/go/headers/header.re \
examples/go/headers/lexer/state.go \
examples/go/includes/include.re \
examples/go/includes/definitions.go \
examples/go/includes/include.re \
examples/go/reuse/reuse.re \
examples/go/reuse/usedir.re \
examples/go/state/push.re \
examples/go/submatch/01_stags_fill.re \
examples/go/submatch/01_stags.re \
examples/go/submatch/02_mtags.re \
examples/go/submatch/03_posix.re \
examples/go/submatch/03_captures.re \
examples/go/submatch/04_posix_captures.re \
examples/haskell/01_basic.hs \
examples/haskell/01_basic.re \
examples/haskell/conditions/parse_u32_blocks.re \
examples/haskell/conditions/parse_u32_conditions.re \
examples/haskell/encodings/unicode_identifier.re \
examples/haskell/eof/01_sentinel.re \
examples/haskell/eof/02_bounds_checking.re \
examples/haskell/eof/03_eof_rule.re \
examples/haskell/eof/04_fake_sentinel.re \
examples/haskell/fill/01_fill.re \
examples/haskell/fill/02_fill.re \
examples/haskell/headers/header.re \
examples/haskell/headers/lexer/state.hs \
examples/haskell/includes/definitions.hs \
examples/haskell/includes/include.re \
examples/haskell/reuse/reuse.re \
examples/haskell/reuse/usedir.re \
examples/haskell/state/push.re \
examples/haskell/submatch/01_stags_fill.re \
examples/haskell/submatch/01_stags.re \
examples/haskell/submatch/02_mtags.re \
examples/haskell/submatch/03_captures.re \
examples/java/01_basic.java \
examples/java/01_basic.re \
examples/java/conditions/parse_u32_blocks.re \
examples/java/conditions/parse_u32_conditions.re \
examples/java/encodings/unicode_identifier.re \
examples/java/eof/01_sentinel.re \
examples/java/eof/02_bounds_checking.re \
examples/java/eof/03_eof_rule.re \
examples/java/eof/04_fake_sentinel.re \
examples/java/fill/01_fill.re \
examples/java/fill/02_fill.re \
examples/java/headers/header.re \
examples/java/headers/lexer/state.java \
examples/java/includes/definitions.java \
examples/java/includes/include.re \
examples/java/reuse/reuse.re \
examples/java/reuse/usedir.re \
examples/java/state/push.re \
examples/java/submatch/01_stags_fill.re \
examples/java/submatch/01_stags.re \
examples/java/submatch/02_mtags.re \
examples/java/submatch/03_captures.re \
examples/java/submatch/04_posix_captures.re \
examples/js/01_basic.js \
examples/js/01_basic.re \
examples/js/conditions/parse_u32_blocks.re \
examples/js/conditions/parse_u32_conditions.re \
examples/js/encodings/unicode_identifier.re \
examples/js/eof/01_sentinel.re \
examples/js/eof/02_bounds_checking.re \
examples/js/eof/03_eof_rule.re \
examples/js/eof/04_fake_sentinel.re \
examples/js/fill/01_fill.re \
examples/js/fill/02_fill.re \
examples/js/headers/header.re \
examples/js/headers/lexer/state.js \
examples/js/includes/definitions.js \
examples/js/includes/include.re \
examples/js/reuse/reuse.re \
examples/js/reuse/usedir.re \
examples/js/state/push.re \
examples/js/submatch/01_stags_fill.re \
examples/js/submatch/01_stags.re \
examples/js/submatch/02_mtags.re \
examples/js/submatch/03_captures.re \
examples/js/submatch/04_posix_captures.re \
examples/ocaml/01_basic.ml \
examples/ocaml/01_basic.re \
examples/ocaml/conditions/parse_u32_blocks.re \
examples/ocaml/conditions/parse_u32_conditions.re \
examples/ocaml/encodings/unicode_identifier.re \
examples/ocaml/eof/01_sentinel.re \
examples/ocaml/eof/02_bounds_checking.re \
examples/ocaml/eof/03_eof_rule.re \
examples/ocaml/eof/04_fake_sentinel.re \
examples/ocaml/fill/01_fill.re \
examples/ocaml/fill/02_fill.re \
examples/ocaml/headers/header.re \
examples/ocaml/headers/lexer/state.ml \
examples/ocaml/includes/definitions.ml \
examples/ocaml/includes/include.re \
examples/ocaml/reuse/reuse.re \
examples/ocaml/reuse/usedir.re \
examples/ocaml/state/push.re \
examples/ocaml/submatch/01_stags_fill.re \
examples/ocaml/submatch/01_stags.re \
examples/ocaml/submatch/02_mtags.re \
examples/ocaml/submatch/03_captures.re \
examples/ocaml/submatch/04_posix_captures.re \
examples/python/01_basic.py \
examples/python/01_basic.re \
examples/python/conditions/parse_u32_blocks.re \
examples/python/conditions/parse_u32_conditions.re \
examples/python/encodings/unicode_identifier.re \
examples/python/eof/01_sentinel.re \
examples/python/eof/02_bounds_checking.re \
examples/python/eof/03_eof_rule.re \
examples/python/eof/04_fake_sentinel.re \
examples/python/fill/01_fill.re \
examples/python/fill/02_fill.re \
examples/python/headers/header.re \
examples/python/headers/lexer/state.py \
examples/python/includes/definitions.py \
examples/python/includes/include.re \
examples/python/reuse/reuse.re \
examples/python/reuse/usedir.re \
examples/python/state/push.re \
examples/python/submatch/01_stags_fill.re \
examples/python/submatch/01_stags.re \
examples/python/submatch/02_mtags.re \
examples/python/submatch/03_captures.re \
examples/python/submatch/04_posix_captures.re \
examples/rust/01_basic.re \
examples/rust/01_basic.rs \
examples/rust/conditions/parse_u32_blocks.re \
@@ -278,38 +478,160 @@ re2c_SRC_DOC_EXT = \
examples/rust/eof/01_sentinel.re \
examples/rust/eof/02_bounds_checking.re \
examples/rust/eof/03_eof_rule.re \
examples/rust/eof/05_generic_api_eof_rule.re \
examples/rust/eof/04_fake_sentinel.re \
examples/rust/fill/01_fill.re \
examples/rust/fill/02_fill.re \
examples/rust/headers/header.re \
examples/rust/headers/lexer/state.rs \
examples/rust/includes/include.re \
examples/rust/includes/definitions.rs \
examples/rust/includes/include.re \
examples/rust/real_world/c.re \
examples/rust/reuse/reuse.re \
examples/rust/reuse/usedir.re \
examples/rust/state/push.re \
examples/rust/submatch/01_stags_fill.re \
examples/rust/submatch/01_stags.re \
examples/rust/submatch/02_mtags.re \
examples/rust/submatch/03_posix.re
DOC_C = doc/re2c.1
DOCS = $(DOC_C)
examples/rust/submatch/03_captures.re \
examples/rust/submatch/04_posix_captures.re \
examples/swift/01_basic.re \
examples/swift/01_basic.swift \
examples/swift/conditions/parse_u32_blocks.re \
examples/swift/conditions/parse_u32_conditions.re \
examples/swift/encodings/unicode_identifier.re \
examples/swift/eof/01_sentinel.re \
examples/swift/eof/02_bounds_checking.re \
examples/swift/eof/03_eof_rule.re \
examples/swift/eof/04_fake_sentinel.re \
examples/swift/eof/05_fake_sentinel_eof_rule.re \
examples/swift/fill/01_fill.re \
examples/swift/fill/02_fill.re \
examples/swift/headers/header.re \
examples/swift/headers/lexer/state.swift \
examples/swift/includes/definitions.swift \
examples/swift/includes/include.re \
examples/swift/reuse/reuse.re \
examples/swift/reuse/usedir.re \
examples/swift/state/push.re \
examples/swift/submatch/01_stags.re \
examples/swift/submatch/01_stags_fill.re \
examples/swift/submatch/02_mtags.re \
examples/swift/submatch/03_captures.re \
examples/swift/submatch/04_posix_captures.re \
examples/v/01_basic.re \
examples/v/01_basic.v \
examples/v/conditions/parse_u32_blocks.re \
examples/v/conditions/parse_u32_conditions.re \
examples/v/encodings/unicode_identifier.re \
examples/v/eof/01_sentinel.re \
examples/v/eof/02_bounds_checking.re \
examples/v/eof/03_eof_rule.re \
examples/v/eof/04_fake_sentinel.re \
examples/v/fill/01_fill.re \
examples/v/fill/02_fill.re \
examples/v/headers/header.re \
examples/v/headers/lexer/state.v \
examples/v/includes/definitions.v \
examples/v/includes/include.re \
examples/v/reuse/reuse.re \
examples/v/reuse/usedir.re \
examples/v/state/push.re \
examples/v/submatch/01_stags_fill.re \
examples/v/submatch/01_stags.re \
examples/v/submatch/02_mtags.re \
examples/v/submatch/03_captures.re \
examples/v/submatch/04_posix_captures.re \
examples/zig/01_basic.re \
examples/zig/01_basic.zig \
examples/zig/conditions/parse_u32_blocks.re \
examples/zig/conditions/parse_u32_conditions.re \
examples/zig/encodings/unicode_identifier.re \
examples/zig/eof/01_sentinel.re \
examples/zig/eof/02_bounds_checking.re \
examples/zig/eof/03_eof_rule.re \
examples/zig/eof/04_fake_sentinel.re \
examples/zig/fill/01_fill.re \
examples/zig/fill/02_fill.re \
examples/zig/headers/header.re \
examples/zig/headers/lexer/state.zig \
examples/zig/includes/definitions.zig \
examples/zig/includes/include.re \
examples/zig/reuse/reuse.re \
examples/zig/reuse/usedir.re \
examples/zig/state/push.re \
examples/zig/submatch/01_stags_fill.re \
examples/zig/submatch/01_stags.re \
examples/zig/submatch/02_mtags.re \
examples/zig/submatch/03_captures.re \
examples/zig/submatch/04_posix_captures.re
DOCS = doc/re2c.1
HELP = src/msg/help_re2c.cc
if WITH_DLANG
DOCS += doc/re2d.1
HELP += src/msg/help_re2d.cc
endif
if WITH_GOLANG
DOC_GO = doc/re2go.1
DOCS += $(DOC_GO)
DOCS += doc/re2go.1
HELP += src/msg/help_re2go.cc
endif
if WITH_HASKELL
DOCS += doc/re2hs.1
HELP += src/msg/help_re2hs.cc
endif
if WITH_JAVA
DOCS += doc/re2java.1
HELP += src/msg/help_re2java.cc
endif
if WITH_JS
DOCS += doc/re2js.1
HELP += src/msg/help_re2js.cc
endif
if WITH_OCAML
DOCS += doc/re2ocaml.1
HELP += src/msg/help_re2ocaml.cc
endif
if WITH_PYTHON
DOCS += doc/re2py.1
HELP += src/msg/help_re2py.cc
endif
if WITH_RUST
DOC_RUST = doc/re2rust.1
DOCS += $(DOC_RUST)
DOCS += doc/re2rust.1
HELP += src/msg/help_re2rust.cc
endif
if WITH_SWIFT
DOCS += doc/re2swift.1
HELP += src/msg/help_re2swift.cc
endif
if WITH_VLANG
DOCS += doc/re2v.1
HELP += src/msg/help_re2v.cc
endif
if WITH_ZIG
DOCS += doc/re2zig.1
HELP += src/msg/help_re2zig.cc
endif
BUILT_SOURCES += $(HELP)
man_MANS = $(DOCS)
# include files (stdlib)
dist_stdlib_DATA = include/unicode_categories.re
dist_stdlib_DATA = \
include/syntax/c \
include/syntax/d \
include/syntax/go \
include/syntax/haskell \
include/syntax/java \
include/syntax/js \
include/syntax/ocaml \
include/syntax/python \
include/syntax/rust \
include/syntax/swift \
include/syntax/v \
include/syntax/zig \
include/unicode_blocks.re \
include/unicode_categories.re \
include/unicode_properties.re
BAZELFILES := \
BUILD.bazel \
@@ -342,14 +664,31 @@ EXTRA_DIST = \
CLEANFILES = \
$(re2c_GEN) \
$(DOCS)
$(re2c_GEN_HELP) \
$(DOCS) \
$(HELP)
if REBUILD_SYNTAX
STX2CPP = $(top_srcdir)/build/stx2cpp.py
# generate C++ sources from syntax configs and update bootstrap files
.stx.h:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(STX2CPP) $< $@
$(AM_V_GEN)cp -f $@ $(top_srcdir)/bootstrap/$@
else
# copy bootstrap files
.stx.h:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $(@D)
$(AM_V_at)echo "Reconfigure with --enable-syntax to regenerate $@"
endif
if REBUILD_LEXERS
# generate lexer and update bootstrap files
.re.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(RE2C_FOR_BUILD) $(RE2CFLAGS) -o $@ $<
$(AM_V_GEN)cp $(@:cc=[ch]*) $(top_srcdir)/bootstrap/$(@D);
$(AM_V_GEN)cp $(@:cc=[ch]*) $(top_srcdir)/bootstrap/$(@D)
else
# copy bootstrap files
.re.cc:
@@ -363,17 +702,18 @@ if REBUILD_PARSERS
.ypp.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(BISON) --warnings --output=$@ --defines=$(@:cc=h) $<
$(AM_V_GEN)cp $@ $(@:cc=h) $(top_srcdir)/bootstrap/$(@D);
$(AM_V_GEN)cp $@ $(@:cc=h) $(top_srcdir)/bootstrap/$(@D)
else
# copy bootstrap files
.ypp.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D);
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$(@:cc=*) $(@D)
$(AM_V_at)echo "Reconfigure with --enable-parsers to regenerate $@"
endif
# lexer depends on bison-generated header
$(re2c_GEN_LEX): $(re2c_GEN_PARSER)
# re2c-generated lexer depends on bison-generated parser header (generated by the parser rule)
src/parse/lexer.cc : src/parse/parser.cc
src/parse/conf_lexer.cc : src/parse/conf_parser.cc
# rebuild all re2c sources using newly built re2c
.PHONY: bootstrap
@@ -383,55 +723,34 @@ bootstrap: all
.PHONY: docs
if REBUILD_DOCS
docs: $(DOCS) $(re2c_GEN_HELP)
RST2TXT = $(top_srcdir)/build/rst2txt.py
RST2MAN = $(top_srcdir)/build/rst2man.py
SPLITMAN = $(top_srcdir)/build/split_man.py
# generate manpage for C
$(DOC_C): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
docs: $(DOCS) $(HELP)
$(DOCS) $(HELP) : $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN) $(RST2TXT)
# generate manpage
.rst.1:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).c c \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).c > $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_C) \
&& rm $(top_builddir)/$(re2c_SRC_DOC).c
# generate manpage for Go
$(DOC_GO): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).go go \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).go > $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_GO) \
&& rm $(top_builddir)/$(re2c_SRC_DOC).go
# generate manpage for Rust
$(DOC_RUST): $(re2c_SRC_DOC) $(re2c_SRC_DOC_EXT) $(SPLITMAN) $(RST2MAN)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$(re2c_SRC_DOC) $(top_builddir)/$(re2c_SRC_DOC).rust rust \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$(re2c_SRC_DOC).rust > $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_DOC_RUST) \
&& rm $(top_builddir)/$(re2c_SRC_DOC).rust
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$< $(top_builddir)/$< \
&& $(PYTHON) $(RST2MAN) --tab-width=4 $(top_builddir)/$< > $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@
# generate help
$(re2c_GEN_HELP): $(re2c_CUSTOM_HELP) $(re2c_SRC_DOC_EXT) $(RST2TXT)
.rst.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)$(PYTHON) $(RST2TXT) --variable-name=help $(top_builddir)/$(re2c_CUSTOM_HELP) $@ \
&& cp $@ $(top_srcdir)/$(re2c_BOOT_HELP)
$(AM_V_GEN)$(PYTHON) $(SPLITMAN) $(top_builddir)/$< $(top_builddir)/$< \
&& $(PYTHON) $(RST2TXT) --variable-name=help $(top_builddir)/$< $@ \
&& cp $@ $(top_srcdir)/bootstrap/$@
else
docs: $(DOCS) $(re2c_GEN_HELP)
docs: $(DOCS) $(HELP)
$(AM_V_at)echo "Reconfigure with --enable-docs to rebuild docs"
# copy bootstrap manpage for C
$(DOC_C): $(re2c_BOOT_DOC_C)
# copy bootstrap manpage
.rst.1:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_C) $@
# copy bootstrap manpage for Go
$(DOC_GO): $(re2c_BOOT_DOC_GO)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_GO) $@
# copy bootstrap manpage for Rust
$(DOC_RUST): $(re2c_BOOT_DOC_RUST)
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_DOC_RUST) $@
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $@
# copy bootstrap help
$(re2c_GEN_HELP): $(re2c_BOOT_HELP)
.rst.cc:
$(AM_V_at)$(MKDIR_P) $(@D)
$(AM_V_GEN)cp $(top_srcdir)/$(re2c_BOOT_HELP) $@
$(AM_V_GEN)cp $(top_srcdir)/bootstrap/$@ $@
endif
all-local: docs $(re2c_BOOT_PARSER)
@@ -448,6 +767,9 @@ vtests: all $(re2c_TESTSUITE)
wtests: all $(re2c_TESTSUITE)
$(PYTHON) $(top_builddir)/$(re2c_TESTSUITE) --wine -j1
re2c_test_list_SOURCES = \
src/test/list/test.cc
re2c_test_range_SOURCES = \
src/test/range/test-impl.h \
src/test/range/test.cc \
@@ -461,12 +783,13 @@ re2c_test_s_to_n32_unsafe_SOURCES = \
re2c_test_ver_to_vernum_SOURCES = \
src/test/ver_to_vernum/test.cc \
$(re2c_GEN_VER_TO_VERNUM)
src/msg/ver_to_vernum.cc
re2c_test_argsubst_SOURCES = \
src/test/argsubst/test.cc
check_PROGRAMS = \
re2c_test_list \
re2c_test_range \
re2c_test_s_to_n32_unsafe \
re2c_test_ver_to_vernum \
@@ -478,8 +801,8 @@ TESTS = \
# benchmarks
if WITH_BENCHMARKS
SUBDIRS += benchmarks/submatch_dfa_aot
EXTRA_DIST += benchmarks/submatch_dfa_aot
SUBDIRS += benchmarks/c
EXTRA_DIST += benchmarks/c
endif
# libre2c
@@ -489,18 +812,90 @@ lib_LTLIBRARIES =
include $(top_srcdir)/Makefile.lib.am
endif
# re2d
if WITH_DLANG
bin_PROGRAMS += re2d
re2d_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::D -DRE2C_PROG=\"re2d\"
re2d_SOURCES = $(re2c_SOURCES)
nodist_re2d_SOURCES = $(re2c_GEN) src/msg/help_re2d.cc
endif
# re2go
if WITH_GOLANG
bin_PROGRAMS += re2go
re2go_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::GO
re2go_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::GO -DRE2C_PROG=\"re2go\"
re2go_SOURCES = $(re2c_SOURCES)
nodist_re2go_SOURCES = $(nodist_re2c_SOURCES)
nodist_re2go_SOURCES = $(re2c_GEN) src/msg/help_re2go.cc
endif
# re2hs
if WITH_HASKELL
bin_PROGRAMS += re2hs
re2hs_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::HASKELL -DRE2C_PROG=\"re2hs\"
re2hs_SOURCES = $(re2c_SOURCES)
nodist_re2hs_SOURCES = $(re2c_GEN) src/msg/help_re2hs.cc
endif
# re2java
if WITH_JAVA
bin_PROGRAMS += re2java
re2java_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::JAVA -DRE2C_PROG=\"re2java\"
re2java_SOURCES = $(re2c_SOURCES)
nodist_re2java_SOURCES = $(re2c_GEN) src/msg/help_re2java.cc
endif
# re2js
if WITH_JS
bin_PROGRAMS += re2js
re2js_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::JS -DRE2C_PROG=\"re2js\"
re2js_SOURCES = $(re2c_SOURCES)
nodist_re2js_SOURCES = $(re2c_GEN) src/msg/help_re2js.cc
endif
# re2ocaml
if WITH_OCAML
bin_PROGRAMS += re2ocaml
re2ocaml_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::OCAML -DRE2C_PROG=\"re2ocaml\"
re2ocaml_SOURCES = $(re2c_SOURCES)
nodist_re2ocaml_SOURCES = $(re2c_GEN) src/msg/help_re2ocaml.cc
endif
# re2py
if WITH_PYTHON
bin_PROGRAMS += re2py
re2py_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::PYTHON -DRE2C_PROG=\"re2py\"
re2py_SOURCES = $(re2c_SOURCES)
nodist_re2py_SOURCES = $(re2c_GEN) src/msg/help_re2py.cc
endif
# re2rust
if WITH_RUST
bin_PROGRAMS += re2rust
re2rust_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::RUST
re2rust_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::RUST -DRE2C_PROG=\"re2rust\"
re2rust_SOURCES = $(re2c_SOURCES)
nodist_re2rust_SOURCES = $(nodist_re2c_SOURCES)
nodist_re2rust_SOURCES = $(re2c_GEN) src/msg/help_re2rust.cc
endif
# re2swift
if WITH_SWIFT
bin_PROGRAMS += re2swift
re2swift_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::SWIFT -DRE2C_PROG=\"re2swift\"
re2swift_SOURCES = $(re2c_SOURCES)
nodist_re2swift_SOURCES = $(re2c_GEN) src/msg/help_re2swift.cc
endif
# re2v
if WITH_VLANG
bin_PROGRAMS += re2v
re2v_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::V -DRE2C_PROG=\"re2v\"
re2v_SOURCES = $(re2c_SOURCES)
nodist_re2v_SOURCES = $(re2c_GEN) src/msg/help_re2v.cc
endif
# re2zig
if WITH_ZIG
bin_PROGRAMS += re2zig
re2zig_CXXFLAGS = $(AM_CXXFLAGS) -DRE2C_LANG=Lang::ZIG -DRE2C_PROG=\"re2zig\"
re2zig_SOURCES = $(re2c_SOURCES)
nodist_re2zig_SOURCES = $(re2c_GEN) src/msg/help_re2zig.cc
endif
+7 -6
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 \
@@ -169,12 +170,12 @@ check_PROGRAMS += test_libre2c
# benchmarks
if WITH_BENCHMARKS
SUBDIRS += benchmarks/submatch_nfa
SUBDIRS += benchmarks/submatch_dfa_jit
EXTRA_DIST += benchmarks/submatch_nfa
EXTRA_DIST += benchmarks/submatch_dfa_jit
SUBDIRS += benchmarks/c/libre2c/nfa
SUBDIRS += benchmarks/c/libre2c/jit
EXTRA_DIST += benchmarks/c/libre2c/nfa
EXTRA_DIST += benchmarks/c/libre2c/jit
if WITH_JAVA
SUBDIRS += benchmarks/submatch_java
EXTRA_DIST += benchmarks/submatch_java
SUBDIRS += benchmarks/c/libre2c/java
EXTRA_DIST += benchmarks/c/libre2c/java
endif # WITH_JAVA
endif # WITH_BENCHMARKS
+5 -3
View File
@@ -4,11 +4,13 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_skylib",
sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz",
],
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
)
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
bazel_skylib_workspace()
View File
+4 -4
View File
@@ -14,16 +14,16 @@ _RE2C_EXT = [".re", ".re2c"]
def _re2c_impl(ctx):
srcs = ctx.files.srcs
if len(srcs) != 1:
fail("Attribute `srcs` must contain exactly 1 re2c source file ({exts}).".format(exts=", ".join(_RE2C_EXT)))
fail("Attribute `srcs` must contain exactly 1 re2c source file ({exts}).".format(exts = ", ".join(_RE2C_EXT)))
outs = ctx.outputs.outs
if not outs or [o for o in outs if paths.split_extension(o.path)[1] not in _C_SRC_EXT + _C_HDR_EXT]:
fail("Attribute `outs` must contain at least 1 C/C++ shource or header file ({exts}).".format(exts=", ".join(_C_SRC_EXT + _C_HDR_EXT)))
fail("Attribute `outs` must contain at least 1 C/C++ shource or header file ({exts}).".format(exts = ", ".join(_C_SRC_EXT + _C_HDR_EXT)))
ctx.actions.run_shell(
outputs = outs + [err_file],
outputs = outs,
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,
@@ -2,8 +2,8 @@
import os
# 100 megabytes
LIMIT = 1024 * 1024 * 100
# 16 megabytes
LIMIT = 1024 * 1024 * 16
# read the small sample
with open('small', 'rb') as f:
+20
View File
@@ -0,0 +1,20 @@
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
12345678901
123456789012
1234567890123
12345678901234
123456789012345
1234567890123456
12345678901234567
123456789012345678
1234567890123456789
12345678901234567890
+97
View File
@@ -0,0 +1,97 @@
0b1
0b10
0b101
0b1010
0b10101
0b101010
0b1011010
0b10101010
0b101010101
0b1010101010
0b10101010101
0b101010101010
0b1010101010101
0b10101010101010
0b101010101010101
0b1010101010101010
0B1
0B10
0B111
0B1000
0B11111
0B100000
0B1111111
0B10000000
0B111111111
0B1000000000
0B11111111111
0B100000000000
0B1111111111111
0B10000000000000
0B111111111111111
0B1000000000000000
0
01
012
0123
01234
012345
0123456
01234567
012345670
1
12
123
1234
12345
123456
1234567
12345678
123456789
1234567890
0x1
0x12
0x123
0x1234
0x12345
0x123456
0x1234567
0x12345678
0x123456789
0x123456789a
0x123456789ab
0x123456789abc
0x123456789abcd
0x123456789abcde
0x123456789abcdef
0x123456789abcdef0
1.1e+1
12.12e-12
123.123e+123
1234.1234e-1234
12345.12345e+12345
123456.123456e-123456
1234567.1234567e+1234567
12345678.12345678e-12345678
123456789.123456789e+123456789
1234567890.1234567890e-1234567890
0.1
0.01
0.001
0.0001
0.00001
0.000001
0.0000001
0.00000001
0.000000001
0.0000000001
0.00000000001
0.000000000001
0.0000000000001
0.00000000000001
0.000000000000001
0.0000000000000001
0.00000000000000001
0.000000000000000001
0.0000000000000000001
0.00000000000000000001
+7
View File
@@ -0,0 +1,7 @@
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
+196
View File
@@ -0,0 +1,196 @@
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua and Barbuda
Argentina
Armenia
Australia
Austria
Azerbaijan
The Bahamas
Bahrain
Bangladesh
Barbados
Belarus
Belgium
Belize
Benin
Bhutan
Bolivia
Bosnia and Herzegovina
Botswana
Brazil
Brunei
Bulgaria
Burkina Faso
Burundi
Cabo Verde
Cambodia
Cameroon
Canada
Central African Republic
Chad
Chile
China
Colombia
Comoros
Congo, Democratic Republic of the
Congo, Republic of the
Costa Rica
Cote d'Ivoire
Croatia
Cuba
Cyprus
Czech Republic
Denmark
Djibouti
Dominica
Dominican Republic
East Timor (Timor-Leste)
Ecuador
Egypt
El Salvador
Equatorial Guinea
Eritrea
Estonia
Eswatini
Ethiopia
Fiji
Finland
France
Gabon
The Gambia
Georgia
Germany
Ghana
Greece
Grenada
Guatemala
Guinea
Guinea-Bissau
Guyana
Haiti
Honduras
Hungary
Iceland
India
Indonesia
Iran
Iraq
Ireland
Israel
Italy
Jamaica
Japan
Jordan
Kazakhstan
Kenya
Kiribati
Korea, North
Korea, South
Kosovo
Kuwait
Kyrgyzstan
Laos
Latvia
Lebanon
Lesotho
Liberia
Libya
Liechtenstein
Lithuania
Luxembourg
Madagascar
Malawi
Malaysia
Maldives
Mali
Malta
Marshall Islands
Mauritania
Mauritius
Mexico
Micronesia, Federated States of
Moldova
Monaco
Mongolia
Montenegro
Morocco
Mozambique
Myanmar (Burma)
Namibia
Nauru
Nepal
Netherlands
New Zealand
Nicaragua
Niger
Nigeria
North Macedonia
Norway
Oman
Pakistan
Palau
Panama
Papua New Guinea
Paraguay
Peru
Philippines
Poland
Portugal
Qatar
Romania
Russia
Rwanda
Saint Kitts and Nevis
Saint Lucia
Saint Vincent and the Grenadines
Samoa
San Marino
Sao Tome and Principe
Saudi Arabia
Senegal
Serbia
Seychelles
Sierra Leone
Singapore
Slovakia
Slovenia
Solomon Islands
Somalia
South Africa
Spain
Sri Lanka
Sudan
Sudan, South
Suriname
Sweden
Switzerland
Syria
Taiwan
Tajikistan
Tanzania
Thailand
Togo
Tonga
Trinidad and Tobago
Tunisia
Turkey
Turkmenistan
Tuvalu
Uganda
Ukraine
United Arab Emirates
United Kingdom
United States
Uruguay
Uzbekistan
Vanuatu
Vatican City
Venezuela
Vietnam
Yemen
Zambia
Zimbabwe
File diff suppressed because it is too large Load Diff
@@ -117,7 +117,7 @@ plot_end = """
"""
VARIANTS = ['dfa_aot', 'dfa_jit', 'nfa']
VARIANTS = ['aot', 'jit', 'nfa']
def parse_args():
@@ -183,7 +183,7 @@ def index_of_algo(group, stem):
def time_format(time):
order = math.floor(math.log(time, 10))
if order > 0:
return '%.0lf'
return '%.1lf'
else:
return '%%.%dlf' % (-order + 1)
@@ -192,10 +192,10 @@ class Params:
def __init__(self, args):
self.barwidth = 0.08
if args.variant == 'dfa_aot':
self.override_params_dfa_aot()
elif args.variant == 'dfa_jit':
self.override_params_dfa_jit()
if args.variant == 'aot':
self.override_params_aot()
elif args.variant == 'jit':
self.override_params_jit()
elif args.variant == 'nfa':
self.override_params_nfa()
@@ -210,7 +210,7 @@ class Params:
if args.relative_to: # override only if set
self.relative_to = args.relative_to
def override_params_dfa_aot(self):
def override_params_aot(self):
self.plotwidth = 1.5
self.xshift = 2 * self.plotwidth
self.header = """
@@ -225,7 +225,7 @@ class Params:
self.global_styles = ""
self.local_styles = plot_labels_and_title % 'left'
def override_params_dfa_jit(self):
def override_params_jit(self):
self.plotwidth = 2.7
self.xshift = self.plotwidth
self.header = """
@@ -322,7 +322,7 @@ def group_benchmarks(benchmarks, params):
avgtime /= nbench
avgsize /= nbench
factor = 10 if params.relative_to != None else 3
factor = 10 if params.relative_to != None else 5
maxtime = min(maxtime, factor * avgtime)
maxsize = min(maxsize, factor * avgsize)
+196
View File
@@ -0,0 +1,196 @@
find_package(PkgConfig REQUIRED)
pkg_check_modules(GBENCHMARK REQUIRED benchmark)
set(BENCHMARKS
"lex_00__numbers1"
"lex_01__numbers2"
"lex_02__words1"
"lex_03__words2"
"lex_04__words3"
"submatch_00__http_rfc7230"
"submatch_01__http_simple"
"submatch_02__uri_rfc3986"
"submatch_03__uri_simple"
"submatch_04__apache_log"
"submatch_05__datetime"
"submatch_06__email"
"submatch_07__ipv4"
"submatch_10__alt1_2"
"submatch_11__alt1_4"
"submatch_12__alt1_8"
"submatch_13__alt2_2"
"submatch_14__alt2_4"
"submatch_15__alt2_8"
"submatch_16__alt4_2"
"submatch_17__alt4_4"
"submatch_18__alt4_8"
"submatch_20__cat2_0"
"submatch_21__cat2_4"
"submatch_22__cat2_8"
"submatch_23__cat4_0"
"submatch_24__cat4_2"
"submatch_25__cat4_4"
"submatch_26__cat8_0"
"submatch_27__cat8_1"
"submatch_28__cat8_2"
"submatch_30__rep_cat_5_3_2"
"submatch_31__rep_cat_13_11_7"
"submatch_32__rep_cat_23_19_17"
"submatch_33__rep_alt_5_3_2"
"submatch_34__rep_alt_13_11_7"
"submatch_35__rep_alt_23_19_17"
"submatch_36__rep_5_rep_3_rep_2"
"submatch_37__rep_13_rep_11_rep_7"
"submatch_38__rep_23_rep_19_rep_17"
)
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(ENG_DIR "${CMAKE_CURRENT_BINARY_DIR}/engines")
set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen")
set(PREGEN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pregen")
set(GEN "")
# ragel
file(MAKE_DIRECTORY "${ENG_DIR}/ragel/")
file(MAKE_DIRECTORY "${GEN_DIR}/ragel/")
set(RAGEL "${ENG_DIR}/ragel/ragel7")
add_custom_command(
OUTPUT "${RAGEL}"
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/../_engines/ragel/getragel7.sh"
WORKING_DIRECTORY "${ENG_DIR}/ragel/"
)
foreach(bench ${BENCHMARKS})
set(src_file "${SRC_DIR}/ragel/${bench}.rl")
set(gen_file "${GEN_DIR}/ragel/${bench}.cc")
set(pregen_file "${PREGEN_DIR}/ragel/${bench}.cc")
# optionally regenerate ragel benchmarks if RE2C_REGEN_BENCHMARKS is set
if(RE2C_REGEN_BENCHMARKS)
file(RELATIVE_PATH rel_src_file "${CMAKE_CURRENT_BINARY_DIR}" "${src_file}")
file(RELATIVE_PATH rel_gen_file "${CMAKE_CURRENT_BINARY_DIR}" "${gen_file}")
add_custom_command(
OUTPUT "${gen_file}"
COMMAND "${RAGEL}" "-G2" "${rel_src_file}" -o "${rel_gen_file}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${gen_file}" "${pregen_file}"
DEPENDS "${src_file}" "${RAGEL}"
)
else()
add_custom_command(
OUTPUT "${gen_file}"
COMMAND "${CMAKE_COMMAND}" -E copy "${pregen_file}" "${gen_file}"
DEPENDS "${pregen_file}"
)
endif()
list(APPEND GEN "${gen_file}")
endforeach()
# re2c
file(MAKE_DIRECTORY "${GEN_DIR}/re2c/")
set(RE2C "${CMAKE_BINARY_DIR}/re2c")
set(RE2C_FLAGS "--reusable" "--tags" "--no-generation-date" "--no-version" "-i")
# always regenerate re2c benchmarks
foreach(bench ${BENCHMARKS})
set(src_file "${SRC_DIR}/re2c/${bench}.re")
set(gen_file "${GEN_DIR}/re2c/${bench}.cc")
set(pregen_file "${PREGEN_DIR}/re2c/${bench}.cc")
file(RELATIVE_PATH rel_src_file "${CMAKE_CURRENT_BINARY_DIR}" "${src_file}")
file(RELATIVE_PATH rel_gen_file "${CMAKE_CURRENT_BINARY_DIR}" "${gen_file}")
add_custom_command(
OUTPUT "${gen_file}"
COMMAND "${RE2C}" ${RE2C_FLAGS} "${rel_src_file}" -o "${rel_gen_file}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${gen_file}" "${pregen_file}"
DEPENDS "${src_file}" "${SRC_DIR}/re2c/base.re" "${RE2C}"
)
list(APPEND GEN "${gen_file}")
endforeach()
# binaries
if("${GBENCHMARK_INCLUDE_DIR}" STREQUAL "")
set(GBENCHMARK_INCLUDES "${GBENCHMARK_CFLAGS}")
else()
set(GBENCHMARK_INCLUDES "-I${GBENCHMARK_INCLUDE_DIR}")
endif()
set(RE2C_CXX_FLAGS "-O3" "-g" "-I" "${SRC_DIR}" "-Wall" "-Wno-unused-const-variable"
"${GBENCHMARK_INCLUDES}" "-std=c++11") # C++11 is needed for some google-benchmark features
list(APPEND COMPILERS "g++" "clang++")
list(APPEND COMPNAMES "gcc" "clang")
foreach(compiler IN ZIP_LISTS COMPILERS COMPNAMES)
set(objects "")
set(flags ${RE2C_CXX_FLAGS} "-DCXX=\\\"${compiler_1}\\\"")
foreach(gen_file ${GEN})
string(REGEX REPLACE
"^${GEN_DIR}(.+)\.cc$" "${GEN_DIR}\\1-${compiler_1}.o" obj_file "${gen_file}")
add_custom_command(
OUTPUT "${obj_file}"
COMMAND "${compiler_0}" ${flags} -c "${gen_file}" -o "${obj_file}"
DEPENDS "${gen_file}" "${SRC_DIR}/common.h"
)
list(APPEND objects "${obj_file}")
endforeach()
# don't use add_executable, as we need to mnually select the toolchain.
set(inputs ${objects} "${SRC_DIR}/bench.cc")
set(output "bench-${compiler_1}")
add_custom_command(
OUTPUT "${output}"
COMMAND "${compiler_0}" ${flags} ${inputs} "-o" "${output}" ${GBENCHMARK_LINK_LIBRARIES}
DEPENDS ${inputs}
)
if(compiler_1 STREQUAL "gcc") # build test only with GCC
set(test_inputs ${objects} "${SRC_DIR}/test.cc")
add_custom_command(
OUTPUT "test"
COMMAND "${compiler_0}" ${flags} ${test_inputs} "-o" "test" ${GBENCHMARK_LINK_LIBRARIES}
DEPENDS ${test_inputs}
)
endif()
endforeach()
# helper function to transform list
function(regex_replace_list regexp replace var)
set(result "")
foreach(arg ${ARGN})
string(REGEX REPLACE "${regexp}" "${replace}" x "${arg}")
list(APPEND result "${x}")
endforeach()
set(${var} "${result}" PARENT_SCOPE)
endfunction()
# input data
set(DAT)
# Some benchmarks share the same data, like submatch_03__uri_simple and submatch_02__uri_rfc3986.
regex_replace_list("^[a-z]+_[0-9]+__([^_]+).*" "\\1" INPUTS ${BENCHMARKS})
list(REMOVE_DUPLICATES INPUTS)
foreach(input ${INPUTS})
set(src_dir "${CMAKE_CURRENT_SOURCE_DIR}/../_data/${input}")
set(dst_dir "${CMAKE_CURRENT_BINARY_DIR}/data/${input}")
file(GLOB script "${CMAKE_CURRENT_SOURCE_DIR}/../_data/gen.py")
add_custom_command(
OUTPUT "${dst_dir}/small"
COMMAND "${CMAKE_COMMAND}" -E copy "${src_dir}/small" "${dst_dir}/small"
DEPENDS "${src_dir}/small"
)
add_custom_command(
OUTPUT "${dst_dir}/big"
COMMAND "${script}"
DEPENDS "${script}" "${dst_dir}/small"
WORKING_DIRECTORY "${dst_dir}"
)
list(APPEND DAT "${dst_dir}/small" "${dst_dir}/big")
endforeach()
add_custom_target(bench_submatch_aot ALL DEPENDS bench-gcc bench-clang test ${DAT})
# benchmark scripts
set(srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
set(builddir ".")
configure_file(run.py.in run.py @ONLY)
# override default clean command to keep engines
set_directory_properties(PROPERTY
CLEAN_NO_CUSTOM On
ADDITIONAL_CLEAN_FILES "${GEN};${OBJ};${BIN};${DAT}"
)
+146
View File
@@ -0,0 +1,146 @@
SRC_DIR = $(srcdir)/src
ENG_DIR = engines
GEN_DIR = gen
PREGEN_DIR = $(srcdir)/pregen
DAT_DIR = data
RAGEL = $(ENG_DIR)/ragel/ragel7
RE2C = $(top_builddir)/re2c
RE2C_FLAGS = --reusable --tags --no-generation-date --no-version -i
CXXFLAGS = $(AM_CXXFLAGS) -O3 -g -I $(SRC_DIR) -Wall -Wno-unused-const-variable
LDFLAGS = -lbenchmark -lpthread
BENCHMARKS = \
lex_00__numbers1 \
lex_01__numbers2 \
lex_02__words1 \
lex_03__words2 \
lex_04__words3 \
\
submatch_00__http_rfc7230 \
submatch_01__http_simple \
submatch_02__uri_rfc3986 \
submatch_03__uri_simple \
submatch_04__apache_log \
submatch_05__datetime \
submatch_06__email \
submatch_07__ipv4 \
\
submatch_10__alt1_2 \
submatch_11__alt1_4 \
submatch_12__alt1_8 \
submatch_13__alt2_2 \
submatch_14__alt2_4 \
submatch_15__alt2_8 \
submatch_16__alt4_2 \
submatch_17__alt4_4 \
submatch_18__alt4_8 \
\
submatch_20__cat2_0 \
submatch_21__cat2_4 \
submatch_22__cat2_8 \
submatch_23__cat4_0 \
submatch_24__cat4_2 \
submatch_25__cat4_4 \
submatch_26__cat8_0 \
submatch_27__cat8_1 \
submatch_28__cat8_2 \
\
submatch_30__rep_cat_5_3_2 \
submatch_31__rep_cat_13_11_7 \
submatch_32__rep_cat_23_19_17 \
submatch_33__rep_alt_5_3_2 \
submatch_34__rep_alt_13_11_7 \
submatch_35__rep_alt_23_19_17 \
submatch_36__rep_5_rep_3_rep_2 \
submatch_37__rep_13_rep_11_rep_7 \
submatch_38__rep_23_rep_19_rep_17
COMMON_SRC = $(SRC_DIR)/common.h
COMMON_RAGEL = \
$(COMMON_SRC) \
$(SRC_DIR)/ragel/base.h
COMMON_RE2C = \
$(COMMON_SRC) \
$(SRC_DIR)/re2c/base.re \
$(SRC_DIR)/re2c/base.h
GEN_RAGEL = $(patsubst %, $(GEN_DIR)/ragel/%.cc, $(BENCHMARKS))
GEN_RE2C = $(patsubst %, $(GEN_DIR)/re2c/%.cc, $(BENCHMARKS))
GEN = $(GEN_RAGEL) $(GEN_RE2C)
SRC = $(GEN_RAGEL) $(GEN_RE2C)
OBJ_GCC = $(patsubst %.cc, %-gcc.o, $(SRC))
OBJ_CLANG = $(patsubst %.cc, %-clang.o, $(SRC))
OBJ_TEST = $(patsubst %.cc, %-test.o, $(SRC))
OBJ = $(OBJ_GCC) $(OBJ_CLANG) $(OBJ_TEST)
# Some benchmarks share the same data, like 03__uri_simple and 02__uri_rfc3986.
DAT = $(patsubst %, $(DAT_DIR)/%/big, \
$(sort $(foreach bench, $(BENCHMARKS), \
$(word 3, $(subst _, , $(bench))))))
$(DAT): $(DAT_DIR)/%/big: $(srcdir)/../_data/%/small
$(AM_V_at)mkdir -p $(@D) && cp $< $(@D)
$(AM_V_GEN)( cd $(@D) && ../../$(srcdir)/../_data/gen.py )
all-local: bench-gcc bench-clang test $(DAT)
# compile
$(OBJ_GCC): %-gcc.o: %.cc
$(AM_V_at)mkdir -p $(@D)
$(AM_V_GEN)g++ $(CXXFLAGS) -c -o $@ $<
$(OBJ_CLANG): %-clang.o: %.cc
$(AM_V_at)mkdir -p $(@D)
$(AM_V_GEN)clang++ $(CXXFLAGS) -c -o $@ $<
$(OBJ_TEST): %-test.o: %.cc
$(AM_V_at)mkdir -p $(@D)
$(AM_V_GEN)g++ $(CXXFLAGS) -DRUN_IN_TEST_MODE -c -o $@ $<
bench-gcc: src/bench.cc $(OBJ_GCC)
$(AM_V_GEN)g++ -DCXX=\"gcc\" -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
bench-clang: src/bench.cc $(OBJ_CLANG)
$(AM_V_GEN)clang++ -DCXX=\"clang\" -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
test: src/test.cc $(OBJ_TEST)
$(AM_V_GEN)g++ -DRUN_IN_TEST_MODE -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
# always regenerate re2c benchmarks (except for deprecated algorithms)
$(GEN_RE2C): $(GEN_DIR)/%.cc: $(SRC_DIR)/%.re $(COMMON_RE2C) $(RE2C)
$(AM_V_at)mkdir -p $(@D)
$(AM_V_GEN)$(RE2C) $(RE2C_FLAGS) $< -o $@
$(AM_V_at)if ! cmp -s $@ $(PREGEN_DIR)/re2c/$(@F) ; then cp -f $@ $(PREGEN_DIR)/re2c/$(@F) ; fi
# optionally regenerate other benchmarks
if REGEN_BENCHMARKS
$(GEN_RAGEL): $(GEN_DIR)/%.cc: $(SRC_DIR)/%.rl $(COMMON_RAGEL) $(RAGEL)
$(AM_V_at)mkdir -p $(@D)
$(AM_V_GEN)$(RAGEL) -G2 $< -o $@
$(AM_V_at)if ! cmp -s $@ $(PREGEN_DIR)/ragel/$(@F) ; then cp -f $@ $(PREGEN_DIR)/ragel/$(@F) ; fi
else
$(GEN_RAGEL) $(GEN_DIR)/%: $(PREGEN_DIR)/%
$(AM_V_at)mkdir -p $(@D)
$(AM_V_GEN)cp -f $< $@
endif
# engines
$(RAGEL):
$(AM_V_at)mkdir -p $(@D) && cp $(srcdir)/../_engines/ragel/getragel7.sh $(@D)
$(AM_V_GEN)( cd $(@D) && ./getragel7.sh )
# clean
clean-local:
rm -f $(GEN) $(OBJ) $(DAT) bench-gcc bench-clang test
@@ -1,6 +1,6 @@
#include <string.h>
#include "benchmarks/common/common.h"
#include "benchmarks/c/common/common.h"
#include "lib/regex.h"
#ifdef HAVE_RE2_RE2_H
+21
View File
@@ -0,0 +1,21 @@
add_executable(bench_submatch_jit
"bench.cc"
"${CMAKE_SOURCE_DIR}/benchmarks/c/common/common.cc"
)
target_link_libraries(bench_submatch_jit libre2c)
find_package(benchmark REQUIRED)
target_link_libraries(bench_submatch_jit benchmark::benchmark)
# if present, re2 is used for benchmarks
find_path(RE2_INCLUDE_DIRECTORY "re2/re2.h")
find_library(RE2_LIBRARY re2)
if(RE2_INCLUDE_DIRECTORY AND RE2_LIBRARY)
set_target_properties(bench_submatch_jit PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)
target_compile_definitions(bench_submatch_jit PRIVATE "HAVE_RE2_RE2_H=1")
target_include_directories(bench_submatch_jit PRIVATE "${RE2_INCLUDE_DIRECTORY}")
target_link_libraries(bench_submatch_jit "${RE2_LIBRARY}")
endif()
+17
View File
@@ -0,0 +1,17 @@
bench_submatch_jit_CXXFLAGS = $(AM_CXXFLAGS) -O3 -I $(top_srcdir)
bench_submatch_jit_LDFLAGS = $(LDFLAGS_RE2) -lbenchmark -lpthread
bench_submatch_jit_LDADD = $(top_builddir)/libre2c.la
noinst_PROGRAMS = bench_submatch_jit
bench_submatch_jit_SOURCES = bench.cc \
$(top_srcdir)/benchmarks/c/common/common.cc \
$(top_srcdir)/benchmarks/c/common/common.h \
$(top_srcdir)/benchmarks/c/common/strings_atom.h \
$(top_srcdir)/benchmarks/c/common/strings_date.h \
$(top_srcdir)/benchmarks/c/common/strings_http.h \
$(top_srcdir)/benchmarks/c/common/strings_ipv4.h \
$(top_srcdir)/benchmarks/c/common/strings_ipv6.h \
$(top_srcdir)/benchmarks/c/common/strings_uri.h
all-local: bench_submatch_jit
+66
View File
@@ -0,0 +1,66 @@
#include <benchmark/benchmark.h>
#include <string.h>
#include "benchmarks/c/common/common.h"
#include "benchmarks/c/common/strings_atom.h"
#include "benchmarks/c/common/strings_date.h"
#include "benchmarks/c/common/strings_http.h"
#include "benchmarks/c/common/strings_ipv4.h"
#include "benchmarks/c/common/strings_ipv6.h"
#include "benchmarks/c/common/strings_uri.h"
#include "lib/regex.h"
int main(int argc, char** argv)
{
static const size_t MAX_TITLE = 1024;
char title[MAX_TITLE];
static const size_t AAA_LEN = 1 << 14;
char *aaa = new char[AAA_LEN + 1];
memset(aaa, 'a', AAA_LEN);
const char *aaa_strings[] = {aaa, NULL};
const std::vector<bench_t> benches {
{"http-rfc7230", MESSAGE_HEAD, http_strings},
{"http-simple", MESSAGE_HEAD2, http_strings},
{"uri-rfc3986", URI, uri_strings},
{"uri-simple", URI2, uri_strings},
{"ipv6", IPV6, ipv6_strings},
{"ipv4", IPV4, ipv4_strings},
{"date", DATE, date_strings},
{"package", PACKAGE_ATOM, atom_strings},
{NULL, "(a)*a{10}", aaa_strings},
{NULL, "(a)*a{100}", aaa_strings},
{NULL, "(a)*a{1000}", aaa_strings},
};
const std::vector<alg_t> algs {
{"last-offset", ENGINE_RE2C, 0},
{"multipass-last-offset", ENGINE_RE2C, REG_MULTIPASS},
{"all-offsets", ENGINE_RE2C, REG_SUBHIST},
{"multipass-all-offsets", ENGINE_RE2C, REG_SUBHIST | REG_MULTIPASS},
};
benchmark::Initialize(&argc, argv);
for (const bench_t &bench : benches) {
for (const alg_t &alg : algs) {
const char *name = bench.name ? bench.name : bench.regexp;
snprintf(title, MAX_TITLE, "%s-regcomp_%s", name, alg.name);
benchmark::RegisterBenchmark(title, bench_regcomp_t(), alg, bench)
->Unit(benchmark::kMicrosecond);
}
for (const alg_t &alg : algs) {
const char *name = bench.name ? bench.name : bench.regexp;
snprintf(title, MAX_TITLE, "%s-regexec_%s", name, alg.name);
benchmark::RegisterBenchmark(title, bench_regexec_t(), alg, bench)
->Unit(benchmark::kMicrosecond);
}
}
benchmark::RunSpecifiedBenchmarks();
delete[] aaa;
}
+21
View File
@@ -0,0 +1,21 @@
add_executable(bench_submatch_nfa
"bench.cc"
"${CMAKE_SOURCE_DIR}/benchmarks/c/common/common.cc"
)
target_link_libraries(bench_submatch_nfa libre2c)
find_package(benchmark REQUIRED)
target_link_libraries(bench_submatch_nfa benchmark::benchmark)
# if present, re2 is used for benchmarks
find_path(RE2_INCLUDE_DIRECTORY "re2/re2.h")
find_library(RE2_LIBRARY re2)
if(RE2_INCLUDE_DIRECTORY AND RE2_LIBRARY)
set_target_properties(bench_submatch_nfa PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON)
target_compile_definitions(bench_submatch_nfa PRIVATE "HAVE_RE2_RE2_H=1")
target_include_directories(bench_submatch_nfa PRIVATE "${RE2_INCLUDE_DIRECTORY}")
target_link_libraries(bench_submatch_nfa "${RE2_LIBRARY}")
endif()
+17
View File
@@ -0,0 +1,17 @@
bench_submatch_nfa_CXXFLAGS = $(AM_CXXFLAGS) -O3 -I $(top_srcdir)
bench_submatch_nfa_LDFLAGS = $(LDFLAGS_RE2) -lbenchmark -lpthread
bench_submatch_nfa_LDADD = $(top_builddir)/libre2c.la
noinst_PROGRAMS = bench_submatch_nfa
bench_submatch_nfa_SOURCES = bench.cc \
$(top_srcdir)/benchmarks/c/common/common.cc \
$(top_srcdir)/benchmarks/c/common/common.h \
$(top_srcdir)/benchmarks/c/common/strings_atom.h \
$(top_srcdir)/benchmarks/c/common/strings_date.h \
$(top_srcdir)/benchmarks/c/common/strings_http.h \
$(top_srcdir)/benchmarks/c/common/strings_ipv4.h \
$(top_srcdir)/benchmarks/c/common/strings_ipv6.h \
$(top_srcdir)/benchmarks/c/common/strings_uri.h
all-local: bench_submatch_nfa
+103
View File
@@ -0,0 +1,103 @@
#include <benchmark/benchmark.h>
#include <string.h>
#include "benchmarks/c/common/common.h"
#include "benchmarks/c/common/strings_atom.h"
#include "benchmarks/c/common/strings_date.h"
#include "benchmarks/c/common/strings_http.h"
#include "benchmarks/c/common/strings_ipv4.h"
#include "benchmarks/c/common/strings_ipv6.h"
#include "benchmarks/c/common/strings_uri.h"
#include "lib/regex.h"
int main(int argc, char** argv)
{
static const size_t MAX_TITLE = 1024;
char title[MAX_TITLE];
static const size_t AAA_LEN = 1 << 13;
char *aaa = new char[AAA_LEN + 1];
memset(aaa, 'a', AAA_LEN);
const char *aaa_strings[] = {aaa, NULL};
const std::vector<bench_t> benches = {
{"HTTP-RFC7230", MESSAGE_HEAD, http_strings},
{"HTTP-simple", MESSAGE_HEAD2, http_strings},
{"URI-RFC3986", URI, uri_strings},
{"URI-simple", URI2, uri_strings},
{"IPv6", IPV6, ipv6_strings},
{"IPv6-simple", IPV62, ipv6_strings},
{"IPv4", IPV4, ipv4_strings},
{"IPv4-simple", IPV42, ipv4_strings},
{"date", DATE, date_strings},
{"date-simple", DATE2, date_strings},
{"package", PACKAGE_ATOM, atom_strings},
{"package-simple", PACKAGE_ATOM2, atom_strings},
{NULL, "(a{2}|a{3}|a{5})*", aaa_strings},
{NULL, "(a{7}|a{13}|a{19})*", aaa_strings},
{NULL, "(a{29}|a{41}|a{53})*", aaa_strings},
{NULL, "(a{67}|a{83}|a{103})*", aaa_strings},
{NULL, "(a{127}|a{151}|a{179})*", aaa_strings},
{NULL, "(a{199}|a{239}|a{271})*", aaa_strings},
{NULL, "(((a){2})|((a){3})|((a){5}))*", aaa_strings},
{NULL, "(((a){7})|((a){13})|((a){19}))*", aaa_strings},
{NULL, "(((a){29})|((a){41})|((a){53}))*", aaa_strings},
{NULL, "(((a){67})|((a){83})|((a){103}))*", aaa_strings},
{NULL, "(((a){127})|((a){151})|((a){179}))*", aaa_strings},
{NULL, "(((a){199})|((a){239})|((a){271}))*", aaa_strings},
{NULL, "(a{0,16})*", aaa_strings},
{NULL, "((a){0,16})*", aaa_strings},
{NULL, "(a{0,64})*", aaa_strings},
{NULL, "((a){0,64})*", aaa_strings},
{NULL, "(a{0,256})*", aaa_strings},
{NULL, "((a){0,256})*", aaa_strings},
// Pathological case for constant-memory POSIX algorithms that use naive
// (worst-case cubic in the size of TNFA) algorithm for precedence matrix
// computation. Cubic behaviour is caused by quadratic-time computation
// of precedence matrix on each step (the number of core items in closure
// approaches TNFA size), multiplied by the length of compared histores
// (which also approaches TNFA size). Trie-based algorithms are not
// affected, but they consume memory proportional to the length of input,
// and so are also not practical.
{NULL, "((a?){0,16})*", aaa_strings},
{NULL, "((a*){0,16})*", aaa_strings},
{NULL, "((a?){0,64})*", aaa_strings},
{NULL, "((a*){0,64})*", aaa_strings},
{NULL, "((a?){0,256})*", aaa_strings},
{NULL, "((a*){0,256})*", aaa_strings},
};
const std::vector<alg_t> algs = {
{"LG", ENGINE_RE2C, REG_NFA | REG_LEFTMOST},
{"lazy-LG", ENGINE_RE2C, REG_NFA | REG_LEFTMOST | REG_TRIE},
{"OS", ENGINE_RE2C, REG_NFA},
{"simple-OS", ENGINE_RE2C, REG_NFA | REG_SLOWPREC},
{"lazy-OS", ENGINE_RE2C, REG_NFA | REG_TRIE},
#ifdef HAVE_RE2_RE2_H
{"re2-LG", ENGINE_RE2, 0},
#endif
};
benchmark::Initialize(&argc, argv);
for (const bench_t &bench : benches) {
for (const alg_t &alg : algs) {
const char *name = bench.name ? bench.name : bench.regexp;
snprintf(title, MAX_TITLE, "%s_%s", name, alg.name);
benchmark::RegisterBenchmark(title, bench_regexec_t(), alg, bench)
->Unit(benchmark::kMicrosecond);
}
}
benchmark::RunSpecifiedBenchmarks();
delete[] aaa;
}
@@ -0,0 +1,120 @@
#line 1 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
#include "ragel/base.h"
namespace ragel_lex_00__numbers1 {
const char *delim = "\n";
#line 13 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
#line 11 "gen/ragel/lex_00__numbers1.cc"
static const int lex_numbers_start = 2;
static const int lex_numbers_first_final = 2;
static const int lex_numbers_error = 0;
static const int lex_numbers_en_main = 2;
#line 15 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *ts = in->ts;
char *te = in->te;
char *pe = in->pe;
int act = in->act;
int cs;
#line 28 "gen/ragel/lex_00__numbers1.cc"
{
cs = (int)lex_numbers_start;
ts = 0;
te = 0;
}
#line 25 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
#line 35 "gen/ragel/lex_00__numbers1.cc"
{
switch ( cs ) {
case 2:
goto st_case_2;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
}
_ctr2:
{
#line 12 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
{te = p+1;{
#line 12 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
OUTS(ts, te); }
}}
#line 52 "gen/ragel/lex_00__numbers1.cc"
goto _st2;
_st2:
{
#line 1 "NONE"
{ts = 0;}}
#line 59 "gen/ragel/lex_00__numbers1.cc"
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
{
#line 1 "NONE"
{ts = p;}}
#line 68 "gen/ragel/lex_00__numbers1.cc"
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st1;
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
if ( ( (*( p))) == 10 ) {
goto _ctr2;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st1;
}
goto _st0;
_out2: cs = 2; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out: {}
}
#line 26 "../../../benchmarks/c/src/ragel/lex_00__numbers1.rl"
in->p = p;
in->ts = ts;
in->te = te;
in->pe = pe;
in->act = act;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_lex_00__numbers1
@@ -0,0 +1,410 @@
#line 1 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
#include "ragel/base.h"
namespace ragel_lex_01__numbers2 {
const char *delim = "\n";
#line 24 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
#line 11 "gen/ragel/lex_01__numbers2.cc"
static const int lex_numbers_start = 14;
static const int lex_numbers_first_final = 14;
static const int lex_numbers_error = 0;
static const int lex_numbers_en_main = 14;
#line 26 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *ts = in->ts;
char *te = in->te;
char *pe = in->pe;
int act = in->act;
int cs;
#line 28 "gen/ragel/lex_01__numbers2.cc"
{
cs = (int)lex_numbers_start;
ts = 0;
te = 0;
}
#line 36 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
#line 35 "gen/ragel/lex_01__numbers2.cc"
{
switch ( cs ) {
case 14:
goto st_case_14;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
case 9:
goto st_case_9;
case 10:
goto st_case_10;
case 11:
goto st_case_11;
case 12:
goto st_case_12;
case 13:
goto st_case_13;
}
_ctr3:
{
#line 22 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
{te = p+1;{
#line 22 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
OUTX(ts, te, 1); }
}}
#line 76 "gen/ragel/lex_01__numbers2.cc"
goto _st14;
_ctr8:
{
#line 19 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
{te = p+1;{
#line 19 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
OUTX(ts, te, 8); }
}}
#line 86 "gen/ragel/lex_01__numbers2.cc"
goto _st14;
_ctr14:
{
#line 18 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
{te = p+1;{
#line 18 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
OUTX(ts, te, 2); }
}}
#line 96 "gen/ragel/lex_01__numbers2.cc"
goto _st14;
_ctr16:
{
#line 21 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
{te = p+1;{
#line 21 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
OUTX(ts, te, 16); }
}}
#line 106 "gen/ragel/lex_01__numbers2.cc"
goto _st14;
_ctr18:
{
#line 20 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
{te = p+1;{
#line 20 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
OUTX(ts, te, 10); }
}}
#line 116 "gen/ragel/lex_01__numbers2.cc"
goto _st14;
_st14:
{
#line 1 "NONE"
{ts = 0;}}
#line 123 "gen/ragel/lex_01__numbers2.cc"
p+= 1;
st_case_14:
if ( p == pe )
goto _out14;
{
#line 1 "NONE"
{ts = p;}}
#line 132 "gen/ragel/lex_01__numbers2.cc"
switch( ( (*( p))) ) {
case 46: {
goto _st1;
}
case 48: {
goto _st6;
}
}
if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st13;
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st2;
}
goto _st0;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr3;
}
case 69: {
goto _st3;
}
case 101: {
goto _st3;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st2;
}
goto _st0;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 43: {
goto _st4;
}
case 45: {
goto _st4;
}
}
if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st5;
}
goto _st0;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st5;
}
goto _st0;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
if ( ( (*( p))) == 10 ) {
goto _ctr3;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st5;
}
goto _st0;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
switch( ( (*( p))) ) {
case 10: {
goto _ctr8;
}
case 46: {
goto _st1;
}
case 66: {
goto _st9;
}
case 88: {
goto _st11;
}
case 98: {
goto _st9;
}
case 120: {
goto _st11;
}
}
if ( ( (*( p))) > 55 ) {
if ( ( (*( p))) <= 57 ) {
goto _st8;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st7;
}
goto _st0;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
switch( ( (*( p))) ) {
case 10: {
goto _ctr8;
}
case 46: {
goto _st1;
}
}
if ( ( (*( p))) > 55 ) {
if ( ( (*( p))) <= 57 ) {
goto _st8;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st7;
}
goto _st0;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
if ( ( (*( p))) == 46 ) {
goto _st1;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st8;
}
goto _st0;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 49 ) {
goto _st10;
}
goto _st0;
_st10:
p+= 1;
st_case_10:
if ( p == pe )
goto _out10;
if ( ( (*( p))) == 10 ) {
goto _ctr14;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 49 ) {
goto _st10;
}
goto _st0;
_st11:
p+= 1;
st_case_11:
if ( p == pe )
goto _out11;
if ( ( (*( p))) < 65 ) {
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st12;
}
} else if ( ( (*( p))) > 70 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) {
goto _st12;
}
} else {
goto _st12;
}
goto _st0;
_st12:
p+= 1;
st_case_12:
if ( p == pe )
goto _out12;
if ( ( (*( p))) == 10 ) {
goto _ctr16;
}
if ( ( (*( p))) < 65 ) {
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st12;
}
} else if ( ( (*( p))) > 70 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) {
goto _st12;
}
} else {
goto _st12;
}
goto _st0;
_st13:
p+= 1;
st_case_13:
if ( p == pe )
goto _out13;
switch( ( (*( p))) ) {
case 10: {
goto _ctr18;
}
case 46: {
goto _st1;
}
case 69: {
goto _st3;
}
case 101: {
goto _st3;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st13;
}
goto _st0;
_out14: cs = 14; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out9: cs = 9; goto _out;
_out10: cs = 10; goto _out;
_out11: cs = 11; goto _out;
_out12: cs = 12; goto _out;
_out13: cs = 13; goto _out;
_out: {}
}
#line 37 "../../../benchmarks/c/src/ragel/lex_01__numbers2.rl"
in->p = p;
in->ts = ts;
in->te = te;
in->pe = pe;
in->act = act;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_lex_01__numbers2
+369
View File
@@ -0,0 +1,369 @@
#line 1 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
#include "ragel/base.h"
namespace ragel_lex_02__words1 {
const char *delim = "\n";
#line 20 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
#line 11 "gen/ragel/lex_02__words1.cc"
static const int lex_words_start = 21;
static const int lex_words_first_final = 21;
static const int lex_words_error = 0;
static const int lex_words_en_main = 21;
#line 22 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *ts = in->ts;
char *te = in->te;
char *pe = in->pe;
int act = in->act;
int cs;
#line 28 "gen/ragel/lex_02__words1.cc"
{
cs = (int)lex_words_start;
ts = 0;
te = 0;
}
#line 32 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
#line 35 "gen/ragel/lex_02__words1.cc"
{
switch ( cs ) {
case 21:
goto st_case_21;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
case 9:
goto st_case_9;
case 10:
goto st_case_10;
case 11:
goto st_case_11;
case 12:
goto st_case_12;
case 13:
goto st_case_13;
case 14:
goto st_case_14;
case 15:
goto st_case_15;
case 16:
goto st_case_16;
case 17:
goto st_case_17;
case 18:
goto st_case_18;
case 19:
goto st_case_19;
case 20:
goto st_case_20;
}
_ctr7:
{
#line 19 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
{te = p+1;{
#line 19 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
OUTS(ts, te); }
}}
#line 90 "gen/ragel/lex_02__words1.cc"
goto _st21;
_st21:
{
#line 1 "NONE"
{ts = 0;}}
#line 97 "gen/ragel/lex_02__words1.cc"
p+= 1;
st_case_21:
if ( p == pe )
goto _out21;
{
#line 1 "NONE"
{ts = p;}}
#line 106 "gen/ragel/lex_02__words1.cc"
switch( ( (*( p))) ) {
case 70: {
goto _st1;
}
case 77: {
goto _st7;
}
case 83: {
goto _st9;
}
case 84: {
goto _st13;
}
case 87: {
goto _st18;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
if ( ( (*( p))) == 114 ) {
goto _st2;
}
goto _st0;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
if ( ( (*( p))) == 105 ) {
goto _st3;
}
goto _st0;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
if ( ( (*( p))) == 100 ) {
goto _st4;
}
goto _st0;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
if ( ( (*( p))) == 97 ) {
goto _st5;
}
goto _st0;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
if ( ( (*( p))) == 121 ) {
goto _st6;
}
goto _st0;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
if ( ( (*( p))) == 10 ) {
goto _ctr7;
}
goto _st0;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
if ( ( (*( p))) == 111 ) {
goto _st8;
}
goto _st0;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
if ( ( (*( p))) == 110 ) {
goto _st3;
}
goto _st0;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
switch( ( (*( p))) ) {
case 97: {
goto _st10;
}
case 117: {
goto _st8;
}
}
goto _st0;
_st10:
p+= 1;
st_case_10:
if ( p == pe )
goto _out10;
if ( ( (*( p))) == 116 ) {
goto _st11;
}
goto _st0;
_st11:
p+= 1;
st_case_11:
if ( p == pe )
goto _out11;
if ( ( (*( p))) == 117 ) {
goto _st12;
}
goto _st0;
_st12:
p+= 1;
st_case_12:
if ( p == pe )
goto _out12;
if ( ( (*( p))) == 114 ) {
goto _st3;
}
goto _st0;
_st13:
p+= 1;
st_case_13:
if ( p == pe )
goto _out13;
switch( ( (*( p))) ) {
case 104: {
goto _st14;
}
case 117: {
goto _st17;
}
}
goto _st0;
_st14:
p+= 1;
st_case_14:
if ( p == pe )
goto _out14;
if ( ( (*( p))) == 117 ) {
goto _st15;
}
goto _st0;
_st15:
p+= 1;
st_case_15:
if ( p == pe )
goto _out15;
if ( ( (*( p))) == 114 ) {
goto _st16;
}
goto _st0;
_st16:
p+= 1;
st_case_16:
if ( p == pe )
goto _out16;
if ( ( (*( p))) == 115 ) {
goto _st3;
}
goto _st0;
_st17:
p+= 1;
st_case_17:
if ( p == pe )
goto _out17;
if ( ( (*( p))) == 101 ) {
goto _st16;
}
goto _st0;
_st18:
p+= 1;
st_case_18:
if ( p == pe )
goto _out18;
if ( ( (*( p))) == 101 ) {
goto _st19;
}
goto _st0;
_st19:
p+= 1;
st_case_19:
if ( p == pe )
goto _out19;
if ( ( (*( p))) == 100 ) {
goto _st20;
}
goto _st0;
_st20:
p+= 1;
st_case_20:
if ( p == pe )
goto _out20;
if ( ( (*( p))) == 110 ) {
goto _st17;
}
goto _st0;
_out21: cs = 21; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out9: cs = 9; goto _out;
_out10: cs = 10; goto _out;
_out11: cs = 11; goto _out;
_out12: cs = 12; goto _out;
_out13: cs = 13; goto _out;
_out14: cs = 14; goto _out;
_out15: cs = 15; goto _out;
_out16: cs = 16; goto _out;
_out17: cs = 17; goto _out;
_out18: cs = 18; goto _out;
_out19: cs = 19; goto _out;
_out20: cs = 20; goto _out;
_out: {}
}
#line 33 "../../../benchmarks/c/src/ragel/lex_02__words1.rl"
in->p = p;
in->ts = ts;
in->te = te;
in->pe = pe;
in->act = act;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_lex_02__words1
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,709 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
#include "ragel/base.h"
namespace ragel_submatch_04__apache_log {
const char *delim = "\n";
#line 44 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
#line 11 "gen/ragel/submatch_04__apache_log.cc"
static const int apache_log_start = 25;
static const int apache_log_first_final = 25;
static const int apache_log_error = 0;
static const int apache_log_en_main = 25;
#line 46 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*h1, *i1, *a1, *d1, *r1, *s1, *z1, *u1, *g1,
*h2, *i2, *a2, *d2, *r2, *s2, *z2, *u2, *g2;
int cs;
#line 28 "gen/ragel/submatch_04__apache_log.cc"
{
cs = (int)apache_log_start;
}
#line 56 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
#line 33 "gen/ragel/submatch_04__apache_log.cc"
{
switch ( cs ) {
case 25:
goto st_case_25;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
case 9:
goto st_case_9;
case 10:
goto st_case_10;
case 11:
goto st_case_11;
case 12:
goto st_case_12;
case 13:
goto st_case_13;
case 14:
goto st_case_14;
case 15:
goto st_case_15;
case 16:
goto st_case_16;
case 17:
goto st_case_17;
case 18:
goto st_case_18;
case 19:
goto st_case_19;
case 20:
goto st_case_20;
case 21:
goto st_case_21;
case 22:
goto st_case_22;
case 23:
goto st_case_23;
case 24:
goto st_case_24;
}
_ctr41:
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
g2 = p; }
#line 93 "gen/ragel/submatch_04__apache_log.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
OUT("host: ", h1, h2);
OUT("userid: ", i1, i2);
OUT("authuser: ", a1, a2);
OUT("date: ", d1, d2);
OUT("request: ", r1, r2);
OUT("status: ", s1, s2);
OUT("size: ", z1, z2);
OUT("url: ", u1, u2);
OUT("agent: ", g1, g2);
OUTC('\n');
}
#line 109 "gen/ragel/submatch_04__apache_log.cc"
goto _st25;
_st25:
p+= 1;
st_case_25:
if ( p == pe )
goto _out25;
if ( ( (*( p))) == 46 ) {
goto _ctr44;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr44;
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr44:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
h1 = p; }
#line 131 "gen/ragel/submatch_04__apache_log.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 9: {
goto _ctr2;
}
case 32: {
goto _ctr2;
}
case 46: {
goto _st1;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st1;
}
goto _st0;
_ctr2:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
h2 = p; }
#line 158 "gen/ragel/submatch_04__apache_log.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 9: {
goto _st2;
}
case 32: {
goto _st2;
}
case 45: {
goto _ctr4;
}
}
goto _st0;
_ctr4:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
i1 = p; }
#line 182 "gen/ragel/submatch_04__apache_log.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 9: {
goto _ctr6;
}
case 32: {
goto _ctr6;
}
}
goto _st0;
_ctr6:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
i2 = p; }
#line 203 "gen/ragel/submatch_04__apache_log.cc"
goto _st4;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 9: {
goto _st4;
}
case 32: {
goto _st4;
}
case 45: {
goto _ctr8;
}
}
goto _st0;
_ctr8:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
a1 = p; }
#line 227 "gen/ragel/submatch_04__apache_log.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 9: {
goto _ctr10;
}
case 32: {
goto _ctr10;
}
}
goto _st0;
_ctr10:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
a2 = p; }
#line 248 "gen/ragel/submatch_04__apache_log.cc"
goto _st6;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
switch( ( (*( p))) ) {
case 9: {
goto _st6;
}
case 32: {
goto _st6;
}
case 91: {
goto _ctr12;
}
}
goto _st0;
_ctr12:
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
d1 = p; }
#line 272 "gen/ragel/submatch_04__apache_log.cc"
goto _st7;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st0;
}
case 93: {
goto _st0;
}
}
goto _st8;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st0;
}
case 93: {
goto _st9;
}
}
goto _st8;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
switch( ( (*( p))) ) {
case 9: {
goto _ctr16;
}
case 32: {
goto _ctr16;
}
}
goto _st0;
_ctr16:
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
d2 = p; }
#line 327 "gen/ragel/submatch_04__apache_log.cc"
goto _st10;
_st10:
p+= 1;
st_case_10:
if ( p == pe )
goto _out10;
switch( ( (*( p))) ) {
case 9: {
goto _st10;
}
case 32: {
goto _st10;
}
case 34: {
goto _ctr18;
}
}
goto _st0;
_ctr18:
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
r1 = p; }
#line 351 "gen/ragel/submatch_04__apache_log.cc"
goto _st11;
_st11:
p+= 1;
st_case_11:
if ( p == pe )
goto _out11;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st0;
}
case 34: {
goto _st0;
}
}
goto _st12;
_st12:
p+= 1;
st_case_12:
if ( p == pe )
goto _out12;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st0;
}
case 34: {
goto _st13;
}
}
goto _st12;
_st13:
p+= 1;
st_case_13:
if ( p == pe )
goto _out13;
switch( ( (*( p))) ) {
case 9: {
goto _ctr22;
}
case 32: {
goto _ctr22;
}
}
goto _st0;
_ctr22:
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
r2 = p; }
#line 406 "gen/ragel/submatch_04__apache_log.cc"
goto _st14;
_st14:
p+= 1;
st_case_14:
if ( p == pe )
goto _out14;
switch( ( (*( p))) ) {
case 9: {
goto _st14;
}
case 32: {
goto _st14;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr24;
}
goto _st0;
_ctr24:
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
s1 = p; }
#line 430 "gen/ragel/submatch_04__apache_log.cc"
goto _st15;
_st15:
p+= 1;
st_case_15:
if ( p == pe )
goto _out15;
switch( ( (*( p))) ) {
case 9: {
goto _ctr26;
}
case 32: {
goto _ctr26;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st15;
}
goto _st0;
_ctr26:
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
s2 = p; }
#line 454 "gen/ragel/submatch_04__apache_log.cc"
goto _st16;
_st16:
p+= 1;
st_case_16:
if ( p == pe )
goto _out16;
switch( ( (*( p))) ) {
case 9: {
goto _st16;
}
case 32: {
goto _st16;
}
case 45: {
goto _ctr28;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr29;
}
goto _st0;
_ctr28:
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
z1 = p; }
#line 481 "gen/ragel/submatch_04__apache_log.cc"
goto _st17;
_st17:
p+= 1;
st_case_17:
if ( p == pe )
goto _out17;
switch( ( (*( p))) ) {
case 9: {
goto _ctr31;
}
case 32: {
goto _ctr31;
}
}
goto _st0;
_ctr31:
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
z2 = p; }
#line 502 "gen/ragel/submatch_04__apache_log.cc"
goto _st18;
_st18:
p+= 1;
st_case_18:
if ( p == pe )
goto _out18;
switch( ( (*( p))) ) {
case 9: {
goto _st18;
}
case 32: {
goto _st18;
}
case 34: {
goto _ctr33;
}
}
goto _st0;
_ctr33:
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
u1 = p; }
#line 526 "gen/ragel/submatch_04__apache_log.cc"
goto _st19;
_st19:
p+= 1;
st_case_19:
if ( p == pe )
goto _out19;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st0;
}
case 34: {
goto _st20;
}
}
goto _st19;
_st20:
p+= 1;
st_case_20:
if ( p == pe )
goto _out20;
switch( ( (*( p))) ) {
case 9: {
goto _ctr36;
}
case 32: {
goto _ctr36;
}
}
goto _st0;
_ctr36:
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
u2 = p; }
#line 564 "gen/ragel/submatch_04__apache_log.cc"
goto _st21;
_st21:
p+= 1;
st_case_21:
if ( p == pe )
goto _out21;
switch( ( (*( p))) ) {
case 9: {
goto _st21;
}
case 32: {
goto _st21;
}
case 34: {
goto _ctr38;
}
}
goto _st0;
_ctr38:
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
g1 = p; }
#line 588 "gen/ragel/submatch_04__apache_log.cc"
goto _st22;
_st22:
p+= 1;
st_case_22:
if ( p == pe )
goto _out22;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st0;
}
case 34: {
goto _st23;
}
}
goto _st22;
_st23:
p+= 1;
st_case_23:
if ( p == pe )
goto _out23;
if ( ( (*( p))) == 10 ) {
goto _ctr41;
}
goto _st0;
_ctr29:
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
z1 = p; }
#line 621 "gen/ragel/submatch_04__apache_log.cc"
goto _st24;
_st24:
p+= 1;
st_case_24:
if ( p == pe )
goto _out24;
switch( ( (*( p))) ) {
case 9: {
goto _ctr31;
}
case 32: {
goto _ctr31;
}
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st24;
}
goto _st0;
_out25: cs = 25; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out9: cs = 9; goto _out;
_out10: cs = 10; goto _out;
_out11: cs = 11; goto _out;
_out12: cs = 12; goto _out;
_out13: cs = 13; goto _out;
_out14: cs = 14; goto _out;
_out15: cs = 15; goto _out;
_out16: cs = 16; goto _out;
_out17: cs = 17; goto _out;
_out18: cs = 18; goto _out;
_out19: cs = 19; goto _out;
_out20: cs = 20; goto _out;
_out21: cs = 21; goto _out;
_out22: cs = 22; goto _out;
_out23: cs = 23; goto _out;
_out24: cs = 24; goto _out;
_out: {}
}
#line 57 "../../../benchmarks/c/src/ragel/submatch_04__apache_log.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_04__apache_log
@@ -0,0 +1,697 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
#include "ragel/base.h"
namespace ragel_submatch_05__datetime {
const char *delim = "\n";
#line 37 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
#line 11 "gen/ragel/submatch_05__datetime.cc"
static const int datetime_start = 35;
static const int datetime_first_final = 35;
static const int datetime_error = 0;
static const int datetime_en_main = 35;
#line 39 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*s1, *y1, *h1, *m1, *d1, *M1, *z1,
*s2, *y2, *h2, *m2, *d2, *M2, *z2;
int cs;
#line 28 "gen/ragel/submatch_05__datetime.cc"
{
cs = (int)datetime_start;
}
#line 49 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
#line 33 "gen/ragel/submatch_05__datetime.cc"
{
switch ( cs ) {
case 35:
goto st_case_35;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
case 9:
goto st_case_9;
case 10:
goto st_case_10;
case 11:
goto st_case_11;
case 12:
goto st_case_12;
case 13:
goto st_case_13;
case 14:
goto st_case_14;
case 15:
goto st_case_15;
case 16:
goto st_case_16;
case 17:
goto st_case_17;
case 18:
goto st_case_18;
case 19:
goto st_case_19;
case 20:
goto st_case_20;
case 21:
goto st_case_21;
case 22:
goto st_case_22;
case 23:
goto st_case_23;
case 24:
goto st_case_24;
case 25:
goto st_case_25;
case 26:
goto st_case_26;
case 27:
goto st_case_27;
case 28:
goto st_case_28;
case 29:
goto st_case_29;
case 30:
goto st_case_30;
case 31:
goto st_case_31;
case 32:
goto st_case_32;
case 33:
goto st_case_33;
case 34:
goto st_case_34;
}
_ctr43:
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
z2 = p; }
#line 113 "gen/ragel/submatch_05__datetime.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
OUT("year: ", y1, y2);
OUT("month: ", m1, m2);
OUT("day: ", d1, d2);
OUT("hours: ", h1, h2);
OUT("minutes: ", M1, M2);
OUT("seconds: ", s1, s2);
OUT("tz: ", z1, z2);
OUTC('\n');
}
#line 127 "gen/ragel/submatch_05__datetime.cc"
goto _st35;
_st35:
p+= 1;
st_case_35:
if ( p == pe )
goto _out35;
if ( ( (*( p))) == 48 ) {
goto _ctr53;
}
if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr54;
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr53:
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
y1 = p; }
#line 149 "gen/ragel/submatch_05__datetime.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st2;
}
goto _st0;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st3;
}
goto _st0;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st4;
}
goto _st0;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
if ( ( (*( p))) == 45 ) {
goto _ctr5;
}
goto _st0;
_ctr5:
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
y2 = p; }
#line 192 "gen/ragel/submatch_05__datetime.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 48: {
goto _ctr7;
}
case 49: {
goto _ctr8;
}
}
goto _st0;
_ctr7:
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
m1 = p; }
#line 213 "gen/ragel/submatch_05__datetime.cc"
goto _st6;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st7;
}
goto _st0;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
if ( ( (*( p))) == 45 ) {
goto _ctr11;
}
goto _st0;
_ctr11:
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
m2 = p; }
#line 238 "gen/ragel/submatch_05__datetime.cc"
goto _st8;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
switch( ( (*( p))) ) {
case 48: {
goto _ctr13;
}
case 51: {
goto _ctr15;
}
}
if ( 49 <= ( (*( p))) && ( (*( p))) <= 50 ) {
goto _ctr14;
}
goto _st0;
_ctr13:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
d1 = p; }
#line 262 "gen/ragel/submatch_05__datetime.cc"
goto _st9;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st10;
}
goto _st0;
_st10:
p+= 1;
st_case_10:
if ( p == pe )
goto _out10;
if ( ( (*( p))) == 84 ) {
goto _ctr18;
}
goto _st0;
_ctr18:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
d2 = p; }
#line 287 "gen/ragel/submatch_05__datetime.cc"
goto _st11;
_st11:
p+= 1;
st_case_11:
if ( p == pe )
goto _out11;
if ( ( (*( p))) == 50 ) {
goto _ctr21;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 49 ) {
goto _ctr20;
}
goto _st0;
_ctr20:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
h1 = p; }
#line 306 "gen/ragel/submatch_05__datetime.cc"
goto _st12;
_st12:
p+= 1;
st_case_12:
if ( p == pe )
goto _out12;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st13;
}
goto _st0;
_st13:
p+= 1;
st_case_13:
if ( p == pe )
goto _out13;
if ( ( (*( p))) == 58 ) {
goto _ctr24;
}
goto _st0;
_ctr24:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
h2 = p; }
#line 331 "gen/ragel/submatch_05__datetime.cc"
goto _st14;
_st14:
p+= 1;
st_case_14:
if ( p == pe )
goto _out14;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 53 ) {
goto _ctr26;
}
goto _st0;
_ctr26:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
M1 = p; }
#line 347 "gen/ragel/submatch_05__datetime.cc"
goto _st15;
_st15:
p+= 1;
st_case_15:
if ( p == pe )
goto _out15;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st16;
}
goto _st0;
_st16:
p+= 1;
st_case_16:
if ( p == pe )
goto _out16;
if ( ( (*( p))) == 58 ) {
goto _ctr29;
}
goto _st0;
_ctr29:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
M2 = p; }
#line 372 "gen/ragel/submatch_05__datetime.cc"
goto _st17;
_st17:
p+= 1;
st_case_17:
if ( p == pe )
goto _out17;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 53 ) {
goto _ctr31;
}
goto _st0;
_ctr31:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
s1 = p; }
#line 388 "gen/ragel/submatch_05__datetime.cc"
goto _st18;
_st18:
p+= 1;
st_case_18:
if ( p == pe )
goto _out18;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st19;
}
goto _st0;
_st19:
p+= 1;
st_case_19:
if ( p == pe )
goto _out19;
switch( ( (*( p))) ) {
case 43: {
goto _ctr34;
}
case 45: {
goto _ctr34;
}
case 90: {
goto _ctr35;
}
}
goto _st0;
_ctr34:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
s2 = p; }
#line 421 "gen/ragel/submatch_05__datetime.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
z1 = p; }
#line 426 "gen/ragel/submatch_05__datetime.cc"
goto _st20;
_st20:
p+= 1;
st_case_20:
if ( p == pe )
goto _out20;
if ( ( (*( p))) == 50 ) {
goto _st26;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 49 ) {
goto _st21;
}
goto _st0;
_st21:
p+= 1;
st_case_21:
if ( p == pe )
goto _out21;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st22;
}
goto _st0;
_st22:
p+= 1;
st_case_22:
if ( p == pe )
goto _out22;
if ( ( (*( p))) == 58 ) {
goto _st23;
}
goto _st0;
_st23:
p+= 1;
st_case_23:
if ( p == pe )
goto _out23;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 53 ) {
goto _st24;
}
goto _st0;
_st24:
p+= 1;
st_case_24:
if ( p == pe )
goto _out24;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st25;
}
goto _st0;
_ctr35:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
s2 = p; }
#line 481 "gen/ragel/submatch_05__datetime.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
z1 = p; }
#line 486 "gen/ragel/submatch_05__datetime.cc"
goto _st25;
_st25:
p+= 1;
st_case_25:
if ( p == pe )
goto _out25;
if ( ( (*( p))) == 10 ) {
goto _ctr43;
}
goto _st0;
_st26:
p+= 1;
st_case_26:
if ( p == pe )
goto _out26;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 51 ) {
goto _st22;
}
goto _st0;
_ctr21:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
h1 = p; }
#line 511 "gen/ragel/submatch_05__datetime.cc"
goto _st27;
_st27:
p+= 1;
st_case_27:
if ( p == pe )
goto _out27;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 51 ) {
goto _st13;
}
goto _st0;
_ctr14:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
d1 = p; }
#line 527 "gen/ragel/submatch_05__datetime.cc"
goto _st28;
_st28:
p+= 1;
st_case_28:
if ( p == pe )
goto _out28;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st10;
}
goto _st0;
_ctr15:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
d1 = p; }
#line 543 "gen/ragel/submatch_05__datetime.cc"
goto _st29;
_st29:
p+= 1;
st_case_29:
if ( p == pe )
goto _out29;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 49 ) {
goto _st10;
}
goto _st0;
_ctr8:
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
m1 = p; }
#line 559 "gen/ragel/submatch_05__datetime.cc"
goto _st30;
_st30:
p+= 1;
st_case_30:
if ( p == pe )
goto _out30;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 50 ) {
goto _st7;
}
goto _st0;
_ctr54:
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
y1 = p; }
#line 575 "gen/ragel/submatch_05__datetime.cc"
goto _st31;
_st31:
p+= 1;
st_case_31:
if ( p == pe )
goto _out31;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st32;
}
goto _st0;
_st32:
p+= 1;
st_case_32:
if ( p == pe )
goto _out32;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st33;
}
goto _st0;
_st33:
p+= 1;
st_case_33:
if ( p == pe )
goto _out33;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st34;
}
goto _st0;
_st34:
p+= 1;
st_case_34:
if ( p == pe )
goto _out34;
if ( ( (*( p))) == 45 ) {
goto _ctr5;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st34;
}
goto _st0;
_out35: cs = 35; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out9: cs = 9; goto _out;
_out10: cs = 10; goto _out;
_out11: cs = 11; goto _out;
_out12: cs = 12; goto _out;
_out13: cs = 13; goto _out;
_out14: cs = 14; goto _out;
_out15: cs = 15; goto _out;
_out16: cs = 16; goto _out;
_out17: cs = 17; goto _out;
_out18: cs = 18; goto _out;
_out19: cs = 19; goto _out;
_out20: cs = 20; goto _out;
_out21: cs = 21; goto _out;
_out22: cs = 22; goto _out;
_out23: cs = 23; goto _out;
_out24: cs = 24; goto _out;
_out25: cs = 25; goto _out;
_out26: cs = 26; goto _out;
_out27: cs = 27; goto _out;
_out28: cs = 28; goto _out;
_out29: cs = 29; goto _out;
_out30: cs = 30; goto _out;
_out31: cs = 31; goto _out;
_out32: cs = 32; goto _out;
_out33: cs = 33; goto _out;
_out34: cs = 34; goto _out;
_out: {}
}
#line 50 "../../../benchmarks/c/src/ragel/submatch_05__datetime.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_05__datetime
@@ -0,0 +1,407 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
#include "ragel/base.h"
namespace ragel_submatch_06__email {
const char *delim = "\n";
#line 28 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
#line 11 "gen/ragel/submatch_06__email.cc"
static const int email_start = 10;
static const int email_first_final = 10;
static const int email_error = 0;
static const int email_en_main = 10;
#line 30 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
char *p1, *p2;
int cs;
#line 26 "gen/ragel/submatch_06__email.cc"
{
cs = (int)email_start;
}
#line 38 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
#line 31 "gen/ragel/submatch_06__email.cc"
{
switch ( cs ) {
case 10:
goto st_case_10;
case 1:
goto st_case_1;
case 0:
goto st_case_0;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
case 9:
goto st_case_9;
}
_ctr11:
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
OUTC(' ');
OUTS(p1, p2 - 1);
OUTC(' ');
OUTS(p2, p);
OUTC('\n');
}
#line 67 "gen/ragel/submatch_06__email.cc"
goto _st10;
_st10:
p+= 1;
st_case_10:
if ( p == pe )
goto _out10;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
case 33: {
goto _ctr13;
}
case 45: {
goto _ctr13;
}
case 61: {
goto _ctr13;
}
case 63: {
goto _ctr13;
}
}
if ( ( (*( p))) < 42 ) {
if ( 35 <= ( (*( p))) && ( (*( p))) <= 39 ) {
goto _ctr13;
}
} else if ( ( (*( p))) > 43 ) {
if ( ( (*( p))) > 57 ) {
if ( 94 <= ( (*( p))) && ( (*( p))) <= 126 ) {
goto _ctr13;
}
} else if ( ( (*( p))) >= 47 ) {
goto _ctr13;
}
} else {
goto _ctr13;
}
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
}
goto _st1;
_st0:
st_case_0:
goto _out0;
_ctr13:
{
#line 17 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
p1 = p; }
#line 132 "gen/ragel/submatch_06__email.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
case 33: {
goto _st2;
}
case 46: {
goto _st3;
}
case 61: {
goto _st2;
}
case 63: {
goto _st2;
}
case 64: {
goto _st4;
}
}
if ( ( (*( p))) < 42 ) {
if ( 35 <= ( (*( p))) && ( (*( p))) <= 39 ) {
goto _st2;
}
} else if ( ( (*( p))) > 43 ) {
if ( ( (*( p))) > 57 ) {
if ( 94 <= ( (*( p))) && ( (*( p))) <= 126 ) {
goto _st2;
}
} else if ( ( (*( p))) >= 45 ) {
goto _st2;
}
} else {
goto _st2;
}
goto _st1;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
case 33: {
goto _st2;
}
case 45: {
goto _st2;
}
case 61: {
goto _st2;
}
case 63: {
goto _st2;
}
}
if ( ( (*( p))) < 42 ) {
if ( 35 <= ( (*( p))) && ( (*( p))) <= 39 ) {
goto _st2;
}
} else if ( ( (*( p))) > 43 ) {
if ( ( (*( p))) > 57 ) {
if ( 94 <= ( (*( p))) && ( (*( p))) <= 126 ) {
goto _st2;
}
} else if ( ( (*( p))) >= 47 ) {
goto _st2;
}
} else {
goto _st2;
}
goto _st1;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
}
if ( ( (*( p))) > 57 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 122 ) {
goto _ctr6;
}
} else if ( ( (*( p))) >= 48 ) {
goto _ctr6;
}
goto _st1;
_ctr6:
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
p2 = p; }
#line 245 "gen/ragel/submatch_06__email.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
case 45: {
goto _st6;
}
case 46: {
goto _st7;
}
}
if ( ( (*( p))) > 57 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 122 ) {
goto _st5;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st5;
}
goto _st1;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
case 45: {
goto _st6;
}
}
if ( ( (*( p))) > 57 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 122 ) {
goto _st5;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st5;
}
goto _st1;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
}
if ( ( (*( p))) > 57 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 122 ) {
goto _st8;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st8;
}
goto _st1;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _ctr11;
}
case 45: {
goto _st9;
}
case 46: {
goto _st7;
}
}
if ( ( (*( p))) > 57 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 122 ) {
goto _st8;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st8;
}
goto _st1;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
switch( ( (*( p))) ) {
case 0: {
goto _st0;
}
case 10: {
goto _st10;
}
case 45: {
goto _st9;
}
}
if ( ( (*( p))) > 57 ) {
if ( 97 <= ( (*( p))) && ( (*( p))) <= 122 ) {
goto _st8;
}
} else if ( ( (*( p))) >= 48 ) {
goto _st8;
}
goto _st1;
_out10: cs = 10; goto _out;
_out1: cs = 1; goto _out;
_out0: cs = 0; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out9: cs = 9; goto _out;
_out: {}
}
#line 39 "../../../benchmarks/c/src/ragel/submatch_06__email.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_06__email
@@ -0,0 +1,328 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
#include "ragel/base.h"
namespace ragel_submatch_07__ipv4 {
const char *delim = "\n";
#line 29 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
#line 11 "gen/ragel/submatch_07__ipv4.cc"
static const int ipv4_start = 16;
static const int ipv4_first_final = 16;
static const int ipv4_error = 0;
static const int ipv4_en_main = 16;
#line 31 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char *p1, *p2, *p3, *p4;
int cs;
#line 26 "gen/ragel/submatch_07__ipv4.cc"
{
cs = (int)ipv4_start;
}
#line 39 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
#line 31 "gen/ragel/submatch_07__ipv4.cc"
{
switch ( cs ) {
case 16:
goto st_case_16;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
case 9:
goto st_case_9;
case 10:
goto st_case_10;
case 11:
goto st_case_11;
case 12:
goto st_case_12;
case 13:
goto st_case_13;
case 14:
goto st_case_14;
case 15:
goto st_case_15;
}
_ctr14:
{
#line 17 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
OUTS(p1, p2 - 1);
OUTC(',');
OUTS(p2, p3 - 1);
OUTC(',');
OUTS(p3, p4 - 1);
OUTC(',');
OUTS(p4, p);
OUTC('\n');
}
#line 82 "gen/ragel/submatch_07__ipv4.cc"
goto _st16;
_st16:
p+= 1;
st_case_16:
if ( p == pe )
goto _out16;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr21;
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr21:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
p1 = p; }
#line 101 "gen/ragel/submatch_07__ipv4.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
if ( ( (*( p))) == 46 ) {
goto _st2;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st14;
}
goto _st0;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr4;
}
goto _st0;
_ctr4:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
p2 = p; }
#line 129 "gen/ragel/submatch_07__ipv4.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
if ( ( (*( p))) == 46 ) {
goto _st4;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st12;
}
goto _st0;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr8;
}
goto _st0;
_ctr8:
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
p3 = p; }
#line 157 "gen/ragel/submatch_07__ipv4.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
if ( ( (*( p))) == 46 ) {
goto _st6;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st10;
}
goto _st0;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _ctr12;
}
goto _st0;
_ctr12:
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
p4 = p; }
#line 185 "gen/ragel/submatch_07__ipv4.cc"
goto _st7;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
if ( ( (*( p))) == 10 ) {
goto _ctr14;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st8;
}
goto _st0;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
if ( ( (*( p))) == 10 ) {
goto _ctr14;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st9;
}
goto _st0;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
if ( ( (*( p))) == 10 ) {
goto _ctr14;
}
goto _st0;
_st10:
p+= 1;
st_case_10:
if ( p == pe )
goto _out10;
if ( ( (*( p))) == 46 ) {
goto _st6;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st11;
}
goto _st0;
_st11:
p+= 1;
st_case_11:
if ( p == pe )
goto _out11;
if ( ( (*( p))) == 46 ) {
goto _st6;
}
goto _st0;
_st12:
p+= 1;
st_case_12:
if ( p == pe )
goto _out12;
if ( ( (*( p))) == 46 ) {
goto _st4;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st13;
}
goto _st0;
_st13:
p+= 1;
st_case_13:
if ( p == pe )
goto _out13;
if ( ( (*( p))) == 46 ) {
goto _st4;
}
goto _st0;
_st14:
p+= 1;
st_case_14:
if ( p == pe )
goto _out14;
if ( ( (*( p))) == 46 ) {
goto _st2;
}
if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
goto _st15;
}
goto _st0;
_st15:
p+= 1;
st_case_15:
if ( p == pe )
goto _out15;
if ( ( (*( p))) == 46 ) {
goto _st2;
}
goto _st0;
_out16: cs = 16; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out9: cs = 9; goto _out;
_out10: cs = 10; goto _out;
_out11: cs = 11; goto _out;
_out12: cs = 12; goto _out;
_out13: cs = 13; goto _out;
_out14: cs = 14; goto _out;
_out15: cs = 15; goto _out;
_out: {}
}
#line 40 "../../../benchmarks/c/src/ragel/submatch_07__ipv4.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_07__ipv4
@@ -0,0 +1,207 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
#include "ragel/base.h"
namespace ragel_submatch_10__alt1_2 {
const char *delim = "\n";
#line 23 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
#line 11 "gen/ragel/submatch_10__alt1_2.cc"
static const int m_start = 3;
static const int m_first_final = 3;
static const int m_error = 0;
static const int m_en_main = 3;
#line 25 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*a1, *b1,
*a2, *b2;
int cs;
#line 28 "gen/ragel/submatch_10__alt1_2.cc"
{
cs = (int)m_start;
}
#line 35 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
#line 33 "gen/ragel/submatch_10__alt1_2.cc"
{
switch ( cs ) {
case 3:
goto st_case_3;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
}
_ctr2:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 49 "gen/ragel/submatch_10__alt1_2.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
OUTC('\n');
}
#line 58 "gen/ragel/submatch_10__alt1_2.cc"
goto _st3;
_ctr4:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 65 "gen/ragel/submatch_10__alt1_2.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
OUTC('\n');
}
#line 74 "gen/ragel/submatch_10__alt1_2.cc"
goto _st3;
_ctr6:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
b1 = p; }
#line 81 "gen/ragel/submatch_10__alt1_2.cc"
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 86 "gen/ragel/submatch_10__alt1_2.cc"
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
a1 = p; }
#line 91 "gen/ragel/submatch_10__alt1_2.cc"
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 96 "gen/ragel/submatch_10__alt1_2.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
OUTC('\n');
}
#line 105 "gen/ragel/submatch_10__alt1_2.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 10: {
goto _ctr6;
}
case 97: {
goto _ctr7;
}
case 98: {
goto _ctr8;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr7:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
a1 = p; }
#line 132 "gen/ragel/submatch_10__alt1_2.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 10: {
goto _ctr2;
}
case 97: {
goto _st1;
}
}
goto _st0;
_ctr8:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
b1 = p; }
#line 153 "gen/ragel/submatch_10__alt1_2.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr4;
}
case 98: {
goto _st2;
}
}
goto _st0;
_out3: cs = 3; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out: {}
}
#line 36 "../../../benchmarks/c/src/ragel/submatch_10__alt1_2.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_10__alt1_2
@@ -0,0 +1,333 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
#include "ragel/base.h"
namespace ragel_submatch_11__alt1_4 {
const char *delim = "\n";
#line 27 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
#line 11 "gen/ragel/submatch_11__alt1_4.cc"
static const int m_start = 5;
static const int m_first_final = 5;
static const int m_error = 0;
static const int m_en_main = 5;
#line 29 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*a1, *b1, *c1, *d1,
*a2, *b2, *c2, *d2;
int cs;
#line 28 "gen/ragel/submatch_11__alt1_4.cc"
{
cs = (int)m_start;
}
#line 39 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
#line 33 "gen/ragel/submatch_11__alt1_4.cc"
{
switch ( cs ) {
case 5:
goto st_case_5;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
}
_ctr2:
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 53 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
OUTC('\n');
}
#line 64 "gen/ragel/submatch_11__alt1_4.cc"
goto _st5;
_ctr4:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 71 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
OUTC('\n');
}
#line 82 "gen/ragel/submatch_11__alt1_4.cc"
goto _st5;
_ctr6:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 89 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
OUTC('\n');
}
#line 100 "gen/ragel/submatch_11__alt1_4.cc"
goto _st5;
_ctr8:
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 107 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
OUTC('\n');
}
#line 118 "gen/ragel/submatch_11__alt1_4.cc"
goto _st5;
_ctr10:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
b1 = p; }
#line 125 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 130 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
c1 = p; }
#line 135 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 140 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
d1 = p; }
#line 145 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 150 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
a1 = p; }
#line 155 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 160 "gen/ragel/submatch_11__alt1_4.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
OUTC('\n');
}
#line 171 "gen/ragel/submatch_11__alt1_4.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 10: {
goto _ctr10;
}
case 97: {
goto _ctr11;
}
case 98: {
goto _ctr12;
}
case 99: {
goto _ctr13;
}
case 100: {
goto _ctr14;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr11:
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
a1 = p; }
#line 204 "gen/ragel/submatch_11__alt1_4.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 10: {
goto _ctr2;
}
case 97: {
goto _st1;
}
}
goto _st0;
_ctr12:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
b1 = p; }
#line 225 "gen/ragel/submatch_11__alt1_4.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr4;
}
case 98: {
goto _st2;
}
}
goto _st0;
_ctr13:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
c1 = p; }
#line 246 "gen/ragel/submatch_11__alt1_4.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 10: {
goto _ctr6;
}
case 99: {
goto _st3;
}
}
goto _st0;
_ctr14:
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
d1 = p; }
#line 267 "gen/ragel/submatch_11__alt1_4.cc"
goto _st4;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 10: {
goto _ctr8;
}
case 100: {
goto _st4;
}
}
goto _st0;
_out5: cs = 5; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out: {}
}
#line 40 "../../../benchmarks/c/src/ragel/submatch_11__alt1_4.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_11__alt1_4
@@ -0,0 +1,609 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
#include "ragel/base.h"
namespace ragel_submatch_12__alt1_8 {
const char *delim = "\n";
#line 35 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
#line 11 "gen/ragel/submatch_12__alt1_8.cc"
static const int m_start = 9;
static const int m_first_final = 9;
static const int m_error = 0;
static const int m_en_main = 9;
#line 37 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*a1, *b1, *c1, *d1, *e1, *f1, *g1, *h1,
*a2, *b2, *c2, *d2, *e2, *f2, *g2, *h2;
int cs;
#line 28 "gen/ragel/submatch_12__alt1_8.cc"
{
cs = (int)m_start;
}
#line 47 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
#line 33 "gen/ragel/submatch_12__alt1_8.cc"
{
switch ( cs ) {
case 9:
goto st_case_9;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
}
_ctr2:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 61 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 76 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr4:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 83 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 98 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr6:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 105 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 120 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr8:
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 127 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 142 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr10:
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
e2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 149 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 164 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr12:
{
#line 17 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
f2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = g1 = g2 = h1 = h2 = NULL; }
#line 171 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 186 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr14:
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
g2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = h1 = h2 = NULL; }
#line 193 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 208 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr16:
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
h2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = NULL; }
#line 215 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 230 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_ctr18:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
b1 = p; }
#line 237 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 242 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
c1 = p; }
#line 247 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 252 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
d1 = p; }
#line 257 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 262 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
e1 = p; }
#line 267 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
e2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 272 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 17 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
f1 = p; }
#line 277 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 17 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
f2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = g1 = g2 = h1 = h2 = NULL; }
#line 282 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
g1 = p; }
#line 287 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
g2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = h1 = h2 = NULL; }
#line 292 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
h1 = p; }
#line 297 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
h2 = p; a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = NULL; }
#line 302 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
a1 = p; }
#line 307 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = f1 = f2 = g1 = g2 = h1 = h2 = NULL; }
#line 312 "gen/ragel/submatch_12__alt1_8.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
else if (e1) { OUTC('E'); OUTS(e1, e2); }
else if (f1) { OUTC('F'); OUTS(f1, f2); }
else if (g1) { OUTC('G'); OUTS(g1, g2); }
else if (h1) { OUTC('H'); OUTS(h1, h2); }
OUTC('\n');
}
#line 327 "gen/ragel/submatch_12__alt1_8.cc"
goto _st9;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
switch( ( (*( p))) ) {
case 10: {
goto _ctr18;
}
case 97: {
goto _ctr19;
}
case 98: {
goto _ctr20;
}
case 99: {
goto _ctr21;
}
case 100: {
goto _ctr22;
}
case 101: {
goto _ctr23;
}
case 102: {
goto _ctr24;
}
case 103: {
goto _ctr25;
}
case 104: {
goto _ctr26;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr19:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
a1 = p; }
#line 372 "gen/ragel/submatch_12__alt1_8.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 10: {
goto _ctr2;
}
case 97: {
goto _st1;
}
}
goto _st0;
_ctr20:
{
#line 13 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
b1 = p; }
#line 393 "gen/ragel/submatch_12__alt1_8.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr4;
}
case 98: {
goto _st2;
}
}
goto _st0;
_ctr21:
{
#line 14 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
c1 = p; }
#line 414 "gen/ragel/submatch_12__alt1_8.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 10: {
goto _ctr6;
}
case 99: {
goto _st3;
}
}
goto _st0;
_ctr22:
{
#line 15 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
d1 = p; }
#line 435 "gen/ragel/submatch_12__alt1_8.cc"
goto _st4;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 10: {
goto _ctr8;
}
case 100: {
goto _st4;
}
}
goto _st0;
_ctr23:
{
#line 16 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
e1 = p; }
#line 456 "gen/ragel/submatch_12__alt1_8.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 10: {
goto _ctr10;
}
case 101: {
goto _st5;
}
}
goto _st0;
_ctr24:
{
#line 17 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
f1 = p; }
#line 477 "gen/ragel/submatch_12__alt1_8.cc"
goto _st6;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
switch( ( (*( p))) ) {
case 10: {
goto _ctr12;
}
case 102: {
goto _st6;
}
}
goto _st0;
_ctr25:
{
#line 18 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
g1 = p; }
#line 498 "gen/ragel/submatch_12__alt1_8.cc"
goto _st7;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
switch( ( (*( p))) ) {
case 10: {
goto _ctr14;
}
case 103: {
goto _st7;
}
}
goto _st0;
_ctr26:
{
#line 19 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
h1 = p; }
#line 519 "gen/ragel/submatch_12__alt1_8.cc"
goto _st8;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
switch( ( (*( p))) ) {
case 10: {
goto _ctr16;
}
case 104: {
goto _st8;
}
}
goto _st0;
_out9: cs = 9; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out: {}
}
#line 48 "../../../benchmarks/c/src/ragel/submatch_12__alt1_8.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_12__alt1_8
@@ -0,0 +1,395 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
#include "ragel/base.h"
namespace ragel_submatch_13__alt2_2 {
const char *delim = "\n";
#line 36 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
#line 11 "gen/ragel/submatch_13__alt2_2.cc"
static const int m_start = 5;
static const int m_first_final = 5;
static const int m_error = 0;
static const int m_en_main = 5;
#line 38 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*a1, *b1,
*a2, *b2,
*a3, *b3,
*a4, *b4;
int cs;
#line 30 "gen/ragel/submatch_13__alt2_2.cc"
{
cs = (int)m_start;
}
#line 50 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
#line 35 "gen/ragel/submatch_13__alt2_2.cc"
{
switch ( cs ) {
case 5:
goto st_case_5;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
}
_ctr2:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 55 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b3 = p; }
#line 60 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 65 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a3 = p; }
#line 70 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 75 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
OUTC('\n');
}
#line 86 "gen/ragel/submatch_13__alt2_2.cc"
goto _st5;
_ctr5:
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 93 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
OUTC('\n');
}
#line 104 "gen/ragel/submatch_13__alt2_2.cc"
goto _st5;
_ctr7:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 111 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b3 = p; }
#line 116 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 121 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a3 = p; }
#line 126 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 131 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
OUTC('\n');
}
#line 142 "gen/ragel/submatch_13__alt2_2.cc"
goto _st5;
_ctr10:
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 149 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
OUTC('\n');
}
#line 160 "gen/ragel/submatch_13__alt2_2.cc"
goto _st5;
_ctr12:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b1 = p; }
#line 167 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 172 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a1 = p; }
#line 177 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 182 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b3 = p; }
#line 187 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 192 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a3 = p; }
#line 197 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 202 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
OUTC('\n');
}
#line 213 "gen/ragel/submatch_13__alt2_2.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 10: {
goto _ctr12;
}
case 97: {
goto _ctr13;
}
case 98: {
goto _ctr14;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr13:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a1 = p; }
#line 240 "gen/ragel/submatch_13__alt2_2.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 10: {
goto _ctr2;
}
case 97: {
goto _st1;
}
case 98: {
goto _ctr3;
}
}
goto _st0;
_ctr3:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 264 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 24 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b3 = p; }
#line 269 "gen/ragel/submatch_13__alt2_2.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr5;
}
case 98: {
goto _st2;
}
}
goto _st0;
_ctr14:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b1 = p; }
#line 290 "gen/ragel/submatch_13__alt2_2.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 10: {
goto _ctr7;
}
case 97: {
goto _ctr8;
}
case 98: {
goto _st3;
}
}
goto _st0;
_ctr8:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 314 "gen/ragel/submatch_13__alt2_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
a3 = p; }
#line 319 "gen/ragel/submatch_13__alt2_2.cc"
goto _st4;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 10: {
goto _ctr10;
}
case 97: {
goto _st4;
}
}
goto _st0;
_out5: cs = 5; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out: {}
}
#line 51 "../../../benchmarks/c/src/ragel/submatch_13__alt2_2.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_13__alt2_2
@@ -0,0 +1,963 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
#include "ragel/base.h"
namespace ragel_submatch_14__alt2_4 {
const char *delim = "\n";
#line 44 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
#line 11 "gen/ragel/submatch_14__alt2_4.cc"
static const int m_start = 9;
static const int m_first_final = 9;
static const int m_error = 0;
static const int m_en_main = 9;
#line 46 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*a1, *b1, *c1, *d1,
*a2, *b2, *c2, *d2,
*a3, *b3, *c3, *d3,
*a4, *b4, *c4, *d4;
int cs;
#line 30 "gen/ragel/submatch_14__alt2_4.cc"
{
cs = (int)m_start;
}
#line 58 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
#line 35 "gen/ragel/submatch_14__alt2_4.cc"
{
switch ( cs ) {
case 9:
goto st_case_9;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
}
_ctr2:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 63 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 68 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b4 = p; a3 = a4 = c3 = c4 = d3 = d4 = NULL; }
#line 73 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 78 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c4 = p; a3 = a4 = b3 = b4 = d3 = d4 = NULL; }
#line 83 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 88 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d4 = p; a3 = a4 = b3 = b4 = c3 = c4 = NULL; }
#line 93 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 98 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a4 = p; b3 = b4 = c3 = c4 = d3 = d4 = NULL; }
#line 103 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 118 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr7:
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b4 = p; a3 = a4 = c3 = c4 = d3 = d4 = NULL; }
#line 125 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 140 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr9:
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c4 = p; a3 = a4 = b3 = b4 = d3 = d4 = NULL; }
#line 147 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 162 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr11:
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d4 = p; a3 = a4 = b3 = b4 = c3 = c4 = NULL; }
#line 169 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 184 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr13:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 191 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 196 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b4 = p; a3 = a4 = c3 = c4 = d3 = d4 = NULL; }
#line 201 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 206 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c4 = p; a3 = a4 = b3 = b4 = d3 = d4 = NULL; }
#line 211 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 216 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d4 = p; a3 = a4 = b3 = b4 = c3 = c4 = NULL; }
#line 221 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 226 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a4 = p; b3 = b4 = c3 = c4 = d3 = d4 = NULL; }
#line 231 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 246 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr18:
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a4 = p; b3 = b4 = c3 = c4 = d3 = d4 = NULL; }
#line 253 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 268 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr20:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 275 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 280 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b4 = p; a3 = a4 = c3 = c4 = d3 = d4 = NULL; }
#line 285 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 290 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c4 = p; a3 = a4 = b3 = b4 = d3 = d4 = NULL; }
#line 295 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 300 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d4 = p; a3 = a4 = b3 = b4 = c3 = c4 = NULL; }
#line 305 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 310 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a4 = p; b3 = b4 = c3 = c4 = d3 = d4 = NULL; }
#line 315 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 330 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr25:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 337 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 342 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b4 = p; a3 = a4 = c3 = c4 = d3 = d4 = NULL; }
#line 347 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 352 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c4 = p; a3 = a4 = b3 = b4 = d3 = d4 = NULL; }
#line 357 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 362 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d4 = p; a3 = a4 = b3 = b4 = c3 = c4 = NULL; }
#line 367 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 372 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a4 = p; b3 = b4 = c3 = c4 = d3 = d4 = NULL; }
#line 377 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 392 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_ctr30:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b1 = p; }
#line 399 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 404 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c1 = p; }
#line 409 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 414 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d1 = p; }
#line 419 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 424 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a1 = p; }
#line 429 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 434 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 439 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b4 = p; a3 = a4 = c3 = c4 = d3 = d4 = NULL; }
#line 444 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 449 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c4 = p; a3 = a4 = b3 = b4 = d3 = d4 = NULL; }
#line 454 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 459 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d4 = p; a3 = a4 = b3 = b4 = c3 = c4 = NULL; }
#line 464 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 469 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a4 = p; b3 = b4 = c3 = c4 = d3 = d4 = NULL; }
#line 474 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 31 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
else if (c1) { OUTC('C'); OUTS(c1, c2); }
else if (d1) { OUTC('D'); OUTS(d1, d2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
else if (c3) { OUTC('C'); OUTS(c3, c4); }
else if (d3) { OUTC('D'); OUTS(d3, d4); }
OUTC('\n');
}
#line 489 "gen/ragel/submatch_14__alt2_4.cc"
goto _st9;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
switch( ( (*( p))) ) {
case 10: {
goto _ctr30;
}
case 97: {
goto _ctr31;
}
case 98: {
goto _ctr32;
}
case 99: {
goto _ctr33;
}
case 100: {
goto _ctr34;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr31:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a1 = p; }
#line 522 "gen/ragel/submatch_14__alt2_4.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 10: {
goto _ctr2;
}
case 97: {
goto _st1;
}
case 98: {
goto _ctr3;
}
case 99: {
goto _ctr4;
}
case 100: {
goto _ctr5;
}
}
goto _st0;
_ctr3:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 552 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 557 "gen/ragel/submatch_14__alt2_4.cc"
goto _st2;
_ctr22:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 564 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 569 "gen/ragel/submatch_14__alt2_4.cc"
goto _st2;
_ctr27:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 576 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b3 = p; }
#line 581 "gen/ragel/submatch_14__alt2_4.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr7;
}
case 98: {
goto _st2;
}
}
goto _st0;
_ctr4:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 602 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 607 "gen/ragel/submatch_14__alt2_4.cc"
goto _st3;
_ctr15:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 614 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 619 "gen/ragel/submatch_14__alt2_4.cc"
goto _st3;
_ctr28:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 626 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 27 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c3 = p; }
#line 631 "gen/ragel/submatch_14__alt2_4.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 10: {
goto _ctr9;
}
case 99: {
goto _st3;
}
}
goto _st0;
_ctr5:
{
#line 23 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a2 = p; b1 = b2 = c1 = c2 = d1 = d2 = NULL; }
#line 652 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 657 "gen/ragel/submatch_14__alt2_4.cc"
goto _st4;
_ctr16:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 664 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 669 "gen/ragel/submatch_14__alt2_4.cc"
goto _st4;
_ctr23:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 676 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 28 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d3 = p; }
#line 681 "gen/ragel/submatch_14__alt2_4.cc"
goto _st4;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 10: {
goto _ctr11;
}
case 100: {
goto _st4;
}
}
goto _st0;
_ctr32:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b1 = p; }
#line 702 "gen/ragel/submatch_14__alt2_4.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 10: {
goto _ctr13;
}
case 97: {
goto _ctr14;
}
case 98: {
goto _st5;
}
case 99: {
goto _ctr15;
}
case 100: {
goto _ctr16;
}
}
goto _st0;
_ctr14:
{
#line 20 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
b2 = p; a1 = a2 = c1 = c2 = d1 = d2 = NULL; }
#line 732 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 737 "gen/ragel/submatch_14__alt2_4.cc"
goto _st6;
_ctr21:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c2 = p; a1 = a2 = b1 = b2 = d1 = d2 = NULL; }
#line 744 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 749 "gen/ragel/submatch_14__alt2_4.cc"
goto _st6;
_ctr26:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d2 = p; a1 = a2 = b1 = b2 = c1 = c2 = NULL; }
#line 756 "gen/ragel/submatch_14__alt2_4.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
a3 = p; }
#line 761 "gen/ragel/submatch_14__alt2_4.cc"
goto _st6;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
switch( ( (*( p))) ) {
case 10: {
goto _ctr18;
}
case 97: {
goto _st6;
}
}
goto _st0;
_ctr33:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
c1 = p; }
#line 782 "gen/ragel/submatch_14__alt2_4.cc"
goto _st7;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
switch( ( (*( p))) ) {
case 10: {
goto _ctr20;
}
case 97: {
goto _ctr21;
}
case 98: {
goto _ctr22;
}
case 99: {
goto _st7;
}
case 100: {
goto _ctr23;
}
}
goto _st0;
_ctr34:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
d1 = p; }
#line 812 "gen/ragel/submatch_14__alt2_4.cc"
goto _st8;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
switch( ( (*( p))) ) {
case 10: {
goto _ctr25;
}
case 97: {
goto _ctr26;
}
case 98: {
goto _ctr27;
}
case 99: {
goto _ctr28;
}
case 100: {
goto _st8;
}
}
goto _st0;
_out9: cs = 9; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out: {}
}
#line 59 "../../../benchmarks/c/src/ragel/submatch_14__alt2_4.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_14__alt2_4
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,939 @@
#line 1 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
#include "ragel/base.h"
namespace ragel_submatch_16__alt4_2 {
const char *delim = "\n";
#line 49 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
#line 11 "gen/ragel/submatch_16__alt4_2.cc"
static const int m_start = 9;
static const int m_first_final = 9;
static const int m_error = 0;
static const int m_en_main = 9;
#line 51 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
static int lex(Input *in, int count) {
char *p = in->p;
char *pe = in->pe;
const char
*a1, *b1,
*a2, *b2,
*a3, *b3,
*a4, *b4,
*a5, *b5,
*a6, *b6,
*a7, *b7,
*a8, *b8;
int cs;
#line 34 "gen/ragel/submatch_16__alt4_2.cc"
{
cs = (int)m_start;
}
#line 67 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
#line 39 "gen/ragel/submatch_16__alt4_2.cc"
{
switch ( cs ) {
case 9:
goto st_case_9;
case 0:
goto st_case_0;
case 1:
goto st_case_1;
case 2:
goto st_case_2;
case 3:
goto st_case_3;
case 4:
goto st_case_4;
case 5:
goto st_case_5;
case 6:
goto st_case_6;
case 7:
goto st_case_7;
case 8:
goto st_case_8;
}
_ctr2:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 67 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b3 = p; }
#line 72 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 77 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a3 = p; }
#line 82 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 87 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b5 = p; }
#line 92 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 97 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a5 = p; }
#line 102 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 107 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 112 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 117 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 122 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 127 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 142 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr5:
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 149 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b5 = p; }
#line 154 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 159 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a5 = p; }
#line 164 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 169 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 174 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 179 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 184 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 189 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 204 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr8:
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 211 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 216 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 221 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 226 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 231 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 246 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr11:
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 253 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 268 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr13:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 275 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b3 = p; }
#line 280 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 285 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a3 = p; }
#line 290 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 295 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b5 = p; }
#line 300 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 305 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a5 = p; }
#line 310 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 315 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 320 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 325 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 330 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 335 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 350 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr16:
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 357 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b5 = p; }
#line 362 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 367 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a5 = p; }
#line 372 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 377 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 382 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 387 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 392 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 397 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 412 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr19:
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 419 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 424 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 429 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 434 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 439 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 454 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr22:
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 461 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 476 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_ctr24:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b1 = p; }
#line 483 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 488 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a1 = p; }
#line 493 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 498 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b3 = p; }
#line 503 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 508 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a3 = p; }
#line 513 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 518 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b5 = p; }
#line 523 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 528 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a5 = p; }
#line 533 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 538 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 543 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b8 = p; a7 = a8 = NULL; }
#line 548 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 553 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a8 = p; b7 = b8 = NULL; }
#line 558 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 36 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
if (a1) { OUTC('A'); OUTS(a1, a2); }
else if (b1) { OUTC('B'); OUTS(b1, b2); }
if (a3) { OUTC('A'); OUTS(a3, a4); }
else if (b3) { OUTC('B'); OUTS(b3, b4); }
if (a5) { OUTC('A'); OUTS(a5, a6); }
else if (b5) { OUTC('B'); OUTS(b5, b6); }
if (a7) { OUTC('A'); OUTS(a7, a8); }
else if (b7) { OUTC('B'); OUTS(b7, b8); }
OUTC('\n');
}
#line 573 "gen/ragel/submatch_16__alt4_2.cc"
goto _st9;
_st9:
p+= 1;
st_case_9:
if ( p == pe )
goto _out9;
switch( ( (*( p))) ) {
case 10: {
goto _ctr24;
}
case 97: {
goto _ctr25;
}
case 98: {
goto _ctr26;
}
}
goto _st0;
_st0:
st_case_0:
goto _out0;
_ctr25:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a1 = p; }
#line 600 "gen/ragel/submatch_16__alt4_2.cc"
goto _st1;
_st1:
p+= 1;
st_case_1:
if ( p == pe )
goto _out1;
switch( ( (*( p))) ) {
case 10: {
goto _ctr2;
}
case 97: {
goto _st1;
}
case 98: {
goto _ctr3;
}
}
goto _st0;
_ctr3:
{
#line 22 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a2 = p; b1 = b2 = NULL; }
#line 624 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b3 = p; }
#line 629 "gen/ragel/submatch_16__alt4_2.cc"
goto _st2;
_st2:
p+= 1;
st_case_2:
if ( p == pe )
goto _out2;
switch( ( (*( p))) ) {
case 10: {
goto _ctr5;
}
case 97: {
goto _ctr6;
}
case 98: {
goto _st2;
}
}
goto _st0;
_ctr6:
{
#line 25 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b4 = p; a3 = a4 = NULL; }
#line 653 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a5 = p; }
#line 658 "gen/ragel/submatch_16__alt4_2.cc"
goto _st3;
_st3:
p+= 1;
st_case_3:
if ( p == pe )
goto _out3;
switch( ( (*( p))) ) {
case 10: {
goto _ctr8;
}
case 97: {
goto _st3;
}
case 98: {
goto _ctr9;
}
}
goto _st0;
_ctr9:
{
#line 30 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a6 = p; b5 = b6 = NULL; }
#line 682 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 33 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b7 = p; }
#line 687 "gen/ragel/submatch_16__alt4_2.cc"
goto _st4;
_st4:
p+= 1;
st_case_4:
if ( p == pe )
goto _out4;
switch( ( (*( p))) ) {
case 10: {
goto _ctr11;
}
case 98: {
goto _st4;
}
}
goto _st0;
_ctr26:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b1 = p; }
#line 708 "gen/ragel/submatch_16__alt4_2.cc"
goto _st5;
_st5:
p+= 1;
st_case_5:
if ( p == pe )
goto _out5;
switch( ( (*( p))) ) {
case 10: {
goto _ctr13;
}
case 97: {
goto _ctr14;
}
case 98: {
goto _st5;
}
}
goto _st0;
_ctr14:
{
#line 21 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b2 = p; a1 = a2 = NULL; }
#line 732 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a3 = p; }
#line 737 "gen/ragel/submatch_16__alt4_2.cc"
goto _st6;
_st6:
p+= 1;
st_case_6:
if ( p == pe )
goto _out6;
switch( ( (*( p))) ) {
case 10: {
goto _ctr16;
}
case 97: {
goto _st6;
}
case 98: {
goto _ctr17;
}
}
goto _st0;
_ctr17:
{
#line 26 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a4 = p; b3 = b4 = NULL; }
#line 761 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b5 = p; }
#line 766 "gen/ragel/submatch_16__alt4_2.cc"
goto _st7;
_st7:
p+= 1;
st_case_7:
if ( p == pe )
goto _out7;
switch( ( (*( p))) ) {
case 10: {
goto _ctr19;
}
case 97: {
goto _ctr20;
}
case 98: {
goto _st7;
}
}
goto _st0;
_ctr20:
{
#line 29 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
b6 = p; a5 = a6 = NULL; }
#line 790 "gen/ragel/submatch_16__alt4_2.cc"
{
#line 34 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
a7 = p; }
#line 795 "gen/ragel/submatch_16__alt4_2.cc"
goto _st8;
_st8:
p+= 1;
st_case_8:
if ( p == pe )
goto _out8;
switch( ( (*( p))) ) {
case 10: {
goto _ctr22;
}
case 97: {
goto _st8;
}
}
goto _st0;
_out9: cs = 9; goto _out;
_out0: cs = 0; goto _out;
_out1: cs = 1; goto _out;
_out2: cs = 2; goto _out;
_out3: cs = 3; goto _out;
_out4: cs = 4; goto _out;
_out5: cs = 5; goto _out;
_out6: cs = 6; goto _out;
_out7: cs = 7; goto _out;
_out8: cs = 8; goto _out;
_out: {}
}
#line 68 "../../../benchmarks/c/src/ragel/submatch_16__alt4_2.rl"
in->p = p;
in->pe = pe;
return count;
}
RAGEL_BENCH_AND_TEST()
} // namespace ragel_submatch_16__alt4_2
File diff suppressed because it is too large Load Diff

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