100 Commits
Author SHA1 Message Date
Ulya Trofimovich 9682dcd2b2 Github Actions: try 'oracle-openjdk' as 'redhat' has no macOS support. 2026-09-06 22:07:26 +01:00
Ulya Trofimovich 745a042652 Github Actions: also fix JDK version.
Pick the most recent one supported by 'redhat' distribution: 21.
2026-09-06 21:49:30 +01:00
Ulya Trofimovich b1720e831c Github Actions: fix infra error with setup-java@v6.
Pick 'redhat' distribution that packages OpenJDK, as the previously used
'adopt' distribution is no longer supported with setup-java@v6.
2026-09-06 21:44:31 +01:00
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
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
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
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 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
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
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
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
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