[antlr-interest] "prog : .+ ; " ==> "no viable alternative at character" (antlr-3.1.2)

Valery Khamenya khamenya at gmail.com
Mon Feb 1 02:52:56 PST 2010


OK,

filter=true seems to do the magic.

best regards
--
Valery A.Khamenya



On Mon, Feb 1, 2010 at 11:43 AM, Valery Khamenya <khamenya at gmail.com> wrote:
> Hi Kirby and all,
>
>> In this case, I'm pretty sure it's because you don't have a lexer rule...
>
> OK, I see, thank you!
>
> Let's try this (pure) lexer grammar:
>
> ***************************
> lexer grammar ANTLRLexer;
> options {
>        language=Python;
>        k=4;
> }
> INT: 'int';
> ANY: .;
> ***************************
>
> I expect a token stream in output consisting of single characters and 'int'.
> For example: 'inint' ==> ['i', 'n', 'int']
>
> When I feed lexer with 'int' it's OK.
> When I feed lexer with 'inX' it's gives me:
>
>  "line 1:2 mismatched character u'x' expecting 't' "
>
> Why there is no rollback from INT rule to ANY by appearance of 'X'?
>
> How to get the expected? (I thought it is solvable on pure lexer level)
>
> Thanks in advance,
> Valery
>


More information about the antlr-interest mailing list