[antlr-interest] How to do iteration in Tree Grammar
Bart Kiers
bkiers at gmail.com
Thu Sep 22 00:22:43 PDT 2011
Hi Yifan,
How about something like this:
foo: ^(VIRTUAL_NODE (bar {if($bar.value) return;})* );
?
Regards,
Bart.
2011/9/22 轶凡 <yifan.cby at taobao.com>
> Hi, I defined a tree grammar as below:
>
> foo: ^(VIRTUAL_NODE bar*) {
> echo($bar.value);
> };
>
> bar returns [boolean value] : //… Omitted
>
> The generated source of rule foo is like below:
>
> public final void foo() throws XX
> {
> boolean bar40 = false;
> do{
> //omitted
> bar40=bar();
> //omitted
> }while (true)
> echo(bar40)
> }
>
> Actually in the rule ‘foo’, I want to do some actions against every ‘bar’,
> not the final bar’s value, code in imagination:
>
> public final void foo() throws XX
> {
> boolean bar40 = false;
> do{
> //omitted
> bar40=bar();
> if (bar40){
> echo(bar40);
> return;
> }
> //omitted
> }while (true)
> echo(bar40)
> }
> How to change the rule ‘foo’ to archive my goal?
>
> Thanks for your help!
>
> ________________________________
> 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.
>
>
> 本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list