[antlr-interest] .* consuming all input

Oliver Zeigermann oliver.zeigermann at gmail.com
Thu Jun 3 02:09:06 PDT 2010


Hi, I am pretty sure wildcards are *greedy* by default and you have to
switch on non-greediness. I seem to remember this should look like:

(options {greedy=false;}:.)*

- Oliver

2010/6/3 George Soom <george.soom at siria.cc>:
>
> Hi,
> according to documentation wildcards are non-greedy in ANTLR, so rule '
> comment: '//' a+=.* NEWLINE -> comment(a={a}) ' should match anything until
> newline, construct list 'a' and send it to template 'comment'.
> Somehow .* will consume everything up to the end of input file so I get
> error 'line 0:-1 mismatched input '<EOF>' expecting NEWLINE'. NEWLINE is
> defined as NEWLINE: ('\r'? '\n')+; and is not sent to hidden channel or
> skipped. Where is the problem? I need to send everything to template
> comment, so I can not send comments to trashbin through lexer rule.
> Thank You
> Georg
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list