Thanks Andrew - after I'd posted, I did some poking around that led me right to CSharp2.stg. It's very readable, and I thought about modifying it, but as you (and Yoda) pointed out, "Once you start modifying your distro, forever will it dominate your upgrades". If there were an actual error I was trying to fix, sure, but this one isn't worth it.
Thanks for your help! Tony Gray | Schneider Electric From: Andrew Bradnan <[email protected]> To: [email protected] Cc: [email protected] Date: 07/09/2010 07:09 AM Subject: Re: [antlr-interest] Can I embed the Antlr version number in my generated code using some kind of macro? Sent by: [email protected] You would have to modify the string template for the CSharp2 target in the antlr-3.2.jar file. It lives at antlr-3.2_jar\org\antlr\codegen\templates\CSharp2\CSharp2.stg You can update if you have a copy of winzip handy. Just unzip, update the stg. file and rezip. Of course that change will be null and void with the next version of antlr which will have a new version of the string template. That is how to update the generated code however. Hope that helps. Andrew On Thu, Jul 8, 2010 at 11:08 AM, <[email protected]>wrote: > The ANTLR generated code has lots of nice identifier comments in it with > the file, line number and grammar file contents that generated the code. > Are there anything like preprocessor macros I can use to get direct access > to that info? > > I'm using the C# target and what I'm really after is the ability to add a > custom code attribute to my generated classes to instruct code analysis > tools that this is generated code. It It should be easy to just embed > that as hard-coded output in the @parser::header { } stuff like so: > > [GeneratedCodeAttribute("ANTLR","3.2")] > > but I'd really like to have the generator drop the version number in for > that string the way it does in the automatically generated comments, like > > // $ANTLR 3.2 Sep 23, 2009 12:02:23 > > I spent 20 minutes googling and came up dry - any suggestions? > > > Tony Gray > Schneider Electric > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > -- /Andrew List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address ________________________________________________________________________ This email has been scanned for SPAM content and Viruses by the MessageLabs Email Security System. ________________________________________________________________________ List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/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.
