2
negExpression   :   (NOT^)* primitiveElement    ;

Is the rule I have. I now have this code:

!!(1==1)

I expected I would end up with this tree:

NOT
 |
NOT
 |
 ==
/  \
1  1

However, in Antlr3, it seems the tree ends up like

  NOT
 /   \
NOT  ==
    /  \
    1  1

IE. I end up with the second NOT having no children, instead the child node it should have, has become its sibling node.

What am I doing wrong?

Cine
  • 4,255
  • 26
  • 46

1 Answers1

3

And as I wrote the question, it came to me that my rule was perhaps wrong. And indeed, this one does exactly what I expected.

negExpression : NOT^ negExpression | primitiveElement^;
Cine
  • 4,255
  • 26
  • 46