[antlr-interest] Re: c# code generation with Visual Studio .NET

bulk at exaflop.org bulk at exaflop.org
Wed May 14 07:32:24 PDT 2003


Annoyingly the CustomTool thing is part of the VS Customisation Kit
which is only available under contract to Microsoft for people like
ActiveState and the ActiveReports people to produce commercial products
that tightly integrate with VS.NET. It has been publicly documented
though (as MS left it as a public class by accident) and so in VS.NET
2003 it has made it part of the public object model for user-level
customisation in the same way as menu items can be added.

I haven't got VS.NET 2003 yet, but as far as I can tell the build system
is exactly the same as the 2002 version which is disappointingly
inflexible for C# projects. Thinking about it though, there should be a
way around this problem: Create a CustomTool for .g files and in the
processing logic, use the VSProject and VSProjectItem interfaces to add
the resultant files to the project if they weren't already there and
reload them if they are. I'm not sure if the dependency logic in VS.NET
is smart enough to deal with that though, but its worth a try :)

In the meantime I made a horrible but fairly effective workaround:
Create a dummy C++ project in your solution, make it a Win32 command
line app or dll or whatever. Ignore the files the Create Project Wizard
creates but add your parser.g file in that project as a source file and
set up a custom build operation for it. You'll have to spend a bit of
time passing all the necessary parameters so it copies the resultant .cs
files to your C# project but you only have to do it once (unless you are
creating ANTLR projects frequently in which case you could write your
own custom wizard to sort it out). Now just make the building of your C#
project dependant on the C++ project and your files will always be up to
date.

Actually I don't know if I did this right or if theres a bug in VS.NET,
but the way I set mine up, ANTLR always gets rerun when I go to compile
the C# project whether or not the .g file has changed. Still, my machine
is fast enough to run even java at a decent speed so it doesn't bother
me too much.

Regards,

Richard

-----Original Message-----
From: micheal_jor [mailto:open.zone at virgin.net] 
Sent: 05 May 2003 22:52
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: c# code generation with Visual Studio .NET


--- In antlr-interest at yahoogroups.com, "Ney, Richard" 
<richard.ney at a...> wrote:
> Patrik,

> The work around I did was to setup a menu item in the Tools menu of
the IDE.
> This at least allows me to select a .g file and compile it. Until
someone
> has the time to write the add-in for .NET languages this is the
best we have
> at this time.

VS.NET's CustomTool model (for code-generators) is limited because it 
only allows the generation of a single source file for each input 
file. It does not support a code generator - like ANTLR - that can 
generate *multiple* outputSourceCode files from a single 
codegenSource file.

Given that *most* ANTLR grammar files are indeed multi-ouput, we 
decided against developing a VS.NET CustomTool interface for ANTLR/C# 
for the moment. Any such interface would be limited to a outputting a 
single source file per *.g file and we didn't fancy having our 
Lexers, Parsers and TreeParsers all pop out in the same *huge* source 
file.

I haven't look at VS.NET 2003 yet in any great detail as far as this 
issue in considered so, there may be hope yet.

Cheers,

Micheal
ANTLR/C# codegen 



 

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




 

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




More information about the antlr-interest mailing list