Cine
Cine

Reputation: 4392

antlr3 NOT rule

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?

Upvotes: 2

Views: 89

Answers (1)

Cine
Cine

Reputation: 4392

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^;

Upvotes: 3

Related Questions