[antlr-interest] Breaking a loop
John Green
greenj at ix.netcom.com
Fri Nov 4 14:35:43 PST 2005
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.)
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. :)
More information about the antlr-interest
mailing list