Skip to content

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

Merged
pablogsal merged 5 commits intopython:masterfrom
pablogsal:bpo36143
Mar 25, 2019
Merged

bpo-36143: Regenerate Lib/keyword.py from the Grammar and Tokens file using pgen#12456
pablogsal merged 5 commits intopython:masterfrom
pablogsal:bpo36143

Conversation

@pablogsal
Copy link
Copy Markdown
Member

@pablogsal pablogsal commented Mar 20, 2019

Comment thread Parser/pgen/keywordgen.py Outdated
Copy link
Copy Markdown
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 :-)

Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Parser/pgen/keywordgen.py Outdated
Copy link
Copy Markdown
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 :-)

Comment thread Lib/keyword.py Outdated
Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Parser/pgen/keywordgen.py
)
parser.add_argument(
"keyword_file",
type=argparse.FileType('w'),
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread Lib/keyword.py Outdated
Comment thread Parser/pgen/keywordgen.py
Comment thread Parser/pgen/keywordgen.py Outdated
Comment thread Lib/keyword.py
'while',
'with',
'yield'
]
Copy link
Copy Markdown
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.

Comment thread Parser/pgen/keywordgen.py
)
parser.add_argument(
"keyword_file",
type=argparse.FileType('w'),
Copy link
Copy Markdown
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.

5 participants