[antlr-interest] AST transforms - propagation of semanticinformation
Sam Harwell
sharwell at pixelminegames.com
Thu Nov 13 13:44:18 PST 2008
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: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bill Andersen
Sent: Thursday, November 13, 2008 2:02 PM
To: antlr-interest at antlr.org
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/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess
More information about the antlr-interest
mailing list