[antlr-interest] Change token-type in AST

manuel aldana aldana at gmx.de
Wed Mar 29 11:14:55 PST 2006


hi,

i've got a problem with changing the type of an AST node. i am 
generating a python parser.

just the nitty part i am struggling with (abbreviated):

--------------------------------------
foo: IDENTIFIER IDENTIFIER
--------------------------------------

i am building an AST for that grammar.
if it comes to foo i want the first IDENTIFIER (-> any combination of 
letters) to change to a different token-type:

--------------------------------------
token{OTHER_TOKEN;}
....
foo: i:IDENTIFIER {i.setType(OTHER_TOKEN)} IDENTIFIER
--------------------------------------

unfortunately, if i build an AST and get to the respective node, its 
token-type is still IDENTIFIER :(.

my questions:
1)does the AST only take token-types which stand "directly" in the grammar?
2)does it go a different way to change token-type for an AST node?
3)(most likely not, but) could that be a bug?

thank you very much!!



-- 
  manuel aldana
  aldana at gmx.de
  aldana at cs.tu-berlin.de
	


More information about the antlr-interest mailing list