[antlr-interest] Re: probably too obvious to see it - plz help

tdjastrzebski tdjastrzebski at yahoo.com
Thu Jul 31 17:53:31 PDT 2003


It should choose StringLiteral when 'n' is followed by '\''.
So how do I fix it ?
Tom Jastrzebski

--- In antlr-interest at yahoogroups.com, mzukowski at y... wrote:
> So if it sees "n" which rule is it supposed to choose?  You need to 
handle
> the two possibilities prefixed with 'n' in one rule.
> 
> Monty
> 
> -----Original Message-----
> From: tdjastrzebski [mailto:tdjastrzebski at y...] 
> Sent: Thursday, July 31, 2003 4:14 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] probably too obvious to see it - plz help
> 
> 
> I ma probably too tireed to see it. Why following two lexer rules 
> cause nondeterminism (k=2).
> 
> Identifier
> 	: ('a'..'z')+
> 	;
> StringLiteral
> 	: ('n')? '\'' (~'\'')* '\''
> 	;
> 
> StringLiteral rule is supposed to match unicode strings like: 
> n'blabla'
> 
> Thanks in advance.
> Tom Jastrzebski
> 
> full test grammar:
> 
> options {
> 	language = "Java";
> }
> 
> class TestParser extends Parser;
> options {
> 	k = 2;
> }
> 
> expression
> 	: (Identifier | StringLiteral) EOF
> 	;
> 
> class TestLexer extends Lexer;
> options {
>     k = 2;
> }
> 
> Identifier
> 	: ('a'..'z')+
> 	;
> 
> StringLiteral
> 	: ('n')? '\'' (~'\'')* '\''
> 	;
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list