[antlr-interest] accessing literal strings

Ric Klaren klaren at cs.utwente.nl
Fri Apr 16 08:36:03 PDT 2004


On Fri, Apr 16, 2004 at 11:36:00AM -0000, idontwantanidwith2000init wrote:
> How can I print all the literals defined in the parser/lexer?

In java mode there's the _tokenNames array in the generated parser. (should
list both lexer and parser tokens) In C++ mode there's some API calls for
it.

> another question less crucial:
> I'd like to keep with the literal its description, how can I do that?

Keep a map or vector of strings indexed by the token number (as returned by
getType() ?

> If I can't do it this way, is there a way to trick antlr and have 
> multiple literal sets so that cells with the same number will relate 
> to the same literal?

Not sure what you mean here. You can do some evil trickery with the
TokenTypes.txt files and importVocab however.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Chaos often breeds life, when order breeds habit.
  --- Henry B. Adams, The Education of Henry Adams



 
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