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

Tech tech at swingkid.fsnet.co.uk
Sat Oct 22 07:27:33 PDT 2005


Hi,

I am trying to create a C# StringTemplateGroup(v2.2) file containing the 
following template

   group TestOutput;

   // Basic statements

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

I am reading this file in using the AngleBracketLexer (code in C#)

       Stream stgStream = 
typeof(JavascriptParser).Assembly.GetManifestResourceStream("translator.csharp.stg"); 

       TextReader stgReader = new StreamReader(stgStream);
       StringTemplateGroup stg = new StringTemplateGroup(stgReader, 
typeof(antlr.stringtemplate.language.AngleBracketTemplateLexer));

running this code gives the following error:

   StringTemplate: error: problem parsing template 'program': line
   3:34: unexpected char: 'r'


putting "\\r" instead puts '\r' in the output as text. "\n" on its own 
is accepted, but I need a carriage return as well. How do I put carriage 
returns as an attribute separator?

Thanks,

Mark


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




More information about the antlr-interest mailing list