AST Improvements #6183
Replies: 5 comments 1 reply
-
NamingAvoid abbreviationsCompiler terminology can be hard to approach, even more so if the code heavily uses abbreviations. Our AST uses plenty of them
I propose that we write out all names in full. Doing so also fixes inconsistency in our AST. For example, we already use The main disadvantage is that things no need a few keystrokes more to write out, but IDEs are pretty good add helping us with that. Type postfixOur AST uses a prefix notation to denote to which kind a node belongs:
|
Beta Was this translation helpful? Give feedback.
-
Structural changesImplicitly concatenated stringsIt is important to know during formatting whether a string is implicitly concatenated or not, but the AST doesn't expose this information and the formatter has to iterate over the whole string. I recommend that we include this information in the AST and remove the parser's automatic joining of strings with implicit concatenation into a single
Open questions:
Alternatives:
Async / Sync variantsThere are multiple nodes with a sync/async variant. I recommend merging them and instead adding a When building interpreters, distinguishing between a sync and async function makes sense because they have fundamentally different execution models. However, we almost always treat them the same during linting and formatting. We've created
|
Beta Was this translation helpful? Give feedback.
-
Remove unsupported fields & nodesRemove the following fields and nodes that are not supported by the parser:
|
Beta Was this translation helpful? Give feedback.
-
This is awesome! |
Beta Was this translation helpful? Give feedback.
-
I may do "Async / Sync variants" quickly for fun, I need something light to work on and this bothers me. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We integrated RustPython's AST into Ruff last week. This makes it easier for us to make changes to the AST that better suit the needs of static analysis (Python compatibility is a non-goal) or make it more approachable.
I want to use this discussion to propose a few improvements that we can implement independently if we agree.
Beta Was this translation helpful? Give feedback.
All reactions