[antlr-interest] Grammar problem, probably silly....
Ruth Karl
ruth.karl at gmx.de
Wed Jun 6 03:04:52 PDT 2007
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
>>
>
>
More information about the antlr-interest
mailing list