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

Don't add from __future__ import print_function in generated file #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

santazhang
Copy link

from __future__ import print_function must be placed at beginning of python file. But the user might have a header code section specified in .g file (before %% marker), and in this case the generated parser will not work. I think it's better to let users add from __future__ import print_function themselves.

`from __future__ import print_function` must be placed at beginning of python file. But the user might have a header code section specified in .g file (before %% marker), and in this case the generated parser will not work. I think it's better to let users add `from __future__ import print_function` themselves.
Users might or might not add `from __future__ import print_function`.
Generated code should work in either case.
@felixp7
Copy link

felixp7 commented Sep 23, 2015

I just ran into the same issue, and worked around it by editing the generated parser. The simpler solution is to insert the pre-parse code from the grammar file after the import statements, rather than before. Nothing else needs to be changed.

@jepler
Copy link

jepler commented Mar 7, 2018

#6 resolves this in a way that still allows the from __future__ import print_function to be in the generated file, similar to what @felixplesoianu described doing manually.

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

Successfully merging this pull request may close these issues.

3 participants