[antlr-interest] newbie lookahead question
Sam Barnett-Cormack
sdb at geekworld.co.uk
Sat Apr 22 05:27:16 PDT 2006
Lance Gutteridge wrote:
>> (now if we only had a way to specify synonyms in the tokens{...} section,
>> e.g. tokens{ TRUE="true","YES"; FALSE="false","NO"; } then life really
>> would
>> be easy ;-)
>
>
> Yes that would be a nice feature.
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