[antlr-interest] Grammar problem, probably silly....

Oliver Zeigermann oliver at zeigermann.de
Wed Jun 6 13:40:12 PDT 2007


Hi!

I just tested you grammar (outside of ANTLRWorks) and it works like it should.

Cheers

Oliver

2007/6/5, Ruth Karl <ruth.karl at gmx.de>:
> Hi,
>
> I have been trying quite a while now, but I keep getting a
> MismatchedTokenException with the following simplified test grammar:
>
>         grammar JSP;
>
>         options {
>             language = CSharp;
>             output = AST;
>         }
>
>
>         @members {
>              boolean xmlDoc = false;
>               boolean outputEnabled = false;
>         }
>
>
>
>         @lexer::members {
>                 boolean tagMode = false;
>         }
>
>         // Parser rules
>         jsp    :    oroot (content)* croot EOF
>             ;
>         oroot     :     OPENTAG OROOT CLOSETAG
>             ;
>         croot    :    OPENTAG '/jsp:root' CLOSETAG
>             ;
>         content    :     TEXT
>             ;
>
>
>
>         // Lexer rules
>         OPENTAG     :     '<' { tagMode = true; }
>             ;
>         CLOSETAG     :     '>' { tagMode = false; }
>             ;
>         TEXT    :    {!tagMode}?=> (~'<')+
>         ;
>         OROOT    :    'jsp:root'
>          ;
>
> The exception occurs when I print
>
>         <jsp:root>ljlj</jsp:root>
>
> in the interpreter and tell it to start from jsp rule.
> it says (4!=5), according to the generated files this is OROOT=5 and
> OPENTAG=4.
> Could anyone please help me with that???
>
> Thanks a lot!
>
> Ruth
>


More information about the antlr-interest mailing list