-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape reserved words during grammar generation, fixes #1070 (for -> …
…for_ but RULE_for) Deprecate USE_OF_BAD_WORD
- Loading branch information
Showing
36 changed files
with
560 additions
and
667 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...suite/resources/org/antlr/v4/test/runtime/descriptors/LexerExec/ReservedWordsEscaping.txt
This file contains 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,23 @@ | ||
[notes] | ||
https://github.com/antlr/antlr4/issues/1070 | ||
|
||
[type] | ||
Lexer | ||
|
||
[grammar] | ||
lexer grammar L; | ||
|
||
channels { break } | ||
|
||
A: 'a' -> mode(for); | ||
|
||
mode for; | ||
B: 'b' -> channel(break); | ||
|
||
[input] | ||
ab | ||
|
||
[output] | ||
[@0,0:0='a',<1>,1:0] | ||
[@1,1:1='b',<2>,channel=2,1:1] | ||
[@2,2:1='<EOF>',<-1>,1:2] |
35 changes: 35 additions & 0 deletions
35
...uite/resources/org/antlr/v4/test/runtime/descriptors/ParserExec/ReservedWordsEscaping.txt
This file contains 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,35 @@ | ||
[notes] | ||
https://github.com/antlr/antlr4/issues/1070 | ||
|
||
[type] | ||
Parser | ||
|
||
[grammar] | ||
grammar G; | ||
|
||
root | ||
: {0==0}? continue+ {<writeln("$text")>} | ||
; | ||
|
||
continue | ||
: for for? {1==1}? #else | ||
| break=BREAK BREAK+ (for | IF) #class | ||
| if+=IF if+=IF* #int | ||
| continue CONTINUE #static | ||
; | ||
|
||
for: FOR; | ||
FOR: 'for_'; | ||
BREAK: 'break_'; | ||
IF: 'if_'; | ||
CONTINUE: 'continue_'; | ||
|
||
[start] | ||
root | ||
|
||
[input] | ||
for_for_break_break_for_if_if_for_continue_ | ||
|
||
[output] | ||
"""for_for_break_break_for_if_if_for_continue_ | ||
""" |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.