[antlr-interest] Evaluator bailing out early?

Olivier Lefevre lefevrol at yahoo.com
Mon Feb 18 19:03:33 PST 2008


If in tour/trees/Eval.g (I am referring to the book examples) you comment 
out, say, the part about assignments (central 2 lines of stat rule) and 
then you feed to the evaluator sample input containing an assignment, 
everything after that assignment (including the assignment itself) will be 
ignored or at least it seems so because there is no printout anymore from 
System.out.println($expr.value). I am attaching the grammar for reference.
A sample input would be

20
(+ 22 30)
(- 21 30)
(= a 3)
30
(+ 2 4)

Everything after (= a 3) will be ignored. It looks as if the evaluator is 
bailing out at the first ummatched AST node, which is surprising behaviour: 
I would have expected an error.

-- O.L.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Eval.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20080219/a483f310/attachment.pl 


More information about the antlr-interest mailing list