[antlr-interest] Forcing creation of children in an AST tree parser

mzukowski at yci.com mzukowski at yci.com
Wed Mar 3 09:12:55 PST 2004


Show us toStringList() for the result of rule:

activityTimeRange: ACTIVITY^ L_paren! INSTRUMENT Comma! timeExpr
R_paren!;

It should be doing exactly what you want and I don't see why it isn't.

Monty

-----Original Message-----
From: Simon Kellett [mailto:skellett at anitesystems.de] 
Sent: Wednesday, March 03, 2004 1:24 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Forcing creation of children in an AST tree parser

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



 


 
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