[antlr-interest] Non-determinism clarification.
Bharath
bharath at starthis.com
Tue May 18 12:10:05 PDT 2004
Hi all,
I have a lexer rule of the form Time:
Time: ('T'|"TIME")(Integer);
It clashes with my "Identifier" rule, as expected. So, I did this:
Time: ('T'|"TIME"){$setType(IDENT);}
(Integer);
but it doesn't work. Is this wrong usage? I cant have the "Time" rule in my
parser because it would make "T" and "TIME" keywords and they are not.
If I try to make "Identifier" rule protected and add a third rule
IDENT_OR_TIME: (....)$setType(IDENT);(Integer)?{$setType(Time);} it still
doesn't work. (...) contains the general ('a'..'z') etc components that form
an identifier.
Any ideas?
Thanks!
Bharath.
-----Original Message-----
From: Mark Lentczner [mailto:markl at glyphic.com]
Sent: Tuesday, May 18, 2004 12:07 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] greedy/non-greedy problem.
On May 18, 2004, at 9:34 AM, jbb at acm.org wrote:
> Bharath :-
>
>> I replaced it with IDENT DOT IDENT DOT (IDENT (DOT IDENT)*)? And it
>> worked.
> But you do realize that the above rule recognizes a different
> language than your original rule?
He's right! I misread the original rule... I thought the trailing
IDENT was optional, but it isn't.... That's what I get for trying to
read my e-mail while my toddler is running around!
Jbb's solution is correct.
- Mark
Yahoo! Groups Links
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