[stringtemplate-interest] Problem with upgrading to ST4 in c#

Sam Harwell sharwell at pixelminegames.com
Thu May 12 21:08:15 PDT 2011


Hi Jakub,

ST4 requires template files to include a template declaration. I modified the test template you sent me to be compatible with ST4 (see attached).

The new syntax allows you to specify formal arguments for templates where it wasn't possible before.

Thanks,
Sam

-----Original Message-----
From: Jakub Šturc [mailto:jakub.sturc at gmail.com] 
Sent: Thursday, May 12, 2011 4:46 PM
To: Sam Harwell
Cc: stringtemplate-interest at antlr.org
Subject: Re: [stringtemplate-interest] Problem with upgrading to ST4 in c#

Hi,

attached file attached file contains VS2010 project with demo of this problem. Just copy ST4# binaries to the lib folder and watch console for error message.

The body of the template is trivial 4 characters "ABCD".

Thanks
Jakub


On Thu, May 12, 2011 at 11:12 PM, Sam Harwell <sharwell at pixelminegames.com> wrote:
> Is there any way you can send the contents of your template file as well?
>
> Thanks,
> Sam
>
> -----Original Message-----
> From: stringtemplate-interest-bounces at antlr.org 
> [mailto:stringtemplate-interest-bounces at antlr.org] On Behalf Of Jakub 
> Šturc
> Sent: Thursday, May 12, 2011 9:32 AM
> To: stringtemplate-interest at antlr.org
> Subject: [stringtemplate-interest] Problem with upgrading to ST4 in c#
>
> Hello,
>
> a while ago I've been using following c# code to load templates from disk:
>
> var group = new StringTemplateGroup(name, dir, 
> typeof(DefaultTemplateLexer)); var template = 
> group.GetInstanceOf(fileName); // where dir + fileName + ".st" is name 
> of template file on disk
>
> In ST4 I suppose former code should look as following:
>
> var group = new TemplateGroupDirectory(dir, UTF8, '$', '$'); var 
> template = group.GetInstanceOf(fileName);
>
> Now however template is null. When I attached ErrorListener I found that  "A recognition error occurred." with following message "Test.st 1:0: no viable alternative at input 'ABCD'".
>
> This errors are quite cryptic for me but I guess that problem might be that GroupParser is used over template file (.st not .gst).
>
> Is this a bug or am I doing something fundamentally wrong?
>
> Thanks,
> Jakub Šturc
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.st
Type: application/octet-stream
Size: 22 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110512/f584eaa7/attachment.obj 


More information about the stringtemplate-interest mailing list