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

bpo-36143: Regenerate Lib/keyword.py from the Grammar and Tokens file using pgen #12456

Merged
merged 5 commits into from Mar 25, 2019

Conversation

pablogsal
Copy link
Member

@pablogsal pablogsal commented Mar 20, 2019

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Travis CI tests passed on this PR: it runs "make regean-all" and make sure that generated files are unchanged. So it means that your generator works ;-)

I proposed minor coding style changes, it's up to you to ignore them or not :-)

Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It's now perfect, thanks :-)

Lib/keyword.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
)
parser.add_argument(
"keyword_file",
type=argparse.FileType('w'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to make the script working on read-only sources (doing nothing if the file is not changed). See for example Tools/scripts/generate_token.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I am not sure I understand exactly what do you mean :(

Can you elaborate a bit more? Or if you want to do it directly, please, push directly to my branch to update the PR :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See "make regen-opcode": Antoine Pitrou wrote $(UPDATE_FILE) which leaves the file unchanged if the content didn't change. One advantage is to not touch the modification time of the file at all. It matters for Makefile to avoid useless recompilation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to use function update_file() from Tools/scripts/generate_token.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I like update_file() approach, I also like the fact that $(UPDATE_FILE) will check that the files are updated in every PR if someone changes the generator as this has been very valuable for gramminit.c and friends.

Lib/keyword.py Outdated Show resolved Hide resolved
Parser/pgen/keywordgen.py Show resolved Hide resolved
Parser/pgen/keywordgen.py Outdated Show resolved Hide resolved
'while',
'with',
'yield'
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@serhiy-storchaka: Sorry, I'm the one who asked @pablogsal to write 'yield']. It doesn't matter, I'm fine with "]" on a separated line as well.

)
parser.add_argument(
"keyword_file",
type=argparse.FileType('w'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See "make regen-opcode": Antoine Pitrou wrote $(UPDATE_FILE) which leaves the file unchanged if the content didn't change. One advantage is to not touch the modification time of the file at all. It matters for Makefile to avoid useless recompilation.

@pablogsal pablogsal merged commit 91759d9 into python:master Mar 25, 2019
@pablogsal pablogsal deleted the bpo36143 branch March 25, 2019 22:01
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.

None yet

5 participants