[antlr-interest] Breaking a loop
Terence Parr
parrt at cs.usfca.edu
Fri Nov 4 18:04:01 PST 2005
On Nov 4, 2005, at 2:35 PM, John Green wrote:
>
> Terence Parr wrote:
>> Does anything follow the loop that signals when to break? You
>> could use a greedy=false loop then.
>
> Unfortunately, no. Any of the tokens in io_opt could also appear in
> the arbitrary token list (consumed by ".").
>
> ( ( (io_opt)* state_end )=> (io_opt)* state_end {break;}
> | .
> )*
>
> It's only the syntax represented by ((io_opt)* state_end) which
> signals when to break.
>
> (Yes, it's an ugly language, obviously implemented with an LR parser.)
Yep, we need a "not" syn pred ala Bryan Ford's PEG parser expression
grammars.
>
> The {break;} hack seems to work (with my quick regression tests,
> anyway), but the obvious concern is that a future change to Antlr's
> C++ code gen could mess up its effect. And I sure don't want to
> fall behind on Antlr versions. :)
True, though the v2 version will stay as it is for a *long* time as
I'm moving forward with v3.
Ter
More information about the antlr-interest
mailing list