[antlr-interest] C# target: String Templates and translation bug?
ToolUsr
toolusr at gmail.com
Mon Feb 27 09:48:59 PST 2012
Hello,
Taking an illustrative example from Language Implementation Patterns page 336 (Cymbol translation)
tree grammar Gen; options {
tokenVocab = Cymbol;
ASTLabelType = CommonTree;
output = template;
}
Here we are walking a tree (ASTLabelType) and outputting a template (output=template). Going down a little further
compilationUnit
: ( d+=classDeclaration | d+=methodDeclaration | d+=varDeclaration )+
-> file(defs={$d})
;
The 'd' variable accumulates the goodies for output to a template. In C# with an equivalent example I get the following code generated ...
List<CommonTree> list_d = null;
...
if (list_d==null) list_d=new List<StringTemplate>();
which is a compilation error as new List<StringTemplate>() doesn't cast to List<CommonTree>.
Seems like a bug, thoughts? I'm using the latest version of the tools.
More information about the antlr-interest
mailing list