[antlr-interest] Can this non-determinism be removed?
JVincent at Novell.Com
Mon Oct 27 11:35:47 PST 2003
I am building a run-time scripting language that can instantiate Java
classes and call methods on the objects (using reflection API). Today,
when a class type is specified, it has to be preceeded with the keyword
class java.lang.String s;
However, I want to change it so that the "class" keyword is not
required, and looks more like real java:
The problem is that the class name has the same format as class member
reference identifier and matches the rule.
IDENTIFIER^ ( arrayNotation )? ( DOT identifier )?
So the parser is nondeterministic at my start rule because
"java.lang.String" could either be part of a class instance declaration
or a class member reference statement. My parser's start rule is:
( ( d:declaration
Can predicates be used to remove this? I tried adding one at the start
rule, but my attempts failed. I can provide more information on other
rules in my parser, but I'm not sure what additional information is
needed, if indeed the ambiguity can be removed. It may be possible to
move the class declaration out of the declaration sub-rule and make it
part of the start rule, but I am hoping to keep all the declaration
rules together for clarity and readability.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest