[antlr-interest] [v3] any way to increment the token integer values
Terence Parr
parrt at cs.usfca.edu
Tue Jun 26 00:10:46 PDT 2007
On Jun 26, 2007, at 2:29 PM, Mark Mandel wrote:
> 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.
Perhaps just import the other tokens into the island grammar so they
are disjoint.
Ter
More information about the antlr-interest
mailing list