[antlr-interest] Printing rule token range
dt05ca4 at student.lth.se
Wed Nov 28 01:29:42 PST 2007
I have a problem when printing the token range of the following constructs:
b_var = 10
My parser will generate 2 copies of the "enum" one for 'a'
Later in my tree grammar I want to print the corresponding tokens whenever
the constant_expression rule is invoked.(I will get 10 in the example
It works fine printing the 'a', but I only get -1 values
for the copy, and the expression end upp being null.
I use the following code to print the token interval for the expression rule:
int start = input.getTreeAdaptor().getTokenStartIndex($start);
int stop = input.getTreeAdaptor().getTokenStopIndex($start);
String text = input.getTokenStream().toString(start, stop);
So is there a way to solve this issue, it seems that there are some token
information missing when making copies like that?
I appreciate all help
More information about the antlr-interest