[antlr-interest] lexing multiple literals to one token
Robert Anderson
randerson110 at gmail.com
Fri Jul 29 15:42:21 PDT 2005
On 7/29/05, Ric Klaren <ric.klaren at gmail.com> wrote:
> Robert Anderson wrote:
> > I want to lex two different (interchangeable) keywords into the same
> > token. I want to use the tokens {..} mechanism because I want both of
> > these to be considered by a testLiterals=true identifier rule option.
> > How do I do this? The following don't seem to work:
>
> You can't with the tokens section, that one is moved to a hashtable/map.
> So the following are all invalid syntax:
...
> > tokens {
> > MYTOK = ("form1"|"form2");
> > }
> You can a move it in the id rule and do a manual check in action code
Thank you. (Another list reader also pointed me to this solution.)
However, this strikes me as an awkward solution to a simple,
straightforward task.
In the spirit of "simple things should be simple" I suggest the form I
left above as a supported feature of the tokens {...} block.
Thanks,
Bob
More information about the antlr-interest
mailing list