On 11/02/2010 12:16 PM, Amr Muhammad wrote:
> 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.
If I understand you correctly, yes. You can put an action block after
any matching token or sub-rule.
> Let's say I have the following grammar:
> ---------------------------------------------------------------
> block_rule: BLOCK block_name
{ // generate your block name stuff here }
> '{'
> property1_rule
>
> NEWLINE
>
> property2_rule
>
> '}'
{ // Then any remaining actions can go here (after propert1_rule and
property2_rule have been run }
> 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;
> -----------------------------------------
My suggestion should get you what you want.
> 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>
Good luck, happy parsing!
--
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/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.