fix(generate): return error when single state transitions have

indirectly recursive cycles.

This can cause infinite loops in the parser near EOF.

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
(cherry picked from commit 310c0b86a7)
This commit is contained in:
Will Lillis 2025-09-02 22:02:31 -04:00 committed by Amaan Qureshi
parent 8e2b5ad2a4
commit 14c4d2f8ca
3 changed files with 114 additions and 1 deletions

View file

@ -0,0 +1 @@
Grammar contains an indirectly recursive rule: type_expression -> _expression -> identifier_expression -> type_expression

View file

@ -0,0 +1,16 @@
module.exports = grammar({
name: 'indirect_recursive_in_single_symbol_transitions',
rules: {
source_file: $ => repeat($._statement),
_statement: $ => seq($.initialization_part, $.type_expression),
type_expression: $ => choice('int', $._expression),
initialization_part: $ => seq('=', $._expression),
_expression: $ => choice($.identifier_expression, $.type_expression),
identifier_expression: $ => choice(/[a-zA-Z_][a-zA-Z0-9_]*/, $.type_expression),
}
});