[antlr-interest] Greedy matching to end of line

Hiran Chaudhuri hiran.chaudhuri at web.de
Fri Jan 28 00:49:50 PST 2011


Am Freitag, den 28.01.2011, 02:51 -0500 schrieb Robert J. Hansen:
> ... Now, consider the derivation of the line:
> 
> 	Comment: NOCHandle John Q. Hacker
> 
> ... starting from rule asline.  asline derives out to 'Comment:' on the
> left, words on the right, and from there straight to NoViableAltException.
> 
> However, if I change it to:
> 
> 	Comment: NCHandle John Q. Hacker
> 
> ... then it derives successfully.

It seems to me that the parser recognizes the anonymous tokens although
at this position in the file they are valid non-keywords.

Somehow the solution must be to allow keywords in other positions of the
language, although I cannot tell how the solution would look like.

Hiran



More information about the antlr-interest mailing list