Hi! I am working through the "Language Implementation Patterns" book and I am translating all examples to C#. Unfortunately, I cannot get StringTemplate output to work.
Attached you'll find a grammar named Cymbol.g3 and a tree parser named
Gen.g3. I have downloaded them from the publisher's web site and only had to
change a few minor thing to make them compliant with C#.
VisualStudio 2010 turns the g3 files into grammars and lexers nicely, but
unfortunately I cannot compile them. The problem seems to appear whenever an
expression such as "d+=" is used as in the following rule:
compilationUnit: ( d+=classDeclaration | d+=methodDeclaration |
d+=varDeclaration )+ -> file(defs={$d})
For such rules I get errors like the following:
Error 6 Argument 1: cannot convert from 'Antlr3.ST.StringTemplate' to
'Antlr.Runtime.Tree.CommonTree' c:\users\mschmidt2\documents\visual studio
2010\Projects\StringTemplateTest\StringTemplateTest\obj\x86\Debug\Gen.cs
The corresponding code snippet looks as follows:
case 1:
DebugEnterAlt(1);
// Gen.g3:13:11: d+= classDeclaration
{
DebugLocation(13, 12);
PushFollow(Follow._classDeclaration_in_compilationUnit74);
d=classDeclaration();
PopFollow();
if (state.failed) return retval;
if (list_d==null) list_d=new List<StringTemplate>();
list_d.Add(d.Template);
The problem seems to be the initial definition of list_d which is
List<CommonTree> list_d = null;
What am I doing wrong?
Cheers,
Maik
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
Cymbol.g3
Description: Binary data
Gen.g3
Description: Binary data
-- You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.
