Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Hand-written" generated code #1

Closed
willfaught opened this issue May 20, 2016 · 2 comments
Closed

"Hand-written" generated code #1

willfaught opened this issue May 20, 2016 · 2 comments

Comments

@willfaught
Copy link
Collaborator

What do you think about generating code that, to all appearances, was written by hand? I think more programmers would be willing to use generated code if it felt "cleaner". This question came to mind when I came across the fileHeader template:

fileHeader(grammarFileName, ANTLRVersion) ::= <<
// Generated from <grammarFileName; format="java-escape"> by ANTLR <ANTLRVersion>
>>
@pboyer
Copy link
Owner

pboyer commented May 22, 2016

@willfaught I don't think we should remove this comment. Here's why:

  1. All gen'ed code from ANTLR is similarly labeled. This would keep things consistent.
  2. The header comment ensures that it's clear that a generator will do a full rewrite, blowing away any "hand" changes to the code.
  3. It provides valuable generator version labeling, which can be used to bring generated code back to a known safe state.
  4. If a dev doesn't want the label, they can remove it at their own risk. They can use a simple script if they want.

@willfaught
Copy link
Collaborator Author

All good points. Agreed.

millergarym pushed a commit to millergarym/antlr4 that referenced this issue Nov 16, 2016
millergarym pushed a commit to millergarym/antlr4 that referenced this issue Feb 19, 2017
pboyer pushed a commit that referenced this issue Mar 11, 2017
Dotnetcore build target with full runtime-testsuite and travis
pboyer pushed a commit that referenced this issue Mar 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants