Skip to content

fix(generate): return error when single state transitions have indirectly recursive cycles#4786

Merged
amaanq merged 2 commits intotree-sitter:masterfrom
WillLillis:epsilon-reduction-loop
Sep 4, 2025
Merged

fix(generate): return error when single state transitions have indirectly recursive cycles#4786
amaanq merged 2 commits intotree-sitter:masterfrom
WillLillis:epsilon-reduction-loop

Conversation

@WillLillis
Copy link
Member

If a grammar's rules can create a cycle via indirect recursion (i.e. A->B->A), this can cause parsing to loop infinitely in certain cases (i.e. near EOF). This is also just a bad idea from a grammar perspective, so we'll return an error during generation.

WillLillis and others added 2 commits September 2, 2025 23:56
indirectly recursive cycles.

This can cause infinite loops in the parser near EOF.

Co-authored-by: Amaan Qureshi <amaanq12@gmail.com>
@WillLillis WillLillis requested a review from amaanq September 3, 2025 06:08
@clason clason added parser-generation Related to `tree-sitter generate` ci:backport release-0.25 Backport label labels Sep 3, 2025
@amaanq amaanq merged commit 310c0b8 into tree-sitter:master Sep 4, 2025
22 checks passed
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:backport release-0.25 Backport label parser-generation Related to `tree-sitter generate`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example grammar that hangs on parse

3 participants