[antlr-interest] Non-greedy lexer rule in ANTLR4

Terence Parr parrt at cs.usfca.edu
Sat Oct 13 09:21:36 PDT 2012


ah. true! we removed explicit greedy=false option so Bart's answer is best i guess.
T
On Oct 12, 2012, at 5:41 PM, Gavin Lambert wrote:

> I know, but "anything but CRLF |or| anything [except implicitly the '>>' terminator]" still sounds like it's going to swallow newlines.  While the first alt won't take them, the second alt would.
> 
> Unless it's doing something especially clever.
> 
> At 13:32 13/10/2012, Terence Parr wrote:
> >it's like an "else" clause as ambiguities resolve to first alt
> >specified.
> >T
> >On Oct 12, 2012, at 5:03 PM, Gavin Lambert wrote:
> >
> >> At 11:56 13/10/2012, Terence Parr wrote:
> >> >oh. if no newline and such what Bart suggests might be best.
> >maybe
> >> >'<<' (~[\r\n] | .)* '>>' which is nongreedy
> >>
> >> Doesn't the "." alt cancel out the first alt?
> 
> -- 
> Gavin Lambert, Mirality Systems
> <http://www.mirality.co.nz/>
> <http://lambert.geek.nz/>
> ----
> Anyone who goes to a psychiatrist ought to have their head examined.
> 
> Few women admit their age.  Few men act theirs.
> 



More information about the antlr-interest mailing list