[antlr-interest] Help with integrating ANTLR3 with Visual Studio 2008

Gavin Lambert antlr at mirality.co.nz
Mon Aug 4 02:41:03 PDT 2008


At 16:05 4/08/2008, Paul Hansen wrote:
>I am trying (forever, it seems like) to get ANTLR3 and ANTLRWorks 
>to work with Visual Studio 2008.  My first try was to follow the 
>steps listed on the following webpage exactly 
><http://antlr.org/wiki/pages/viewpage.action?pageId=557075>http://antlr.org/wiki/pages/viewpage.action?pageId=557075

Bear in mind that the instructions on that page assume you're 
going to be doing all your grammar building in ANTLRworks -- if 
you modify the .g file then Visual Studio will *not* be able to 
rebuild the lexer/parser.

If you want to be able to do that, then you need to follow these 
instructions:
   <http://antlr.org/wiki/display/ANTLR3/Integration+with+Development+Environments>

(Something else to watch out for is that if you have the 
lexer/parser .cs files open in Visual Studio then it will 
sometimes compile what's in the window rather than what's on disk, 
so it might be compiling out-of-date files.)

>I followed the steps exactly but I get 25 errors!  I am not sure 
>where to go from here.  ANTLR3 seems like it would be an 
>incredible tool for DSL's but I can't get it to work?!
>
>I am attaching a zipped version of my project with the 25 
>errors.  There are no executables in the attachment.

I don't have a copy of VS2008 handy at the moment.  But...

Something I did notice in passing; you appear to be using ANTLR 
3.1b2 and StringTemplate 3.0.1.  Now, I could easily be wrong 
about this, but I thought that ANTLR 3.1 required a later version 
of StringTemplate?

Also, "protected" on the DIGIT rule is v2 syntax.  For v3, you 
need to use "fragment".

And finally, the most likely problem: the generated code says it 
was built using ANTLR 3.0.1.  This means that the runtime doesn't 
match the generated code, and that just won't work.  If you did 
use ANTLRworks to compile it then you'll need to use a later 
version (or use an older version of the runtime).



More information about the antlr-interest mailing list