[stringtemplate-interest] C# updates for ANTLR 3.4, StringTemplate 4.0.4
Kevin Carroll
kcarroll at signmgmt.com
Mon Aug 1 09:15:09 PDT 2011
Sam,
Still a little tweak needed in the template. When the return type is void, C# doesn't want you to use the return statement:
ruleWrapperBottomup() ::= <<
<if(TREE_PARSER && filterMode)>
<if(buildAST)>public override IAstRuleReturnScope<else>protected override void<endif> Bottomup() { <if(buildAST)>return<endif> bottomup(); }
<endif>
>>
ruleWrapperTopdown() ::= <<
<if(TREE_PARSER && filterMode)>
<if(buildAST)>public override IAstRuleReturnScope<else>protected override void<endif> Topdown() { <if(buildAST)>return<endif> topdown(); }
<endif>
>>
Regarding whether they should be protected or public, I suspect protected should be fine. I'm not aware of any situations where external code should call Topdown() or Bottomup();
Thanks,
Kevin
From: Sam Harwell [mailto:sharwell at pixelminegames.com]
Sent: Monday, August 01, 2011 9:39 AM
To: Kevin Carroll; antlr-interest at antlr.org; 'stringtemplate-interest'
Subject: RE: [stringtemplate-interest] C# updates for ANTLR 3.4, StringTemplate 4.0.4
I missed that the methods in TreeFilter and TreeRewriter have different signatures. I believe they should either both be protected or both be public - which is it (are they supposed to be called directly by external code)?
For now, you can change the following two rules in CSharp3.stg from this:
ruleWrapperBottomup() ::= <<
<if(TREE_PARSER && filterMode)>
public override IAstRuleReturnScope Bottomup() { return bottomup(); }
<endif>
>>
ruleWrapperTopdown() ::= <<
<if(TREE_PARSER && filterMode)>
public override IAstRuleReturnScope Topdown() { return topdown(); }
<endif>
>>
To this:
ruleWrapperBottomup() ::= <<
<if(TREE_PARSER && filterMode)>
<if(buildAST)>public override IAstRuleReturnScope<else>protected override void<endif> Bottomup() { return bottomup(); }
<endif>
>>
ruleWrapperTopdown() ::= <<
<if(TREE_PARSER && filterMode)>
<if(buildAST)>public override IAstRuleReturnScope<else>protected override void<endif> Topdown() { return topdown(); }
<endif>
>>
Sam
From: Kevin Carroll [mailto:kcarroll at signmgmt.com]
Sent: Monday, August 01, 2011 9:12 AM
To: Sam Harwell; antlr-interest at antlr.org; stringtemplate-interest
Subject: RE: [stringtemplate-interest] C# updates for ANTLR 3.4, StringTemplate 4.0.4
Sam,
Apparently, the TreeFilter class defines Topdown() and Bottomup() as protected void, but the overrides are defined as public IAstRuleReturnScope. When building my parsers using the new release, I get the following errors (sorry, text-only folks):
[cid:image001.png at 01CC503B.C0850F60]
Thanks,
Kevin
From: stringtemplate-interest-bounces at antlr.org<mailto:stringtemplate-interest-bounces at antlr.org> [mailto:stringtemplate-interest-bounces at antlr.org]<mailto:[mailto:stringtemplate-interest-bounces at antlr.org]> On Behalf Of Sam Harwell
Sent: Saturday, July 30, 2011 3:57 PM
To: antlr-interest at antlr.org<mailto:antlr-interest at antlr.org>; stringtemplate-interest
Subject: [stringtemplate-interest] C# updates for ANTLR 3.4, StringTemplate 4.0.4
Hello everyone,
I just finished updating the C# ports of ANTLR and StringTemplate for the recent releases of ANTLR 3.4 and StringTemplate 4.0.4. This is a significant update for the C# port, and includes the following in addition to the updates found in the corresponding Java versions.
* The CSharp2 target has been updated to use the same runtime assembly as the CSharp3 target (Antlr3.Runtime.dll).
* Tree grammars with "filter=true" now automatically generate the required overridden implementations of TreeFilter.Topdown and/or TreeFilter.Bottomup.
* Improved support for delegate grammars in the build process (set their Build Action to AntlrAbstractGrammar and Custom Tool to MSBuild:Compile).
* Improved Tool performance.
The documentation and downloads can be found at the following page:
http://www.antlr.org/wiki/display/ANTLR3/Antlr3CSharpReleases
Also, if you end up using (and liking) my Visual Studio 2010 extensions, I appreciate the reviews on the Visual Studio Gallery. :)
Thank you,
Sam Harwell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110801/30729cb4/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 38133 bytes
Desc: image001.png
Url : http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110801/30729cb4/attachment-0001.png
More information about the stringtemplate-interest
mailing list