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

Jim Idle jimi at temporal-wave.com
Tue Jun 5 11:52:48 PDT 2007


Karl,

You cannot execute predicates in interpretative mode in ANTLR. To test
you have to compile and debug it and see if you get the same problem. IF
you do then the issue is with your predicates most likely.

Jim


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Ruth Karl
> Sent: Tuesday, June 05, 2007 10:10 AM
> To: ANTR Interest
> Subject: [antlr-interest] Grammar problem, probably silly....
> 
> 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