[antlr-interest] Forcing creation of children in an AST tree parser
Simon Kellett
skellett at anitesystems.de
Wed Mar 3 01:23:47 PST 2004
Hi,
I am trying to force the creation of children within a rule that is
essentially parsing a function call:
activityTimeRange: ACTIVITY^ L_paren! INSTRUMENT Comma! timeExpr
R_paren!;
My AST correctly shows the ACTIVITY as a root and the parens and comma
dropped. But I would like the parameters (ie INSTRUMENT and timeExpr)
to be *children* of node ACTIVITY.
Reading the manual I have tried various things, but "AST Action
Translation" about "#rule", in the last para seems to give me what I
want: "For example, any children nodes added after the action will be
added to the children of #rule.".
But in the updated rule all I get is an extra "activityTimeRange" node
and no children, only siblings !!
activityTimeRange: ACTIVITY^ {#activityTimeRange =
#([ACTIVITY,"activityTimeRange"], #activityTimeRange);} L_paren!
INSTRUMENT Comma! timeExpr R_paren!;
Any ideas/pointers as to where I am going wrong ?
(would it be useful to have a force-to-child syntax ? (like "^" for
force-to-root and "!" for drop-token).
TIA, Simon
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list