[antlr-interest] Matching Last Line in ANTLR?
Gavin Lambert
antlr at mirality.co.nz
Tue Aug 18 13:22:18 PDT 2009
At 08:08 19/08/2009, consiliens at gmail.com wrote:
>I want to use your solution, however it throws errors about "The
>following alternatives can never be matched: 1" for MC_QUESTION
>and MC_INCORRECT. Shouldn't the below work?
>
>MC_QUESTION : INT ('.'|')') .* ENDOFLINE;
>MC_INCORRECT : LETTER '.' .* ENDOFLINE;
>MC_CORRECT : '*' MC_INCORRECT;
>
>fragment ENDOFLINE : NEWLINE | { input.LA(1) == EOF }?;
No. You can't use a .* wildcard loop without (a) always having at
least one termination character and (b) specifying it inline
rather than in a subrule.
If you remove the .* (or make it more specific, eg. WS*) then it
should work.
More information about the antlr-interest
mailing list