[antlr-interest] Re: unexpected AST node
Bryan Ewbank
ewbank at gmail.com
Tue Feb 28 09:00:18 PST 2006
The problem is in your main program - you are calling the tree parser
three times for the input, and only the first call can accept a "+"
node. The other calls fail because the root node of the tree is "+".
For logical not, "!", the trick is to use right-recursion:
not_expr
: NOT^ not_expr
| bexpr
;
This will form the necessary tree for correct evaluation
On 2/28/06, Zara Jane Sheil <zara.sheil at ucdconnect.ie> wrote:
> Also, when I give it input 3+4 it can return the value 7 but gives an error:
> <AST>:0:0: unexpected AST node: +
> false
> <AST>:0:0: unexpected AST node: +
> false
> This happens for all input. Im not sure if there's something wrong with the
> grammar or my Main file.
More information about the antlr-interest
mailing list