[antlr-interest] C# antlr-dotnet-tool-3.3.1.7705 issue with collected template list

Sam Harwell sharwell at pixelminegames.com
Fri Feb 25 12:01:06 PST 2011


Hi David,

Can you add the following template to the CSharp3 target's ST.stg which is
used for generating code. Let me know if it resolves the issue for you. If
this works, I'll clean it up (only overriding the necessary portion) and get
it checked in for the next release.

ruleLabelDefs() ::= <<
<[ruleDescriptor.tokenLabels,ruleDescriptor.tokenListLabels,ruleDescriptor.w
ildcardTreeLabels,ruleDescriptor.wildcardTreeListLabels]
    :{<labelType> <it.label.text> = default(<labelType>);}; separator="\n"
>
<ruleDescriptor.tokenListLabels
    :{List\<<labelType>\> list_<it.label.text> = null;}; separator="\n"
>
<ruleDescriptor.ruleListLabels
    :{List\<<StringTemplate>\> list_<it.label.text> = null;}; separator="\n"
>
<ruleDescriptor.wildcardTreeListLabels
    :{List\<<ASTLabelType>\> list_<it.label.text> = null;}; separator="\n"
>
<ruleDescriptor.ruleLabels:ruleLabelDef(label=it); separator="\n">
<ruleDescriptor.ruleListLabels:ruleLabelDef(label=it); separator="\n">
>>


Thanks,
Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of David Daeschler
Sent: Friday, February 25, 2011 1:25 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] C# antlr-dotnet-tool-3.3.1.7705 issue with
collected template list

Hello,

I am using antlr-dotnet-tool-3.3.1.7705 and beginning work on a template to
translate from a high level language to bytecode.

One of my rules looks something like this:

script : (g+=globalVar)+
-> file(globalVars={$g})

globalVar
: ^(VAR_DECL TYPE ID .?)
-> vardec(type={$TYPE.text}, id={$ID.text})
;

It appears that the code being generated in this case to collect the
templates is slightly off. The type of list to hold the returned result is:

List<MyAST> list_g = null;

But when the collection is done, it is expecting the list to hold a
stringtemplate:

if (list_g==null) list_g=new List<StringTemplate>();
list_g.Add(g.Template);

I have confirmed my output is set correctly:

options {
language = 'CSharp3';
tokenVocab = MyVocab;
ASTLabelType = MyAST;
output = template;
}


Is there anything else I need to do?

Thank you very much for any help.
-- 
David Daeschler

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list