[antlr-interest] Available: a prototype for a console application that will transform Java output from Antlr to C#

Rob Hill rob.hill at blueyonder.co.uk
Tue Mar 20 15:42:02 PDT 2007


I don't mean to be pedantic, but it seems you're re-inventing the wheel
somewhat.

 

http://msdn.microsoft.com/vstudio/java/migrate/jlca/default.aspx

 

MS java->C# conversion assistant's been around for quite a while, and seems
to do the job. I haven't tried it on antlr generated output, though i don't
see why it wouldn't work.

 

Cheers,

/2ob

 

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Liviu U
Sent: 20 March 2007 21:00
To: antlr-interest at antlr.org
Subject: [antlr-interest] Available: a prototype for a console application
that will transform Java output from Antlr to C#

 

Hi guys,

Out of the frustration of not being able to have C# code generation working
with antlr 3 beta and direct from ANTLR
I post here a first try of a tool that translates the xxxLexer.java and
xxxParser.java into cs files. 

Usage: antlrJavatoCs.exe fileName

fileName must contain "Lexer" or "Parser" substring. It generates files with
the same name but cs extension, compatible with .NET 2.0.

The application has 2 helper files: Rules.txt and UserRules.txt.  
The first contains replacements that can be reduced to regular expressions. 
The other is for user extensibility, if any new version appears only
Rules.txt must be overriden.
Hardcoded in the application are following transformation rules that do not
map to a regular expression ( the code must be split in blocks and subblocks
) 

0) A preprocessing phase where comments and strings are identified, to avoid
parsing rules in the wrong place.
1)  labeled loop and break label statements
2)  default case for switch should contain a break statement if there is no
one present and no throw. 

I did not try it against bigger grammars, just some smaller ones, but I have
the intention to maintain and extend it if necessary, first because i need
it.
If anyone needs this approach i am open to suggestions. 

Regards
Liviu Uba

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


More information about the antlr-interest mailing list