[antlr-interest] Tree construction with loops, children at same level
Marko Simovic
markobarko at gmail.com
Fri Apr 18 12:17:27 PDT 2008
heheh...not really. client preference. unless you have compelling
argument against?
thanks, that works. however, what does the @init block do?
-----Original Message-----
From: Jim Idle <jimi at temporal-wave.com>
To: antlr-interest <antlr-interest at antlr.org>
Subject: Re: [antlr-interest] Tree construction with loops, children at
same level
Date: Fri, 18 Apr 2008 11:29:22 -0700
Are you sure you want that? ;-)
unionFunction
@init
{
boolean multi = false;
}
: b+=byFunction
( (op=UnionOp b+=byFunction )+
-> ^($op $b+)
| -> $b
)
;
Assuming that UnionOp generates only one node, that should work for all
of them.
JIm
From:antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Marko Simovic
Sent: Friday, April 18, 2008 10:26 AM
To: antlr-interest
Subject: [antlr-interest] Tree construction with loops, children at same
level
So, given a rule like this:
unionFunction
: (byFunction -> byFunction)
(opNode=UnionOp b=byFunction -> ^(Function[$opNode] $unionFunction
$b) )*;
the following input:
a union b union c
creates a tree which consists of a union node with two children, one of
which is another union node (essentially "(a union b) union c").
what i want in such scenarios is to output a single union node with
three children. how is this done?
Thanks,
Marko
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.1/1385 - Release Date:
4/18/2008 9:30 AM
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.1/1385 - Release Date:
4/18/2008 9:30 AM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080418/3f8fc882/attachment.html
More information about the antlr-interest
mailing list