[antlr-interest] Tree rewrite rule problem

Nilo Roberto C Paim nilopaim at gmail.com
Mon Sep 24 19:48:53 PDT 2012


Hi, all.

 

I have the following rule on my grammar:

 

expr

  :

  i1=ID

  (

    compOp boolOp

      ->

        ^(BOOLEXPR $i1 compOp boolOp)

    | (NOT)? NUMERIC

      ->

        ^(BOOLEXPR $i1 NOT? NUMERIC)

    |

      ->

        ^(BOOLEXPR $i1)

  )

  ;

 

Problem: the parsing  is done correctly, but the resulting tree contains
only the imaginary node BOOLEXPR, with no children. If I put a
System.out.println as action for the alternatives, It shows me correctly,
but anyway, the tree is corrupt. 

 

Any hints?

 

TIA.

 

Nilo - Brazil



More information about the antlr-interest mailing list