[antlr-interest] Lexer confusion
Monty Zukowski
monty at codetransform.com
Wed May 26 22:20:40 PDT 2004
On May 26, 2004, at 8:23 PM, FranklinChen at cmu.edu wrote:
> WORD
> :
> 'A'
> (
> HYPHEN
> 'A'
> )*
> ;
> the generated code goes into WORD,
> sees HYPHEN, and then wants an 'A' and bombs out because there isn't
> any.
Yes, that is exactly as you have specified the WORD rule. If you see
an A followed by a HYPHEN it must be followed by A.
This may be something not so obvious with antlr's approximate lookahead.
Try this:
WORD
:
'A'
( (HYPHEN 'A')=>
HYPHEN
'A'
)*
;
That will give a warning about a superflous syntactic predicate, but it
should work.
Monty Zukowski
ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit --
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list