[antlr-interest] Keywords Vs Identifiers.
Bharath
bharath at starthis.com
Wed May 19 14:55:36 PDT 2004
Hi Monty,
I did. I figured a way out too but I am not sure if it's an efficient
solution. I set a rule in the parser which accepts an identifier and I
extracted the identifier input into a string. If the string is not "TIME", I
throw an exception, otherwise I accept it. (using getText() method).
Please let me know if this is bad practice.
Thanks!
Bharath.
-----Original Message-----
From: Monty Zukowski [mailto:monty at codetransform.com]
Sent: Wednesday, May 19, 2004 4:41 PM
To: antlr-interest at yahoogroups.com
Cc: Monty Zukowski
Subject: Re: [antlr-interest] Keywords Vs Identifiers.
See the documentation about "literals"
Monty
On May 19, 2004, at 8:25 AM, Bharath S wrote:
> Hi Antlers,
>
> I have some rules in my grammar, for time literals which require that
> 'TIME'
> or "time" be appended to the front of the rule. For eg., time can
> represented as TIME 99secs. The problem is, "TIME" is not a keyword
> and so I
> cant have it in the parser. If I throw it in the lexer, it causes a
> clash
> with IDENTIFIER rule, because the lexer sees the rule as
>
> TIME: 'T' 'I' 'M' 'E' (Integer) ; and
> IDENTIFIER: ('a'..'z'|'A'..'Z')+;
>
> as expected. Is there a common workaround for this?
>
> I can solve this problem by moving a whole bunch of rules in the
> parser back
> to the lexer, just to make the TIME rule protected. But it doesnt make
> sense, at all.
>
> Any comments are most welcome.
>
> Bharath.
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
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