[antlr-interest] antlr-interest Digest, Vol 31, Issue 20

Mark Venbrux mark.venbrux at gmail.com
Wed Jun 6 03:53:53 PDT 2007


Hi Ruth,
You might wanna try replacing '/jsp:root' with a real Lexer token.
Like you did with OROOT.
Cheers,
    Mark
>
>
>
>
> ---------- Doorgestuurd bericht ----------
> From: Ruth Karl <ruth.karl at gmx.de>
> To: Jim Idle <jimi at temporal-wave.com>
> Date: Wed, 06 Jun 2007 12:04:52 +0200
> Subject: Re: [antlr-interest] Grammar problem, probably silly....
> Jim Idle schrieb:
> > Karl,
> >
> (this is my last name ;-) prefer to be called Ruth...)
>
> > You cannot execute predicates in interpretative mode in ANTLR.
> You mean: ANTLRWorks - right???
> Also I copied the idea of using the predicates that way from
> http://www.antlr.org/wiki/display/ANTLR3/1.+Lexer
> that is why I supposed it would work this way...
> But I'll try to debug it outside ANTLRWorks and see what happens, thanks
> for your suggestions, Jim.
>
> Have a nice day,
> Ruth
>
> > 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
> >>
> >
> >
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070606/816d0c2e/attachment.html 


More information about the antlr-interest mailing list