[antlr-interest] My first tree walker
Simon Manschitz
simon.werbung at gmx.de
Fri Dec 10 05:56:29 PST 2010
Hi,
i am trying to walk over a tree with this forum (tree.toTreeString-Method):
(function (OUTPUT output) (NAME test2) (INPUT input) (= output (- 4 input)))
My tree walker looks like this:
tree grammar MatlabTreeWalker;
options {
language = Java;
tokenVocab = Matlab;
ASTLabelType = CommonTree;
}
walk: ^(FUNCTION
function_output
function_name
function_input
expression);
function_output: ^(OUTPUT IDENT);
function_name: ^(NAME IDENT);
function_input: ^(INPUT IDENT);
expression:
^('=' expression expression) { System.out.println("t1"); }
| ^(MINUS o1=expression o2=expression) { System.out.println("t2"); }
| IDENT { System.out.println("t3"); }
| REAL_NUMBER { System.out.println("t4"); };
But i always receive this error: MatlabTreeWalker.g: node from line 1:0
mismatched tree node: function expecting FUNCTION. Has anyone an idea
why i get this error? FUNCTION is a lexer rule FUNCTION: 'function'; I
think he has problems to find the (OUTPUT IDENT) but i have no idea why?
Can somebody help me?
Bye, Simon.
More information about the antlr-interest
mailing list