[antlr-interest] Nondeterminism warnings upon Lexer and Grammar
Scott Amort
jsamort at gmail.com
Tue Jul 25 15:22:25 PDT 2006
Hi,
Herumor wrote:
> ANTLR Parser Generator Version 2.7.6 (2005-12-22) 1989-2005
> error: Lexer rule ESC is not defined
To begin, you are missing an ESC rule. Presumably you copied this from
some outside source, but neglected to copy the referenced rule.
> EasyJavaLexer.g: warning:lexical nondeterminism between rules
> AccessSpecifier an
> d ReturnType upon
> EasyJavaLexer.g: k==1:'f','s','v'
> EasyJavaLexer.g: k==2:'o','y'
> EasyJavaLexer.g: k==3:'a','i','l','n','o','t'
> EasyJavaLexer.g: k==4:'a'
> EasyJavaLexer.g: warning:lexical nondeterminism between rules
> AccessSpecifier an
> d Type upon
> EasyJavaLexer.g: k==1:'f','s'
> EasyJavaLexer.g: k==2:'o','y'
> EasyJavaLexer.g: k==3:'a','l','n','o','t'
> EasyJavaLexer.g: k==4:'a'
> EasyJavaLexer.g: warning:lexical nondeterminism between rules ReturnType
> and Typ
> e upon
> EasyJavaLexer.g: k==1:'b'..'d','f','i','l','s'
> EasyJavaLexer.g: k==2:'h','l','n','o','y'
> EasyJavaLexer.g: k==3:'a','l','n','o','t','u'
> EasyJavaLexer.g: k==4:<end-of-token>,'a','b','e','g','r'
> Exiting due to errors.
> [/code]
Here, I think your best bet is to just keep an identifier rule in the
lexer, and put your literals in the parser. A couple of items of
interest: I believe you should have all of your lexer rules uppercase
(i.e. IDENTIFIER, not Identifier); and, why have you broken up your
literals (i.e. "publ" "ic")?
Best,
Scott
More information about the antlr-interest
mailing list