[antlr-interest] Re: C# port of 2.7.2

Scott scott at fmsinc.com
Wed Mar 20 23:15:46 PST 2002

I'm hesitant to mention this, but I have a custom version of ANTLR 2.7.1
that works for C# and VB.NET. This includes the code generators. I've been
meaning to post this "Real Soon Now", but I've been buried in trying to get
some products out the door. I intended to clean up the code and document
each change I've made, before posting it, but there seems to be enough
interest that I'm willing to post what I have. 

I haven't yet looked at porting this to 2.7.2.xxx, since I can't afford to
break my code base at this point. This is on my list, though. I can't really
afford to do any maintenance for the next few months, but I'm happy to pass
the torch. 

Unfortunately, I made changes to the C# version of the antlr runtime that
break compatibility with the Java version, but make it more in line with the
CLS. Mostly casing, and wrapping getXXX, setXXX into properties. I also
needed to make changes the java based code generator driver to support
namespaces for C# and VB.NET. I also added lazy creation of the _saveIndex
variable to get rid of annoying unused variable warnings.

In addition, I also added a few optimizations to (hopefully) crank up
performance a little bit. The most obvious are that I hard coded Token and
AST creation to work around CreateInstance performance problems, and I added
cache'ing for the LA() members. I also implemented the InputGuessing
optimization mentioned on this list a few months back, since the .NET GC was
hampering performance. There might be few more that I can't remember at this

The code generators are messy, but they are workable. If anyone is still
interested, I can provide a link to it in a few days. 
It's worked well for my purposes, but YMMV.


Scott Ellis

-----Original Message-----
From: Terence Parr [mailto:parrt at jguru.com] 
Sent: Wednesday, March 20, 2002 2:03 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] Re: C# port of 2.7.2

Hi Guys, just back from a week off.  2.7.2a2 is close, but not quite 
finished.  Might add a few more things...I should have more time soon.

Also, don't implement a new code generator.  The current thing sucks but 
I am experimenting with a new code gen system myself that I might hack 
into 2.x to make things easier.  OTOH, it might have to wait until 3.0 
(a complete rewrite).

In summary, it might just be easier to work with the crappy code 
generation thing in ANTLR as it stands; C# is basically Java so you 
should no trouble with modifying JavaCodeGenerator.java, right?



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list