[antlr-interest] newbie lookahead question

Lance Gutteridge lance at thinkingworks.com
Mon Apr 24 09:05:04 PDT 2006


Ah the joy of literals.  I guess what John Brodie was saying orignally 
was that it would be nice to be able to specify a token that represented 
a group of synomyns in a simple way in the token section, so that one 
didn't have to produce a bunch of extra rules. I like that idea as it 
seems to me to be easier to read and easier to change when new synomyns 
present themselves.

Still you are right it can easily be done the way you suggest.

I'm finally getting on top of all my literals (maybe not joy, but 
satisfaction). Thanks to all of you who helped with my questions.

Lance

Sam Barnett-Cormack wrote:

>While that would be good, it kinda misses part of the joy of literals.
>That is to say, AIUI the reason they are called 'literals' is that the
>parser can then match them with the grammar only specifying the same
>literal. Thus, rather than the parser checking for TRUE, it can check
>for "true".
>
>In the above case, I'd use a subordinate parser rule, personally, like
>
>true
>  : "true"
>  | "YES"
>  ;
>
>Sam
>
>  
>


More information about the antlr-interest mailing list