[antlr-interest] Status of the CSharp3 target and my C# portsof ANTLR and StringTemplate

Jim Idle jimi at temporal-wave.com
Wed Oct 21 01:17:59 PDT 2009


I think we can expose the public/private stuff easily. I will talk to Ter in case there is some reason it is not right now, but I don't think so as the ability to do this is part of the current v2 grammar and I just coded it in my v3 grammar. We should probably move this to ANTLR dev list.

 

Jim

 

From: Sam Harwell [mailto:sharwell at pixelminegames.com] 
Sent: Tuesday, October 20, 2009 10:26 PM
To: Jim Idle; antlr-interest at antlr.org; stringtemplate-interest at antlr.org
Subject: RE: [antlr-interest] Status of the CSharp3 target and my C# portsof ANTLR and StringTemplate

 

The code should be nearly the same as that of the CSharp2 target. Here is the C# port of the CSharp2 target and CSharp3 target so you can see how the CSharp3 one differs. Clearly it should be easy to make it work.

 

public class CSharp2Target : Target

{

    public override string EncodeIntAsCharEscape(int v)

    {

        return "\\x" + v.ToString("X");

    }

}

 

public class CSharp3Target : Target

{

    public override string EncodeIntAsCharEscape(int v)

    {

        return "\\x" + v.ToString("X");

    }

 

    public override string GetTarget64BitStringFromValue(ulong word)

    {

        return "0x" + word.ToString("X");

    }

}

 

Something to note: I'm not sure the Java version of the tool exposes the property required to support marking rules as public/protected/private. We'll have to check that out too, but it should be straightforward.

 

Sam

 

From: Jim Idle [mailto:jimi at temporal-wave.com] 
Sent: Tuesday, October 20, 2009 12:08 AM
To: Sam Harwell; antlr-interest at antlr.org; stringtemplate-interest at antlr.org
Subject: RE: [antlr-interest] Status of the CSharp3 target and my C# portsof ANTLR and StringTemplate

 

OK - well we can add that easily enough J Why don't we try it?

 

Jim

 

From: Sam Harwell [mailto:sharwell at pixelminegames.com] 
Sent: Tuesday, October 20, 2009 7:46 AM
To: Jim Idle; antlr-interest at antlr.org; stringtemplate-interest at antlr.org
Subject: RE: [antlr-interest] Status of the CSharp3 target and my C# portsof ANTLR and StringTemplate

 

I think the only thing missing is the Java class required for the Java version to know the CSharp3 target exists.

 

Sam

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Tuesday, October 20, 2009 2:51 AM
To: antlr-interest at antlr.org; stringtemplate-interest at antlr.org
Subject: Re: [antlr-interest] Status of the CSharp3 target and my C# portsof ANTLR and StringTemplate

 

Top posting for Sam's benefit ;-)

 

Not being able to use the Csharp3 target from the standard version of the tool is going to be a turn off for many I think L What is it that your port of the tool has that the standard version does not. I know you have posted some of that, but perhaps we can summarize this and see if such things can be absorbed into the standard Java tool? Nobody minds you having your own version of anything because it is open source, but most will want ot use the 'offical' java version of the tool even if they are targeting C#.

 

Thanks for the updates,

 

Jim

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Sam Harwell
Sent: Monday, October 19, 2009 1:05 AM
To: antlr-interest at antlr.org; stringtemplate-interest at antlr.org
Subject: [antlr-interest] Status of the CSharp3 target and my C# ports of ANTLR and StringTemplate

 

Hi everyone,

 

Here's a status update that I know many people are asking for. For each portion, I'll talk about the status of the code in Perforce. At the end, I'll talk about the status of the posted binaries.

 

Basic Status

 

StringTemplate and the ANTLR Tool: Up-to-date with the Java version for all targets as of August 4, 2009, which covers all of the changes made earlier in the year and over the summer.

 

CSharp3 Target: working and extensively used in the ANTLR Tool, StringTemplate, and the commercial projects I use ANTLR for. I haven't tested the -profile and -debug modes because I don't use them, however the templates should be "close to working". Currently, the CSharp3 target can only be used when generating grammars from the C# port of the tool.

 

Design Changes

 

1.       Rather than package the target templates as resources in the tool's executable, I've chosen a flat file layout. That way, the templates for a target can be updated without recompiling the tool. The targets themselves are also implemented as individual DLL's.

2.       The CSharp3 target declares rules as private methods by default. Rules can be made public by simply marking them as such in the grammar: "public compile_unit : declaration*;" I have updated the Java target's code generation to support this as well, but it's not checked in.

3.       StringTemplate has code for a high speed dynamically compiled interpreter. By default, the build doesn't enable this mode, but when it's turned on the output appears to work correctly. I need to do another round of tests, but at this point the C# ports of the ANTLR Tool and StringTemplate should be significantly faster than the Java version. We've hit a brick wall preventing further optimization without rewriting ST, but the work on STv4 should give another order of magnitude improvement in template rendering performance.

 

Things Holding Me Up

 

1.       I haven't finalized the way I'm going to do assembly versioning, although I think I've got that worked out now. I'll send a separate mail to the list regarding this.

2.       StringTemplate is only tested in regards to code generation for the ANTLR tool. In particular, its ability to locate templates in resources or on the file system is not documented and may or may not behave as people expect.

3.       I'm still making periodic changes to the API as I finalize things, and breaking changes in production code aren't good. I don't want to suggest replacing the CSharp2 target until the CSharp3 target is more tested by other people.

 

Things I want to do, but not really holding up the builds

 

I really want to package a clean integration of ANTLR+CSharp3 for MSBuild. We need this. This would include at least MSBuild targets file and templates for adding grammars to a project. Unfortunately, there are many issues I still need to resolve for this to be a reality, most of which have answers in shades of gray.

 

Status of the Posted Build

 

The build available for download was uploaded on fairly short notice. Mistakes (by me) included not having the assembly version set correctly and not posting the source code from the build with the binaries. I've been trying to wrap some of these things up before posting another build.

 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20091021/45738851/attachment.html 


More information about the antlr-interest mailing list