On Tue, 2008-10-14 at 11:28 -0500, Sam Harwell wrote: > Here’s how you can get the Clean and Rebuild tasks working as well. If > you delete the .tokens files associated with each grammar, then the > grammar will get properly rebuilt: > > > > <PropertyGroup> > > > <CoreCleanDependsOn>$(CoreCleanDependsOn);CleanAntlrCode</CoreCleanDependsOn> > > </PropertyGroup> > > <Target Name="CleanAntlrCode"> > > <ItemGroup> > > <_CleanAntlrFileWrites > Include="@(Antlr3->'%(RelativeDir)%(Filename).tokens')" /> > > </ItemGroup> > > <Message Importance="normal" Text="Antlr: Deleting output > files '@(_CleanAntlrFileWrites)'"/> > > <Delete Files="@(_CleanAntlrFileWrites)" /> > > </Target> >
Guys, We really need to update the WIki article rather than/as well as, post here - this is all useful information. Jim > > > Sam > > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Gavin Lambert > Sent: Tuesday, October 14, 2008 4:09 AM > To: André van der Merwe; [EMAIL PROTECTED] > Subject: Re: [antlr-interest] VS2008 Integration Example > > > > At 21:35 14/10/2008, André van der Merwe wrote: > > >Does anyone have a simple example VS2008 > > >solution that calls ANTLR as part of the build > > >(i.e. not a pre-build event). > > > > > >I’ve followed the instructions on the web site > > >but I’m doing something wrong.... > > > > For which target language? > > > > This is the method I use for C# projects (will > > probably also work with other .NET languages, but *not* C/C++): > > > > 1. Right-click, Unload Project, Right-click, Edit > > project. (If you're using Express, you don't > > have this option, but you can edit the project > > file outside of VS instead.) > > 2. Somewhere inside the first <PropertyGroup> section, add these: > > > > <AntlrFolder>D:\path\to\antlr\lib</AntlrFolder> > > <AntlrClassPath>$(AntlrFolder)\antlr-3.jar; > $(AntlrFolder)\stringtemplate-3.2.jar; > $(AntlrFolder)\antlr-2.7.7.jar</AntlrClassPath> > > > > 3. Immediately below the > > <ItemGroup>...</ItemGroup> block containing your > > normal source files, add this: > > > > <ItemGroup> > > <Antlr3 Include="Your.g"> > > > <OutputFiles>YourLexer.g;YourParser.g;Your.tokens</OutputFiles> > > </Antlr3> > > <Antlr3 Include="YourTree.g"> > > <InputFiles>Your.tokens</InputFiles> > > <OutputFiles>YourTree.cs</OutputFiles> > > </Antlr3> > > <Compile Include="YourLexer.cs"> > > <AutoGen>True</AutoGen> > > <DesignTime>True</DesignTime> > > <DependentUpon>Your.g</DependentUpon> > > </Compile> > > <Compile Include="YourParser.cs"> > > <AutoGen>True</AutoGen> > > <DesignTime>True</DesignTime> > > <DependentUpon>Your.g</DependentUpon> > > </Compile> > > <Compile Include="YourTree.cs"> > > <AutoGen>True</AutoGen> > > <DesignTime>True</DesignTime> > > <DependentUpon>YourTree.g</DependentUpon> > > </Compile> > > </ItemGroup> > > > > 4. Immediately above the closing </Project> tag, add this: > > > > <Target Name="GenerateAntlrCode" > > Inputs="@(Antlr3);%(Antlr3.InputFiles)" > > Outputs="%(Antlr3.OutputFiles)"> > > <Exec Command="java -cp > > "$(AntlrClassPath)" org.antlr.Tool > > -message-format vs2005 @(Antlr3)" > > Outputs="%(Antlr3.OutputFiles)" /> > > </Target> > > <PropertyGroup> > > <BuildDependsOn>GenerateAntlrCode; > $(BuildDependsOn)</BuildDependsOn> > > </PropertyGroup> > > > > 5. Edit the above to suit your real files. > > > > There's probably better ways to do this (I'm not > > really all that experienced with MSBuild), but > > the above works for me. It's a little bit clunky > > in that you have to manually edit the project > > whenever you add new grammar files (or outputs), > > but that's usually not something that happens very often. > > > > One caveat: Visual Studio does weird things if > > you have the generated .cs files open when you > > build, especially if you've modified the > > grammar. It's best to close the .cs files before > > you build. (It sometimes seems to compile the > > version of the code that's shown in the editor -- > > ie. the old code -- instead of the newly > > generated code. This is especially true if it > > thinks the code has been modified -- which > > includes the line-ending adjustment it likes > > making when you open them.) > > > > > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest > > Unsubscribe: > http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address > > > > > > List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
