[antlr-interest] [v3] any way to increment the token integer values

Mark Mandel mark.mandel at gmail.com
Mon Jun 25 21:29:54 PDT 2007


Heya,

This may seem like a weird question, but -

When the Lexer and Parser are generated, we get code in the header:

    public static final int FUNCTION=29;
    public static final int WHILE=36;
    public static final int LETTER=50;

etc.

But I do a lot of island parsing, so what may be LETTER=50 on one
Parser, it may be ID=50 in another, but both Token types will end up
on the same AST.

I'm wondering if there is a way I can tell the code generator to
increment the integer values of the Tokens that are generated?

That way I could have all my island parsers Token's be from 1000+, and
I have no fear of the values overlapping, and trying to resolve Token
types from my AST becomes a lot simpler.

I hope this makes sense,

Thanks in advance,

Mark

-- 
E: mark.mandel at gmail.com
W: www.compoundtheory.com


More information about the antlr-interest mailing list