[antlr-interest] supress ANTLR comments in the Generated Lexerand Parser code

Sam Harwell sharwell at pixelminegames.com
Sat Mar 7 11:02:21 PST 2009


Invoke the ANTLR Tool from the working directory containing your
grammar, and pass the filename without the path. The name and path that
show in the generated code are the same as what was passed on the
command line.

 

Sam

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Manikandan
Subramanian
Sent: Saturday, March 07, 2009 11:15 AM
To: Gavin Lambert
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] supress ANTLR comments in the Generated
Lexerand Parser code

 

Hi,

Thanks for the information. In our case, some people works on ANTLR
directly and others just use the generated java files to integrate with
the application, so as you said we don't always need to have the ANTLR
to be installed on every one's machine.

Yes, the information in the comments are useful if every one follows the
same directory structure, but that is not the case. For our case, I am
just wondering, is there any way to tweak the comments to just include
the grammar file name and ANTLR version and remove the folder path.

Thank you,
Mani

On 3/7/09, Gavin Lambert <antlr at mirality.co.nz> wrote:

At 03:33 7/03/2009, Manikandan Subramanian wrote:

Is there any way to supress ANTLR comments in the Generated Lexer and
Parser code.

Every where it says, // $ANTLR 3.1.1
D:\\dev\\workspace\\workspace_contivo\\TranslatorType3Rpt.g 2009-03-06
19:55:09

in all the rules, it includes comments like below, it is referring
physical location, the generated java files has checked in to the CVS
repository and doesnt make sense to have local machine's foldernames.


I don't think it does any harm.  And it's a hint to people looking at
the code that it was the result of a codegen, so they shouldn't be
trying to modify it directly.  And it makes it obvious where to find the
corresponding grammar file :)

Normally though you probably wouldn't check generated code into source
control (since it can usually be regenerated at will), although it's
useful in cases where you don't think people will be modifying the
original source (the grammar) and you don't want to require them to
install ANTLR.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090307/249c50bc/attachment.html 


More information about the antlr-interest mailing list