-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat(codegen)!: accept mutual (indirect) left recursion via hub inlining (#151) #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f622f6a
feat(codegen): accept mutual (indirect) left recursion via hub inlini…
tinovyatkin 9fc6a1b
docs: RFC paper on mutual left-recursion elimination for ANTLR mainta…
tinovyatkin 07f786f
docs(rfc): add Visual Basic replication as second real-world data point
tinovyatkin aa03b8f
docs(rfc): link the four dotnet/roslyn issues filed for the VB gramma…
tinovyatkin 4afe111
fix(codegen): decide mutual-left-recursion rewrites before mutating (…
tinovyatkin ec34156
docs: describe the tightened mutual-left-recursion preconditions
tinovyatkin 793b3ae
docs(rfc): repair a sentence the markdown formatter split into a list…
tinovyatkin 65d27af
fix(mutual-recursion): close review round-3 defects in the cycle planner
tinovyatkin 6106e72
docs(mutual-recursion): record round-3 preconditions and findings
tinovyatkin 7ee3b9c
fix(mutual-recursion): accumulate alternative options across chained …
tinovyatkin eb69af7
docs(mutual-recursion): record chained option accumulation semantics
tinovyatkin b18ebff
fix(mutual-recursion): decline context-bound actions, implicit-refere…
tinovyatkin ddb6f5a
fix(mutual-recursion): own satellite semantics, pre-transform symbol …
tinovyatkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...r/snapshots/antlr4_rust_gen__grammar__mutual_recursion__tests__assoc_right_preserved.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| expr: | ||
| | <assoc=right> expr ''^'' expr | ||
| | ID |
7 changes: 7 additions & 0 deletions
7
...pshots/antlr4_rust_gen__grammar__mutual_recursion__tests__caller_alt_label_preserved.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | e ''+'' ID #ViaSatellite | ||
| | ID #Atom |
7 changes: 7 additions & 0 deletions
7
...r/snapshots/antlr4_rust_gen__grammar__mutual_recursion__tests__chained_assoc_carried.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | <assoc=right> e ''^'' e | ||
| | ID |
10 changes: 10 additions & 0 deletions
10
...r/snapshots/antlr4_rust_gen__grammar__mutual_recursion__tests__consecutive_optionals.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | e ''+'' e | ||
| | e e? ''..'' | ||
| | e ''..'' | ||
| | ''..'' | ||
| | ID |
8 changes: 8 additions & 0 deletions
8
...napshots/antlr4_rust_gen__grammar__mutual_recursion__tests__declared_order_preserved.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | e ''*'' e | ||
| | e ''+'' e | ||
| | ID |
12 changes: 12 additions & 0 deletions
12
...shots/antlr4_rust_gen__grammar__mutual_recursion__tests__external_satellite_retained.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| t: | ||
| | t ''['' '']'' | ||
| | t ''?'' | ||
| | ID | ||
| arr: | ||
| | t ''['' '']'' | ||
| new_arr: | ||
| | ''new'' arr |
9 changes: 9 additions & 0 deletions
9
...ar/snapshots/antlr4_rust_gen__grammar__mutual_recursion__tests__name_cycle_collapsed.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| name: | ||
| | name ''.'' simple_name | ||
| | simple_name | ||
| simple_name: | ||
| | ID |
9 changes: 9 additions & 0 deletions
9
...snapshots/antlr4_rust_gen__grammar__mutual_recursion__tests__optional_from_satellite.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | e ''+'' e | ||
| | e ''..'' e? | ||
| | ''..'' e? | ||
| | ID |
9 changes: 9 additions & 0 deletions
9
...hots/antlr4_rust_gen__grammar__mutual_recursion__tests__split_label_on_both_products.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | e ''+'' e #Add | ||
| | e ''..'' #Range | ||
| | ''..'' #Range | ||
| | ID #Atom |
9 changes: 9 additions & 0 deletions
9
...apshots/antlr4_rust_gen__grammar__mutual_recursion__tests__suffix_satellite_retained.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| e: | ||
| | e ''+'' ID s | ||
| | ID | ||
| s: | ||
| | e ''+'' ID |
10 changes: 10 additions & 0 deletions
10
...s/antlr4_rust_gen__grammar__mutual_recursion__tests__verbatim_alt_satellite_retained.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| source: src/bin_support/grammar/mutual_recursion.rs | ||
| expression: render(&unit) | ||
| --- | ||
| t: | ||
| | t ''['' '']'' | ||
| | t ''?'' arr | ||
| | ID | ||
| arr: | ||
| | t ''['' '']'' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
tests/fixtures/antlr4-rust-gen/mutual-left-recursion/DeclinedCycle.g4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // A mutual-left-recursion cycle the pass must DECLINE, not rewrite: the | ||
| // satellite's left corner is `b*`, so splicing a single satellite body in its | ||
| // place would silently drop the closure and change the accepted language. | ||
| // Declining leaves the grammar untouched, so the ATN-level G4A005 detector | ||
| // reports the cycle exactly as it does without the pass (issue #151). | ||
| grammar DeclinedCycle; | ||
|
|
||
| a : b* 'x' | 'a' ; | ||
| b : a 'b' ; | ||
|
|
||
| WS : [ \t\r\n]+ -> skip ; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.