[antlr-interest] Greedy matching to end of line

Pop Qvarnström pop.qvarnstrom at gmail.com
Fri Jan 28 06:07:03 PST 2011


Ouch, that's what I get for cutting and pasting. 'Comment: NOCHandle'
(original mail text) vs 'Comment: NOCHandle:' (from images, and - of course
- the keywords). Getting the same result as you when doing the same thing.
Sorry.

/Pop

2011/1/28 Pop Qvarnström <pop.qvarnstrom at gmail.com>

> Same apology goes here, attached is cap of my run of NOCHandle in the
> interpreter, grammar cut and pasted from your original mail. The interpreter
> has quirks though, have you tried running it in the debugger instead? And
> what versions of antlr/antlrworks are you running?
>
> Cheers,
> Pop
>
> 2011/1/28 Robert J. Hansen <rjh at sixdemonbag.org>
>
>>  (I apologize in advance for the embedded images.  I understand a lot of
>> people on the 'net want only pure ASCII text, but it seems easiest if I give
>> screen caps.)
>>
>>
>>
>> > I cannot reproduce this using your supplied grammar: as long as the
>> required NEWLINE is in place, your example works just fine. If, however, I
>> do not provide a newline in the input, I'm hit by a NoViableAltException.
>>
>> Strange.  In my own tests it works out quite differently.
>>
>> First, yes, you're correct: a newline needs to be at the end of each and
>> every line.  This is part of the original corpus's spec.  In the attached
>> screenshots, the interpreter input has a newline at the end, although it's
>> not visible.  First, a bad parse, showing how it bombs out on the words
>> token:
>>
>>
>>
>> Second, a good parse, showing how changing NOCHandle to anything else
>> allows it to parse:
>>
>>
>>
>


More information about the antlr-interest mailing list