[antlr-interest] Breaking a loop

John Green greenj at ix.netcom.com
Sun Nov 6 12:28:19 PST 2005


Hi Bryan,

Actually, the io_opt rule must be entered in order to build the correctly shaped tree. In other words, the tokens matched by "." are flat siblings in the tree, but some of the productions in io_opt create some parent/child branches in the tree.

Cheers,
John


Bryan Ewbank wrote:
> Correct me if I'm wrong, or if the example was over-simplified, but
> isn't this equivalent?
> 
>    ( ( state_end ) => state_end { break; }
>    | .
>    )*
> 
> No need to chew through the (io_opt)* because it will /always/ match
> just before a state_end.
> 
> It's still the same fundamental problem, but it is perhaps easier to
> think about...
> 
> On 11/4/05, John Green <greenj at ix.netcom.com> wrote:
>> I've got a pre-existing language with a requirement like this:
>>
>>     (    ( (io_opt)* state_end )=> (io_opt)* state_end {break;}
>>     |    .
>>     )*
>>
> 
> 




More information about the antlr-interest mailing list