[antlr-interest] .* consuming all input

George Soom george.soom at siria.cc
Thu Jun 3 02:59:00 PDT 2010


Hi, thank You for answer.
Book "The definitive ANTLR Reference" , page 101, states, 
that ANTLR automatically makes .' and .+ non-greedy. 
Also adding non-greedi option does nothing.

Georg

Oliver Zeigermann <oliver.zeigermann at gmail.com> wrote on 3 Jun 2010, 12:09
PM:
Subject: Re: [antlr-interest] .* consuming all input
>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