[antlr-interest] [bug?] Unrecognized escape sequence in Lexer.cs code(3.1b1 C# Target)

Sam Harwell sharwell at pixelminegames.com
Wed May 28 18:32:34 PDT 2008


There is an override of encodeIntAsCharEscape in CSharp2Target.java that should also be in CSharpTarget.java. This will resolve the escape sequences issue.

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Johannes Luber
Sent: Wednesday, May 28, 2008 6:21 PM
To: Radu Damboianu; antlr-interest at antlr.org; gmdidro at gmail.com
Subject: Re: [antlr-interest] [bug?] Unrecognized escape sequence in Lexer.cs code(3.1b1 C# Target)

> I have encountered this issue as well. The correct solution for the
> unrecognized C# escape sequences is not prepending a @ (that would kill the
> correct \uffff escape sequences as well) but replacing escapes like \3 with
> \u0003.
>  
> Unfortunately, even after doing that (I wrote a small program that does
> the replacements above), I found that there were other problems in 3.1b1 for
> the C# target which makes it basically unusable in the current state.

Sorry about this. :( It seems that Java defines escape sequences differently than C#. I thought C# was a superset of Java here and thus never looked into the actual algorithm mined from the Java target. I'm actually surprised that these problems came up only now - other people did use the same version as you and they never mentioned this problem.

It could be your specific grammar, so it would be nice, if you could send it to me. Also all other problems and possibly their fixes, as they can't be fixed then. Unfortunately, I am bereft of my development tools due to a harddrive crash of my main machine and until it is fixed, I can't look for the bugs. In case you can't wait a few more weeks, you have to fix them yourself or you can go back to an earlier daily build - the runtime compression was a late addition.

I also noted that the grammar example of the OP uses CSharp as the target. For ANTLR 3.1, CSharp is obsoleted by CSharp2. Please take this into account and refer for further details to the ANTLR wiki page about the C# target. 

Johannes
> 
> 
> 
> > Date: Wed, 28 May 2008 21:03:16 +0400> From: gmdidro at gmail.com> To:
> antlr-interest at antlr.org> Subject: [antlr-interest] [bug?] Unrecognized escape
> sequence in Lexer .cs code(3.1b1 C# Target)> > Hello,> the Lexer code
> generated in accordance to the following grammar gets> the many errors
> "LPMEDLexer.cs(510,11): error CS1009: Unrecognized> escape sequence".> > It seems to
> me, that when ANTLR generates a code for DFA, it doesn't> use "@" for
> format-string representation:> > LPMEDLexer.cs> line: 510>
> "\3\uffff\2\10\4\uffff\4\10\1\17\1\10\1\uffff\1\21\1\uffff";> it should be>
> @"\3\uffff\2\10\4\uffff\4\10\1\17\1\10\1\uffff\1\21\1\uffff";> > I also have such errors in
> Parser and Tree Parser code, but can't> reproduce it with a small grammar.> >
> Is it a bug ?>
> ----------------------------------------------------------------------------------------------------------------------> grammar
> LPMED;> options{ language = CSharp; }> tokens{ CINT; CBOOL; }> > program : atom
> '.' ;> > atom> options> {> backtrack=true;> } : dMFID> | INT //-> ^(CINT
> INT)> | dBOOL //-> ^(CBOOL dBOOL)> ;> > dMFID : ',' atom | ID;> > dBOOL :>
> 'true'> |'false'> ;> > > INT : ('0'..'9')+ ;> WS : ( ' '> | '\t'> | '\r'> |
> '\n'> )+> { $channel=HIDDEN; }> ;> > fragment NEWLINE> : '\r'|'\n'> ;> >
> LINECOMMENT> : '//' ~('\r'|'\n')* NEWLINE {$channel=HIDDEN;}> ;> > ID :
> ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_')*;>
> ---------------------------------------------------------------------------------------------------------------------->
> > //ANTLR Parser Generator Version 3.1b1 (May 20, 2008) 1989-2008>
> //LPMEDLexer.cs(510,11): error CS1009: Unrecognized escape sequence> > Thank you
> _________________________________________________________________
> Change the world with e-mail. Join the i'm Initiative from Microsoft.
> http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ChangeWorld

-- 
Super-Aktion nur in der GMX Spieleflat: 10 Tage für 1 Euro.
Über 180 Spiele downloaden: http://flat.games.gmx.de


More information about the antlr-interest mailing list