[antlr-interest] Problem with carriage returns in c# stringtemplate

Tech tech at swingkid.fsnet.co.uk
Sun Oct 23 14:31:31 PDT 2005


Thanks for your reply Luis.

No, this is not my whole template group, but I was trying to reduce the 
problem. I agree with you that your code works. However, if you copy the 
string into a text file (removing the escape characters from the 
quotation marks) and include it as an embedded resource, it doesn't work!

     //StringReader sr = new StringReader("group TestOutput;
    program(statements)::= << class Wrapper { <statements;
    separator=\"\r\n\"> } >>");
     Stream s =
    typeof(Class1).Assembly.GetManifestResourceStream("Project1.Test.stg");
    StreamReader sr = new StreamReader(s);
    StringTemplateGroup stg = new StringTemplateGroup(sr,
    typeof(antlr.stringtemplate.language.AngleBracketTemplateLexer));

where Test.stg contains

    group TestOutput; program(statements)::= << class Wrapper {
    <statements; separator="\r\n"> } >>

I have tried copying the StreamReader contents into a string before 
constructing the StringTemplateGroup, but that doesn't help. It seems 
more like a .Net issue than a StringTemplate issue, but I can't figure 
it out. I wonder if it is an encoding thing?

Always curious,

Mark



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.4/146 - Release Date: 21/10/2005




More information about the antlr-interest mailing list