You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Circular grammar inclusion causes stack overflow in the tool. #2296
The title says it all. If G1 includes G2 etc. ... which includes G1 then the antlr tool crashes with stack overflow. It should rather print out some error diagnostics.
Here is an example tested with the version 4.7.1 of the tool :
grammar G1;
import G2;
r : ;
grammar G2;
import G1;
r : ;
$ antlr G1.g4
Exception in thread "main" java.lang.StackOverflowError
at java.util.HashMap.hash(HashMap.java:339)
at java.util.HashMap.get(HashMap.java:557)
at org.antlr.v4.Tool.loadImportedGrammar(Tool.java:617)
at org.antlr.v4.tool.Grammar.loadImportedGrammars(Grammar.java:391)
at org.antlr.v4.tool.Grammar.loadImportedGrammars(Grammar.java:405)
at org.antlr.v4.tool.Grammar.loadImportedGrammars(Grammar.java:405)
at org.antlr.v4.tool.Grammar.loadImportedGrammars(Grammar.java:405)
at org.antlr.v4.tool.Grammar.loadImportedGrammars(Grammar.java:405)
........
Activity
Fixed antlr#2296
Fixed antlr#2296
Fixed antlr#2296
Fixed antlr#2296
Fixed #2296
KvanTTT commentedon Aug 31, 2022
@parrt it's fixed.