[antlr-interest] Conditional rewrite question

Sean Walton swalton at cs.utah.edu
Fri Aug 4 09:57:51 PDT 2006


Does anyone know how to do a conditional rewrite?  For example:

stdc_Statement
    : stdc_LabeledStatement -> ^(STATEMENT stdc_LabeledStatement)
    | ('atomic')? stdc_CompoundStatement
    | ('atomic')? stdc_ExpressionStatement
    | ('atomic')? stdc_SelectionStatement
    | ('atomic')? stdc_IterationStatement
    | stdc_JumpStatement
    ;

I would like to make the next case (stdc_CompoundStatement) return a 
head node "STATEMENT" and "ATOMIC_STATEMENT" when it is declared 'atomic'.

-Sean


More information about the antlr-interest mailing list