warning:lexical nondeterminism between rules
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   John_Smith
Posted On:   Friday, May 28, 2004 01:34 AM

Hi! I am trying to create a parser with ANTLR Parser Generator 2.7.3. The grammar file contains this: class XParser extends Parser; start : EOF ; class XLexer extends Lexer; options { k=2; charVocabulary = 'u0003'..'u00ff'; } IDENTIFIER : NONDIGIT (NONDIGIT | DIGIT)* ; protected NONDIGIT : 'a'..'z' | 'A'..'Z' | '_' ; protected DIGIT : '0'..'9' ; CHARACTER_LITERAL : ('L')? '\'' C_CHAR_SEQUENCE '\'' ; protected    More>>

Hi!


I am trying to create a parser with ANTLR Parser Generator

2.7.3. The grammar file contains this:


class XParser extends Parser;



start : EOF

;



class XLexer extends Lexer;

options { k=2; charVocabulary = 'u0003'..'u00ff'; }



IDENTIFIER : NONDIGIT (NONDIGIT | DIGIT)*

;



protected

NONDIGIT : 'a'..'z'

| 'A'..'Z'

| '_'

;



protected

DIGIT : '0'..'9'

;



CHARACTER_LITERAL : ('L')? '\'' C_CHAR_SEQUENCE '\''

;



protected

C_CHAR_SEQUENCE : (C_CHAR)+

;



protected

C_CHAR : ~('
' | '
' | '"' | '\\' | '\'' )

;



When I try to compile it with the antlr it generates the

following warning message:


ANTLR Parser Generator Version 2.7.3 1989-2004 jGuru.com

X-Grammar.g: warning:lexical nondeterminism between rules DENTIFIER and CHARACTER_LITERAL upon

X-Grammar.g: k==1:'L'

X-Grammar.g: k==2:'0'..'9','A'..'Z','\\','_','a'..'z'


I don't understand why it writes this out. I think the antlr

must be able to choose between the two rules becouse the
CHARACTER_LITERAL starts with 'L' or '\'' character. And if it starts with 'L' then the second character must be '\''.


When I had replaced the '\'' with '[' the warrning
dissapeared. That's why I think that it is a bad warning.

I would be very happy If somebody could solve this misterious problem. :)


Thanks,

J.S.

   <<Less
About | Sitemap | Contact