Use a custom tree adaptor and write your rules like this:
foo
: ^(IMPL ^(OR x+=form+) y=form)
-> ^(AND[$IMPL] ^(AS_IMPL $x $y)+)
;
Then put the semantics to duplicate the information in the constructor
for your custom node type.
Sam
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bill Andersen
Sent: Thursday, November 13, 2008 2:02 PM
To: [EMAIL PROTECTED]
Subject: [antlr-interest] AST transforms - propagation of
semanticinformation
Folks,
Here's a fragment of a AST transformation grammar I'm working on
foo
: ^(IMPL ^(OR x+=form+) y=form)
-> ^(AND ^(AS_IMPL $x $y)+)
;
I want to keep certain semantic information on tree nodes. Figured
out already how to do this with custom node classes. What I want, in
the example of the rule above, is for the semantic information on the
root node (IMPL) to be automatically propagated to the output root
node (AND). Of course I can write actions in each such production to
do this, but I have a whole lot of productions like this and writing
all those actions is a maintenance problem.
Is there some way to do this pervasively, perhaps with a custom
TreeAdaptor? Thanks in advance.
bill
Bill Andersen
Ontology Works, Inc. (www.ontologyworks.com)
3600 O'Donnell Street, Suite 600
Baltimore, MD 21224
Office: +1.410.675.1201
Cell: +1.443.858.6444
Fax: +1.410.675.1204
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-addr
ess
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---