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

mzukowski at yci.com mzukowski at yci.com
Mon Aug 4 09:12:56 PDT 2003


That looks good to me.

Monty

-----Original Message-----
From: Matt Benson [mailto:gudnabrsam at yahoo.com] 
Sent: Friday, August 01, 2003 10:21 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] Re: probably too obvious to see it - plz help


This is probably not the best way, but it works.  I
added a semantic predicate to the IDENTIFIER rule:

IDENTIFIER
	: {LA(2) != '\''}? ('a'..'z')+
	;

-Matt

--- tdjastrzebski <tdjastrzebski at yahoo.com> wrote:
> 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/
> 
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

 

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