[antlr-interest] Code Generation Instruction Ordering / Order of Execution of Rules Actions
Amr Muhammad
amr.muhammad.w at gmail.com
Tue Nov 2 09:16:41 PDT 2010
Hello,
I was wondering if it is possible to execute actions for rules, that calls
other rules, before executing the actions for the rules, that were called.
Let's say I have the following grammar:
---------------------------------------------------------------
block_rule: BLOCK block_name
'{'
property1_rule
NEWLINE
property2_rule
'}' { // generate block of statements say s3 } ;
property1_rule: property1= value1 { // generate block of statements say s1 }
;
property2_rule: property2= value2 { // generate block of statements say s2 }
;
block_name: ID;
property1: ID;
value1: ID;
property2: ID;
value2: ID;
---------------------------------------------------------------
I would want the actions for rule block_rule to get executed before the
actions of property1_rule or
property2_rule
I am trying to do sth like:
-----------------------------------------
block_object block_name;
block_name.property1= value1;
block_name.property2= value2;
-----------------------------------------
but what i get is:
-----------------------------------------
block_name.property1= value1;
block_name.property2= value2;
block_object block_name;
-----------------------------------------
Just in case it matters, what i am actually doing is using the parser
grammar to generate an AST, and then using a tree grammar to walk the tree.
Thank you for your time :)
Best Regards,
Amr Muhammad
Cairo Univ. Computer Eng. Grad.
twitter:@amrmuhammad <http://twitter.com/amrmuhammad>
More information about the antlr-interest
mailing list