[stringtemplate-interest] C# indexer - no attribute in template context
Tomasz Mloduchowski
tomasz at ourscale.eu
Fri Jul 23 09:25:42 PDT 2010
Hi!
I'm new to StringTemplate, and I've been trying to use it with an CLR
indexer.
I've boiled down my troubles to this simple program:
using System;
using Antlr3.ST;
public class Lang {
public string this [ string key ] {
set {}
get {return "Foo"; }
}
}
public class HelloWorld {
static public void Main (){
Console.WriteLine("Hi");
Lang l = new Lang();
Console.WriteLine(l["XX"]);
StringTemplate hello = new StringTemplate("Hello, $name$: $lang.XX$");
hello.SetAttribute("name", "World");
hello.SetAttribute("lang", l);
Console.WriteLine(hello.ToString());
}
}
If I'm reading the documentation located here correctly,
http://www.antlr.org/wiki/display/ST/Expressions
this should just output:
Hi
XX
Hello World: XX
Unfortunately, I'm getting:
Hi
Foo
Class Lang has no such attribute: XX in template context [anonymous]
Hello, World:
Do you have a suggestion? Google reveals nothing relevant.
Cheers,
Tomasz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20100723/642c9ee1/attachment.bin
More information about the stringtemplate-interest
mailing list