[antlr-interest] action execution at the rule prediction stage

Xie, Linlin linlin.xie at siemens.com
Sat Apr 25 11:49:29 PDT 2009


Dear All,

 

I have a question about the time of execution of the actions put inside
or at the end of the rules. I can see from the generated lexer or parser
code that the actions (at the end of the rule) are inserted after the
match of the whole rule. But I would like to know if any actions (in the
middle or at the end) would be executed before the match of the rule?
i.e. at the Look Ahead (Prediction) stage, would the match of a part of
the rule trigger any actions of the subrule matched? 

 

For example:

 

Rule : Rule1| Rule2;

Rule1 : Rule3* Rule4;

Rule2 : ( Rule3 Rule3 )* Rule5;

Rule3 : AnyRule { AnyAction; };

Rule4 : xxx;

Rule5 : yyy;

 

When trying to find out if the input matches Rule1 or Rule2, will the
AnyAction be executed? Or if the action is in the middle of the rule,
will it be executed before the match of the full rule?

 

I haven't found out any theoretical confirmation from the book, so would
like to ask if anybody can confirm how it works.

 

Thanks.

Linlin

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090425/de7b9c9a/attachment.html 


More information about the antlr-interest mailing list