[antlr-interest] tree walker executes method call twice?
Rob Dougan
rob_dougan at sympatico.ca
Tue Aug 18 11:53:34 PDT 2009
during testing i noticed that my tree walker seems to be walking the tree twice ...
tree grammar t.g
prog : stat+
;
stat
@init { Console.Out.WriteLine("INTO stat"); }
@after { Console.Out.WriteLine("OUTOF stat"); }
: exprRoot
;
exprRoot
@init { Console.Out.WriteLine("INTO exprRoot"); }
@after { Console.Out.WriteLine("OUTOF exprRoot"); }
: ^(EXPR expr)
;
expr
@init { Console.Out.WriteLine("INTO expr"); }
@after { Console.Out.WriteLine("OUTOF expr"); }
: ID
| call
;
call
@init { Console.Out.WriteLine("INTO call"); }
@after { Console.Out.WriteLine("OUTOF call"); }
: ^(CALL ID exprList?)
{
Console.Out.WriteLine("--------in call");
}
;
exprList
: ^(EXPRLIST .*)
| EXPRLIST
;
my program is just one statement, one function call
input:
myfunc(x);
trace:
INTO stat
INTO exprRoot
INTO expr
INTO call
INTO expr
OUTOF expr
-------------in call myfunc
OUTOF call
OUTOF expr
OUTOF exprRoot
OUTOF stat
and then it does it again ...
INTO stat
INTO exprRoot
INTO expr
INTO call
INTO expr
OUTOF expr
-------------in call myfunc
OUTOF call
OUTOF expr
OUTOF exprRoot
OUTOF stat
anyone spot a grammar problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090818/a6c65a69/attachment.html
More information about the antlr-interest
mailing list