[antlr-interest] How to stop automatic evaluation in Tree Grammar?

轶凡 yifan.cby at taobao.com
Thu Sep 22 07:47:31 PDT 2011


Hi, gurus, I defined a tree grammar which contains if statements, it looks like below:

ifs: ^(IF test elseif_part else_part) ;

In normal, this rule will generate source code as below:

test(); //it will return a boolean value
....
elseif_part();
....
else_part();

As you see, if the rule 'test' is ok in some conditions, there's no need to evaluate rule 'elseif_part' and 'else_part'.
What I need is conditional tree node expansion. Ideally generated code in my mind:

if (test())
{
 //skip elseif_part and else_part
}else{
  elseif_part();
  if (some condition was satisfied){
    //skip else_part;
  }else{
    else_part();
  }
}

Hope for you help, thanks!


This email (including any attachments) is confidential and may be legally privileged. If you received this email in error, please delete it immediately and do not copy it or use it for any purpose or disclose its contents to any other person. Thank you.

本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。


More information about the antlr-interest mailing list