1

I use ANTLR 3.5 in my work. However, the auto-generated files (lexer and parser) always get the message:

"$ANTLR 3.5 D:\\PATH_OF_ANTLR_FILE\\Expression.g 2013-04-10 15:34:48"

Is there anyway to hide this message? I want hide the message since I take these files into version control system. The version control system will get conflict message if the date info in this message is mismatch with earlier one.

Tom
  • 13
  • 2
  • In my opinion, generated code should not be checked into source control. You should only check-in your antlr grammar file, not the lexer and parser generated off it. See http://stackoverflow.com/questions/893913/should-i-store-generated-code-in-source-control. – dogbane Apr 10 '13 at 08:29
  • Why VCS will get conflict??? – Andremoniy Apr 10 '13 at 08:33
  • @dogbane but in my case, not every member in our team have installed ANTLR plugin (ex: front end programmer, PM... ). Do not check auto-generated code into VCS means everyone should install ANTLR plugin. It's inconvenient. – Tom Apr 11 '13 at 09:07
  • @Andremoniy since I checkout previous version code the ANTLR will re-generated the code again. The generated comment with date info will change (become newer). when I checkout the latest version, conflict happen. – Tom Apr 11 '13 at 09:13
  • Conflict can occur only in case, when two (or more) programmers commit different changes in same lines of same file. In your case I couldn't understand the issue – Andremoniy Apr 11 '13 at 09:34
  • @Andremoniy If my commit history look like this A--B--C--D, the A is the first version and the D is latest version. When I checkout version B, the ANTLR will auto-generate new code since the g file is different between B and D. After that, when I checkout back to version D the conflict happen since the first line is different. – Tom Apr 11 '13 at 09:46
  • To simplify this question. Can I just hide the message or show the message without the date in the end? – Tom Apr 11 '13 at 09:53
  • I don't believe `antlr` has an option to turn this off. However, you can probably run a script (using the `sed` command for example) to remove this line after `antlr` has generated the files. – dogbane Apr 11 '13 at 11:15

1 Answers1

0

ANTLR does not have a way to disable this message. However, this does not cause a problem with source control since the recommended usage for at least the Java, CSharp2, and CSharp3 targets involves automatic generation of parsers from the grammars at build time, and the generated files themselves are excluded from source control.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • That is the usual way, but there are certainly scenarios where you want to check in the generated code. For example, I might be writing a library to work with SQL queries in C++. Part of the implementation could be an Antlr grammar that generated a C++ parser. When I distribute my library to C++ users, I do not want to force them to install Antlr and Java. I want to distribute the generated C++ files. So in that case, I want the .g files in version control, but I also want the generated headers. – Troy Daniels Apr 15 '13 at 21:50