[v2] Extend AST to wrap terminals#1751
Merged
Merged
Conversation
|
OmarTawfik
reviewed
May 11, 2026
OmarTawfik
approved these changes
May 11, 2026
969b363 to
9de9a73
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spawned from this comment thread.
Extends the IR/AST node-type model so the codegen produces a richer, more useful tree.
Avoid re-exporting IR types in the AST. This will make it easier to evolve them independently (eg. the AST will need to be serializable to JSON).
Unique terminals now have a real IR struct (
Rc<XStruct>withid: NodeIdandrange). Optional sequence fields go frombooltoOption<X>, choice variants carry an(X)payload, and the AST wraps them.Non-unique terminals are now wrapped in the AST as well. This will allow implementing some methods on them that require access to semantic information (eg. getting the type associated to a string expression).
Avoid re-using some IR types for typing/binding information. Eg. function visibility and mutability are now plain variant defined in
types. We can no longer easily re-use the IR types (reason being the previous item).NodeType::Nonterminalis gone and the IR-codegen model now distinguishesSequence,Choice,Collection,Terminal,UniqueTerminal, and the newExternalkind. Templates dispatch onkind/is_terminal/is_externaldirectly instead of looking up the kind on the side. Choice variants for unique terminals lose theirEq/Hashderives along the way (those types no longer make sense as set keys).Shorten the auto-generated
expression_<X>_expression_operatorprecedence-operator field names down to a uniformoperatoreverywhere.