[antlr-interest] imaginary node problem

Damir Franusic damir.franusic at gmail.com
Tue Sep 21 15:38:07 PDT 2010


First of all Hi to everybody, This is my first email here, I have just
recently started using ANTLR. I'm working on some DSL and since i haven't
got any experience with antlr, i have stumbled across some issues.
I am trying to use "rewrite rules" to create a nice two dimensional AST. I
have declared couple of imaginary nodes but what happens is when i for
example do something like:

rule
  : L_SQ_B ANNT (ra=ON | ra=OFF) R_SQ_B COLON RULE L_SQ_B d=DIGITS* R_SQ_B
WS* curlyblock
  -> ^(RULE_NODE $ra)
  ;


This create an imaginary node and then on the outer rule(the one that gets
called last) i am trying to add a root node and assign this RULE_NODE to
that root node:

input
  : (filter)* EOF
  -> ^(ROOT_NODE RULE_NODE)
  ;


..and after this I end up with ROOT_NODE and just a new/blank RULE_NODE. How
do these nodes work? Do they oney work once and get rewritten when you use
them twice? You get my point I hope

Thanks,
Damir


More information about the antlr-interest mailing list