[antlr-interest] Simple grammar tree problem
Gavin Lambert
antlr at mirality.co.nz
Sat Apr 18 18:29:54 PDT 2009
At 08:55 19/04/2009, Martijn Reuvers wrote:
>In fact it does that it prints out the ast tree:
> (TEST %where% (= name "hello")), see the @after in the
>grammer. But when I run the following testcode:
[...]
>And then on the input enter: %where% name="hello", it says:
>src/antlr/basic/test06/TreeSqlUpper.g: node from line 1:13 no
>viable alternative at input '='
[...]
>where_statement
> : ^(TEXT comp_oper STRTEXT optional_where?)
> | ^(TEXT KEYWORD_NOT_LIKE STRTEXT optional_where?)
> | ^(TEXT KEYWORD_LIKE STRTEXT optional_where?)
> ;
There's your problem. Your tree grammar is expecting the TEXT to
be the root of the subtree, but in the actual AST the operator is
the root instead. You should modify the tree grammar accordingly.
More information about the antlr-interest
mailing list