[antlr-interest] Breaking a loop

Bogdanov, Serge serge.bogdanov at intel.com
Mon Nov 7 03:58:32 PST 2005


You would need a recursive rule to do something like that:

my_loop:
	io_opt my_loop
	|state_end
	;

>> Sergey Bogdanov
intel massachusetts
M/S HD2-246
77 Reed Road, 
Hudson, MA  01749
Tel: (978)553-2724
>-----Original Message-----
>From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>bounces at antlr.org] On Behalf Of John Green
>Sent: Friday, November 04, 2005 16:14
>To: ANTLR Interest
>Subject: Re: [antlr-interest] Breaking a loop
>
>The semantic predicate would be awful complex, since it would have to
check
>for:
>  (io_opt)* state_end
>In other words, I'd have to hand-code a syntactic predicate into the
>semantic predicate.
>
>
>Terence Parr wrote:
>> Add a semantic predicate in front of alt(s) that says when to break
:)
>> Ter
>> On Nov 4, 2005, at 10:43 AM, John Green wrote:
>>
>>> I've got a pre-existing language with a requirement like this:
>>>
>>>    (    ( (io_opt)* state_end )=> (io_opt)* state_end {break;}
>>>    |    .
>>>    )*
>>>
>>> Hopefully my question is obvious from the example. I need to break
the
>>> loop when I hit a certain production. Until that production is
>>> reached, arbitrary tokens are consumed by the ".". Assuming {break;}
>>> is a bad hack, what's a good way to do this in Antlr?
>>>
>>> Cheers,
>>> john at joanju dot com
>>>
>>
>>
>>
>



More information about the antlr-interest mailing list