-
Notifications
You must be signed in to change notification settings - Fork 173
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
Implement attribute visitors #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All my comments are about the implementation of the codegen. Everything else LGTM.
@DragonMinded, can you rebase on master so that codecov verifies the test coverage for you? |
…sitor. This allows Pyre to typecheck returns inside visitors for us.
We want to make sure that the generated function stubs stay in sync with the node definitions. So, make a unit test that fails if codegen generates a different file than the existing file, so that somebody modifying code knows they need to re-run codegen.
Adds a BaseStatement type which can be used to specify in types that you can accept either a compound statement or a simple statement line.
There are a lot of nodes that cannot be removed or converted to maybes, such as most of the Op tokens. It would be a bit of a lie to codegen leave_* methods that allow these nodes to be converted, only to throw a runtime error later. So, upgrade the codegen to allow us to see whether certain nodes are used in conjunction with a MaybeSentinel/None, or inside a Sequence, to inform ourselves as to when to allow MaybeSentinel or RemovalSentinel.
Codecov Report
@@ Coverage Diff @@
## master #27 +/- ##
==========================================
- Coverage 95.78% 95.77% -0.02%
==========================================
Files 112 117 +5
Lines 6745 11130 +4385
==========================================
+ Hits 6461 10660 +4199
- Misses 284 470 +186
Continue to review full report at Codecov.
|
Can we have a follow up PR to explain the newly added attribute visitors? We can provide some examples in the |
Question: what's the execution order of attribute functions on the same Node? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the comments, LGTM.
Let me put up another PR with documentation fixes, since this one is starting to get large. |
Summary
It can be useful in a variety of situations to know what attribute of a node you are currently visiting children on. So, implement the ability to track this via attribute visit_ and leave_ support. This pull request finishes support to visit on attributes, adds a test to verify visitor behavior, and adds codegen for attribute visitor functions.
Note that this is on top of the existing pull request for codegen (#23).
Test Plan
tox