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
This is the first of a series of some ambiguities and improvements that I'm finding with the newest version of trparse with the --ambig option to display ambiguous parses.
The rule typeName is incorrect. It should have referenced packageOrTypeName, not packageName.
Although Antlr does a great job and rewriting left-recursion into kleene operators before running Thompson's Construction, it does not rewrite right recursion. Right recursion should not be used because it's inefficient because it causes a call to a sub-automaton in AdaptivePredict(). E.g., the NFA for packageName is:
For input with a method call System.out.println("s.x=" + s.x);, we have ambiguity on where to include .out. Should it be as a packageName or typeIdentifier?
We don't have a symbol table for the grammar to distinguish packages vs. types. Just get rid of packageName and typeName and just define a dotIdChain: identifier ('.' identifier)*;.
The text was updated successfully, but these errors were encountered:
This is the first of a series of some ambiguities and improvements that I'm finding with the newest version of trparse with the
--ambig
option to display ambiguous parses.Input: in.txt
Ambig trees:
typeName/packageName/packageOrTypeName
From the JLS20,
Notes
typeName
is incorrect. It should have referencedpackageOrTypeName
, notpackageName
.packageName
is:System.out.println("s.x=" + s.x);
, we have ambiguity on where to include.out
. Should it be as apackageName
ortypeIdentifier
?We don't have a symbol table for the grammar to distinguish packages vs. types. Just get rid of packageName and typeName and just define a
dotIdChain: identifier ('.' identifier)*;
.The text was updated successfully, but these errors were encountered: