1

I want to set root for AST in this grammar:

boolexp     : relexp op=(AND | OR)^ boolexp
        | relexp
        ;

but get this error:

'^' came as a complete surprise to me

What is the cause?

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
user3758844
  • 11
  • 1
  • 5

1 Answers1

0

If this is ANTLR 4, the AST operators have been removed in favor of automatic parse tree construction.

If this is ANTLR 3, you may need to move your labels inside the parentheses, like the following.

boolexp     : relexp (op=AND | op=OR)^ boolexp
        | relexp
        ;
Sam Harwell
  • 97,721
  • 20
  • 209
  • 280