[antlr-interest] embedding Java codes to grammar problem

Fırat KÜÇÜK firatkucuk at gmail.com
Sun Jun 3 23:24:19 PDT 2007


what about "while statement" situation?

2007/6/4, Panayiotis <panayk at gmail.com>:
> I'm not sure I understand what you want to do, but would the following work?
>
> sample_rule
>     :    SOME_TOKEN bla_bla_rule ({1 == 1}? another_rule)?
>     ;
>
> This will parse 'SOME_TOKEN' followed by 'bla_bla_rule' and then,
> depending on the truth value of the semantic predicate '1 == 1', it will
> try to parse an optional 'another_rule'.
> A related syntax is {1 == 1}?=>.
>
> Panayiotis
>
> Fırat KÜÇÜK wrote:
> > any solution?
> >
> > 2007/6/1, Fırat KÜÇÜK <firatkucuk at gmail.com>:
> >> hi,
> >>
> >> for instance my treeparser rule is
> >>
> >>
> >> sample_rule
> >>     :   ^(SOME_TOKEN
> >>             bla_bla_rule
> >>             { if (1 == 1) { }
> >>             another_rule_should_be_in_if_statement
> >>             {  }  }
> >>         )
> >>      ;
> >>
> >>
> >> "another_rule_should_be_in_if_statement" rule should be in "if (1==1)
> >> {}" statement.
> >> What should i do?
> >>
> >> --
> >> Öğr. Gör. Fırat KÜÇÜK
> >> ADAMYO Distance Learning
> >> SAKARYA University / TURKEY
> >>
>


-- 
Öğr. Gör. Fırat KÜÇÜK
ADAMYO Distance Learning
SAKARYA University / TURKEY


More information about the antlr-interest mailing list