[antlr-interest] Operator tree construction in rewrite syntax
Terence Parr
parrt at cs.usfca.edu
Tue Apr 15 12:47:39 PDT 2008
On Apr 15, 2008, at 12:41 PM, Gavin Lambert wrote:
> At 04:20 16/04/2008, Marko Simovic wrote:
>> also, while we're on the subject, what about a rewrite syntax of
>> this one:
>>
>> unary: (UnaryOp^)? something;
>
> That one's simpler, because there aren't any loops (so no need to
> generate multiple trees):
>
> unary
> : UnaryOp s1=something -> ^(UnaryOp $s1)
> | s2=something -> $s2
> ;
or
unary
: UnaryOp something -> ^(UnaryOp something)
| something
;
in 2nd alt, ANTLR just adds to tree.
Ter
More information about the antlr-interest
mailing list