Skip to content

[v2] Extend AST to wrap terminals#1751

Merged
ggiraldez merged 17 commits into
mainfrom
ggiraldez/v2-extended-unique-terminals
May 11, 2026
Merged

[v2] Extend AST to wrap terminals#1751
ggiraldez merged 17 commits into
mainfrom
ggiraldez/v2-extended-unique-terminals

Conversation

@ggiraldez

@ggiraldez ggiraldez commented May 7, 2026

Copy link
Copy Markdown
Contributor

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> with id: NodeId and range). Optional sequence fields go from bool to Option<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::Nonterminal is gone and the IR-codegen model now distinguishes Sequence, Choice, Collection, Terminal, UniqueTerminal, and the new External kind. Templates dispatch on kind/is_terminal/is_external directly instead of looking up the kind on the side. Choice variants for unique terminals lose their Eq/Hash derives along the way (those types no longer make sense as set keys).

  • Shorten the auto-generated expression_<X>_expression_operator precedence-operator field names down to a uniform operator everywhere.

@changeset-bot

changeset-bot Bot commented May 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 9de9a73

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ggiraldez ggiraldez requested review from OmarTawfik and teofr May 7, 2026 21:54
@ggiraldez ggiraldez marked this pull request as ready for review May 7, 2026 21:54
@ggiraldez ggiraldez requested review from a team as code owners May 7, 2026 21:54
@ggiraldez ggiraldez changed the title [v2] Extend AST to include terminals with text range [v2] Extend AST to wrap terminals May 7, 2026
Comment thread crates/codegen-v2/semantic/src/ir/builder.rs Outdated
Comment thread crates/codegen-v2/semantic/src/ir/builder.rs
Comment thread crates/solidity-v2/outputs/cargo/ast/src/ast/node_extensions/functions.rs Outdated
Comment thread crates/solidity-v2/outputs/cargo/ast/src/ast/nodes.generated.rs Outdated
Comment thread crates/solidity-v2/outputs/cargo/ir/src/tests/builder.rs Outdated
@ggiraldez ggiraldez force-pushed the ggiraldez/v2-extended-unique-terminals branch from 969b363 to 9de9a73 Compare May 11, 2026 22:26
@ggiraldez ggiraldez enabled auto-merge May 11, 2026 22:27
@ggiraldez ggiraldez added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit d55d3d1 May 11, 2026
16 checks passed
@ggiraldez ggiraldez deleted the ggiraldez/v2-extended-unique-terminals branch May 11, 2026 22:59
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.

2 participants