[antlr-interest] Conditional rewrite question
Terence Parr
parrt at cs.usfca.edu
Fri Aug 4 10:11:03 PDT 2006
Hi Sean,
on page:
http://www.antlr.org/wiki/display/ANTLR3/Tree+construction
I have a section that uses a predicate on the rewrites:
variableDefinition
: modifiers typename ID ('=' completeExpression)? ';'
-> {inMethod}? ^(VARIABLE ID modifiers? typename completeExpression?)
-> ^(FIELD ID modifiers? typename completeExpression?)
;
Ter
On Aug 4, 2006, at 9:57 AM, Sean Walton wrote:
> 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