[antlr-interest] ANTLRWorks destroys its AST
John B. Brodie
jbb at acm.org
Fri May 11 20:15:20 PDT 2012
Summary: your abbreviation rule has 3 paths for recognition.
You have supplied '->' rules for only 2 of the paths.
On 05/11/2012 04:20 AM, Stephan Opfer wrote:
> Dear ANTLR-Interest Group,
> I have two grammars, which are almost the same and an example input: A &
> B | C & !A | (D | E) & F
> The first grammar works quite nice, the other grammar generates NIL as
> AST. However, next to the last step in debugging both grammars produced
> exactly the same ParseTree and exactly the same AST.
> Just after the consumption of <EOF> the other grammar throws the
> computed AST away.
because you have not told ANTLR what to do with that tree.
> Is it just a ANTLRWorks problem or does anybody know, what I am doing
> wrong. The only difference between the two grammars is the additional
> abbreviation rule.
( ( /* EMPTY */ -> $f1 )
| ( IMPLY f2=formula -> ^(OR ^(NOT $f1) $f2) )
| ( BIIMPLY f2=formula ->
^(AND ^(OR ^(NOT $f1) $f2) ^(OR ^(NOT $f2) $f1)) )
More information about the antlr-interest