Skip to content

Unified: More work on AST and Swift mappings#21962

Draft
asgerf wants to merge 17 commits into
github:mainfrom
asgerf:commonast-rebased3
Draft

Unified: More work on AST and Swift mappings#21962
asgerf wants to merge 17 commits into
github:mainfrom
asgerf:commonast-rebased3

Conversation

@asgerf

@asgerf asgerf commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Known limitations:

  • Patterns are poorly handled as the parse tree we get from tree-sitter-swift is hard to use, and fixing it involves handling some non-trivial parsing ambiguities.

asgerf and others added 8 commits June 2, 2026 10:38
After a {expr} or {..expr} placeholder, an optional chain of
.<builtin>() calls may follow. Currently the only builtin is:

  .map(param -> template)

which applies the template to each element of the iterable and
collects the resulting node IDs. A chain auto-splices into the
enclosing field/child position.

Example:
  path: {parts}.map(p -> (identifier #{p}))

The framework is extensible: additional builtins can be added by
matching on the method name in parse_chain_suffix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A left fold over an iterable where the first element seeds the accumulator:
- first -> init  : converts the first element to the initial accumulator
- acc, elem -> fold : fold step; acc = current accumulator, elem = next element
- Empty iterable produces nothing (0-element splice)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Ensure the full wildcard _ supports quantifiers
- Also rewrite unnamed nodes in one-shot phases
When a field pattern has a bare capture with no preceding pattern
atom (i.e. `foo: @bar`), implicitly use a true wildcard (`_`,
match_unnamed: true) as the node pattern, making it equivalent to
`foo: _ @bar`.

This is a convenience shorthand: in practice every `field: _ @cap`
in the Swift rules can now be written more concisely as `field: @cap`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@asgerf asgerf added the no-change-note-required This PR does not need a change note label Jun 9, 2026

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@asgerf asgerf force-pushed the commonast-rebased3 branch from 6089867 to 1537a26 Compare June 9, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants