Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7a573c4
yeast: Order AST dump fields by schema-declared order
tausbn Jul 16, 2026
8206f6f
swift-syntax-rs: Fold local and stdlib operators
tausbn Jul 16, 2026
2e74c1d
yeast: Desugar an externally-built AST, and validate by field name
tausbn Jul 16, 2026
bbf52ce
tree-sitter-extractor: Split direct and desugaring extractors
tausbn Jul 17, 2026
79954ce
unified: Add the swift-syntax parser and unresolved operator sequence…
tausbn Jul 17, 2026
ad2ce93
unified: Port top-level, literal, and name rules to swift-syntax
tausbn Jul 16, 2026
8328fba
unified: Port operator rules to swift-syntax
tausbn Jul 17, 2026
437e482
unified: Port variable-binding rules to swift-syntax
tausbn Jul 17, 2026
191fc54
unified: Port type-expression rules to swift-syntax
tausbn Jul 17, 2026
52cdf59
unified: Port function, call, and member-access rules to swift-syntax
tausbn Jul 17, 2026
6ad1fac
unified: Port closure rules to swift-syntax
tausbn Jul 17, 2026
2de1549
unified: Port control-flow and pattern rules to swift-syntax
tausbn Jul 20, 2026
2fcbc9b
unified: Port loop rules to swift-syntax
tausbn Jul 20, 2026
4c764b5
unified: Port collection rules to swift-syntax
tausbn Jul 20, 2026
6275977
unified: Port optional and error-handling rules to swift-syntax
tausbn Jul 20, 2026
37654b4
unified: Port import rules to swift-syntax
tausbn Jul 20, 2026
8e6651a
unified: Port type-container declarations to swift-syntax
tausbn Jul 20, 2026
ec0c49a
unified: Port property accessor rules to swift-syntax
tausbn Jul 22, 2026
90ea1b5
unified: Port enum-case rules to swift-syntax
tausbn Jul 23, 2026
c4fbd74
unified: Port constructor and related declaration rules to swift-syntax
tausbn Jul 23, 2026
5c5fd5e
unified: Switch the Swift front-end to swift-syntax
tausbn Jul 23, 2026
20a2537
unified: Regenerate the raw-AST corpus section for swift-syntax
tausbn Jul 23, 2026
046c88a
unified: Regenerate the enhanced getter/setter property corpus case
tausbn Jul 23, 2026
c50bcba
swift-syntax-rs: Degrade gracefully without a Swift toolchain
tausbn Jul 23, 2026
17cbb4e
unified: Harden the external Swift parser integration
tausbn Jul 24, 2026
7721ce2
unified: Add swift_node_types.yml to the extractor's compile_data
tausbn Jul 24, 2026
e3a0822
unified: Package the swift-syntax parser in the extractor pack
tausbn Jul 24, 2026
ba26e1d
unified: Add corpus tests for nested types
tausbn Jul 27, 2026
a3d9492
Merge branch 'main' into tausbn/swift-syntax-rs-sequenced
tausbn Jul 28, 2026
a2ff35a
unified: Fix Bazel formatting errors
tausbn Jul 28, 2026
ceffe40
unified: Remove references to Swift input schema generation
tausbn Jul 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 21 additions & 35 deletions unified/extractor/src/languages/swift/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,9 @@ fn member_chain(
fn translation_rules() -> Vec<Rule<SwiftContext>> {
vec![
// ---- Top-level ----
// Capture all top-level statements, including unnamed tokens like `nil`.
rule!(
(source_file statement: _* @children)
=>
(top_level
body: (block stmt: {children})
)
),
// Declarations may be wrapped in local/global wrapper nodes.
rule!((global_declaration _ @inner) => stmt { inner }),
rule!((local_declaration _ @inner) => stmt { inner }),
// ---- swift-syntax front-end (minimal hook-up) ----
// These rules target the swift-syntax AST (camelCase kind names),
// produced by the sibling `adapter` module. They coexist with the
// tree-sitter rules (snake_case names): rules are dispatched by exact
// kind name, and the two name spaces never collide, so these are inert
// on the tree-sitter path. Only the minimal top-level mapping lives here
// to demonstrate the pipeline end-to-end; the full translation is added
// separately. Unmatched swift-syntax nodes fall through to the
// These rules translate the swift-syntax AST (camelCase kind names),
// produced by the sibling `adapter` module from the `swift-syntax-parse`
// binary's JSON. Anything unmatched falls through to the
// `unsupported_node` fallback at the end.
//
// `sourceFile` holds its top-level statements in an (elided)
Expand All @@ -155,23 +139,25 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
),
rule!((codeBlockItem item: @item) => stmt { item }),
// ---- Literals ----
rule!((integer_literal) => (int_literal)),
rule!((hex_literal) => (int_literal)),
rule!((bin_literal) => (int_literal)),
rule!((oct_literal) => (int_literal)),
rule!((real_literal) => (float_literal)),
rule!((boolean_literal) => (boolean_literal)),
rule!("nil" => (builtin_expr)),
rule!((special_literal) => (builtin_expr)),
rule!((line_string_literal) => (string_literal)),
rule!((multi_line_string_literal) => (string_literal)),
rule!((raw_string_literal) => (string_literal)),
rule!((regex_literal) => (regex_literal)),
// swift-syntax does not distinguish the lexical integer/string forms
// (hex/binary/octal, single- vs multi-line, raw): each is a single
// `*LiteralExpr` kind, so the tree-sitter variants collapse to one rule.
Comment thread
jketema marked this conversation as resolved.
rule!((integerLiteralExpr) => (int_literal)),
rule!((floatLiteralExpr) => (float_literal)),
rule!((booleanLiteralExpr) => (boolean_literal)),
rule!((nilLiteralExpr) => (builtin_expr)),
rule!((stringLiteralExpr) => (string_literal)),
rule!((regexLiteralExpr) => (regex_literal)),
// ---- Names ----
rule!((simple_identifier) @id => (name_expr identifier: (identifier #{id}))),
// A referenceable_operator (e.g. `+` used as a value, as in `reduce(0, +)`)
// is treated as a name reference to the operator symbol.
rule!((referenceable_operator) @op => (name_expr identifier: (identifier #{op}))),
// A bare name reference (`x`), and an operator used as a value (`+` in
// `reduce(0, +)`), are both `declReferenceExpr`; its `baseName` is the
// referenced identifier / operator symbol.
rule!((declReferenceExpr baseName: @name) => (name_expr identifier: (identifier #{name}))),
// A discard `_` used as an expression — e.g. the target of a discarding
// assignment `_ = x`. swift-syntax models it as a `discardAssignmentExpr`;
// the tree-sitter path treated the bare `_` as a name, so map it to a
// `name_expr` too.
rule!((discardAssignmentExpr wildcard: @@w) => (name_expr identifier: (identifier #{w}))),
// ---- Operators ----
// All binary operators share the lhs/op/rhs shape.
rule!((additive_expression lhs: @l op: @op rhs: @r) => (binary_expr left: {l} operator: (infix_operator #{op}) right: {r})),
Expand Down