-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Remove redundant artificial rules and functions for them in parser.c file #124889
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
Labels
Comments
efimov-mikhail
added a commit
to efimov-mikhail/cpython
that referenced
this issue
Oct 2, 2024
Cache in C PEG-generator reworked: we save artificial rules in cache by Node string representation as a key instead of Node object itself. As a result total count of artificial rules in parsers.c is lowered from 283 to 170. More natural number ordering is used for the names of artificial rules.
efimov-mikhail
added a commit
to efimov-mikhail/cpython
8000
that referenced
this issue
Oct 3, 2024
Cache in C PEG-generator reworked: we save artificial rules in cache by Node string representation as a key instead of Node object itself. As a result total count of artificial rules in parsers.c is lowered from 283 to 170. More natural number ordering is used for the names of artificial rules.
efimov-mikhail
added a commit
to efimov-mikhail/cpython
that referenced
this issue
Oct 3, 2024
…ython#124893) Auxiliary method CCallMakerVisitor._generate_artificial_rule_call is added. Its purpose is abstracting work with artificial rules cache.
efimov-mikhail
added a commit
to efimov-mikhail/cpython
that referenced
this issue
Oct 3, 2024
python#124893) Explicit using of "is_repeat1" kwarg is added to visit_Repeat0 and visit_Repeat1 methods. Its slightly improve code readabitily.
pablogsal
pushed a commit
that referenced
this issue
Oct 3, 2024
Cache in C PEG-generator reworked: we save artificial rules in cache by Node string representation as a key instead of Node object itself. As a result total count of artificial rules in parsers.c is lowered from 283 to 170. More natural number ordering is used for the names of artificial rules. Auxiliary method CCallMakerVisitor._generate_artificial_rule_call is added. Its purpose is abstracting work with artificial rules cache. Explicit using of "is_repeat1" kwarg is added to visit_Repeat0 and visit_Repeat1 methods. Its slightly improve code readabitily.
Is this finished? |
The original issue has been implemented. |
I agree that this should be closed. |
efimov-mikhail
added a commit
to efimov-mikhail/cpython
that referenced
this issue
Oct 21, 2024
efimov-mikhail
added a commit
to efimov-mikhail/cpython
that referenced
this issue
Oct 21, 2024
pablogsal
pushed a commit
that referenced
this issue
Oct 22, 2024
ebonnal
pushed a commit
to ebonnal/cpython
that referenced
this issue
Jan 12, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
It seems like PEG parser produces more than one artificial rule for the same grammar rule.
For example, on each gather rule (','.NAME+) in Grammar/python.gram a function '_gather_N_rule' will be generated.
But only one implementation of such function makes sense, others are just redundant.
Some simple changes in Tools/peg_generator/pegen/c_generator.py file should be made.
We can save artificial rules in cache by Node string representation as a key instead of Node object itself.
Total count of artificial rules can be lowered from 283 to 170 with this change, size of parser.c file can be lowered from 1.5 megabytes to 1.3 megabytes without any cost.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: