[antlr-interest] Adding antlr to Visual Studio C#
Gavin Lambert
antlr at mirality.co.nz
Fri Sep 14 14:09:26 PDT 2007
At 02:24 15/09/2007, Arto Viitanen wrote:
>How can I add Antlr (I use the binary tool from
>http://www.antlr.org/download/Antlr.Tool.zip) to Visual Studio
C#?
>I have defined it as external tool:
>
>Title: [Antlr]
>Command: C:\antlr\Antlr\Antlr3.Tool.exe
>Arguments: ${ItemPath}
>Initial directory: ${ItemDir}
>
>+ Use output Window
>
>This works fine, but I have to select [Antlr] from tool menu
each
>time I like to run antlr to a .g file. Since I have
>one file for parser/lexer and another for tree walker (most
likely
>I will get yet another to generate code), I'd like
>to make the Visual Studio realize that when an .g file is
changed,
>it should run the [Antlr] tool for the file.
There should be a .rules file in lib\C\vs2005\rulefiles. If you
import that into your VS2005 project then it should be able to
compile ANTLR files automatically -- though it expects certain
file extensions (since it needs to know which output files will be
generated) -- .g3 for a combined grammar and .g3t for a tree
grammar, for example.
It is geared for C rather than C#, though, so it won't work
directly. You'd have to edit it first to remove the references to
.h files and change the .c to .cs.
More information about the antlr-interest
mailing list