Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions unified/extractor/src/languages/swift/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
rule!((sequenceExpr elements: _* @els) => (unresolved_operator_sequence element: {els})),
// Prefix unary operators (`!a`, `-x`).
rule!((prefixOperatorExpr operator: @@op expression: @operand) => (unary_expr operator: (prefix_operator #{op}) operand: {operand})),
// Postfix unary operators (e.g., `x!`, `x...`, `x++`).
rule!(
(postfixOperatorExpr expression: @operand operator: @@op)
=>
(unary_expr operator: (postfix_operator #{op}) operand: {operand})
),
// In-out expressions, `&x`, are translated to unary expressions.
rule!(
(inOutExpr ampersand: @@amp expression: @operand)
=>
(unary_expr operator: (prefix_operator #{amp}) operand: {operand})
),
// A parenthesised expression has a single tuple element; elide the
// grouping and preserve the expression itself. Actual tuple literals
// retain their translated labeled elements as `argument` children.
Expand Down Expand Up @@ -1393,7 +1405,6 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
rule!((fallThroughStmt) => (unsupported_node)),
rule!((ifConfigDecl) => (unsupported_node)),
rule!((implicitlyUnwrappedOptionalType) => (unsupported_node)),
rule!((inOutExpr) => (unsupported_node)),
rule!((inlineArrayType) => (unsupported_node)),
rule!((keyPathExpr) => (unsupported_node)),
rule!((macroDecl) => (unsupported_node)),
Expand All @@ -1405,7 +1416,6 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
rule!((packExpansionExpr) => (unsupported_node)),
rule!((packExpansionType) => (unsupported_node)),
rule!((postfixIfConfigExpr) => (unsupported_node)),
rule!((postfixOperatorExpr) => (unsupported_node)),
rule!((poundSourceLocation) => (unsupported_node)),
rule!((precedenceGroupDecl) => (unsupported_node)),
rule!((someOrAnyType) => (unsupported_node)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ top_level source="⟨body⟩"
callee: identifier "swap" source="swap"
argument:
argument source="⟨value⟩"
value: unsupported_node "&a" source="&a"
value:
unary_expr source="⟨operator⟩⟨operand⟩"
operand: identifier "a" source="a"
operator: prefix_operator "&" source="&"
argument source="⟨value⟩"
value: unsupported_node "&b" source="&b"
value:
unary_expr source="⟨operator⟩⟨operand⟩"
operand: identifier "b" source="b"
operator: prefix_operator "&" source="&"
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ top_level source="⟨body⟩"
variable_declaration source="⟨modifier⟩ ⟨pattern⟩ = ⟨value⟩"
modifier: modifier "let" source="let"
pattern: identifier "squared" source="squared"
value: unsupported_node "3^^" source="3^^"
value:
unary_expr source="⟨operand⟩⟨operator⟩"
operand: int_literal "3" source="3"
operator: postfix_operator "^^" source="^^"
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ top_level source="⟨body⟩"
variable_declaration source="⟨modifier⟩ ⟨pattern⟩ = ⟨value⟩"
modifier: modifier "let" source="let"
pattern: identifier "range" source="range"
value: unsupported_node "3..." source="3..."
value:
unary_expr source="⟨operand⟩⟨operator⟩"
operand: int_literal "3" source="3"
operator: postfix_operator "..." source="..."
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
| 90 | cfg.swift:90:3:92:3 | func addOptional | 'func addOptional' |
| 90 | cfg.swift:90:20:90:20 | a | 'a -> Block' |
| 91 | cfg.swift:91:5:91:5 | a | 'a -> nil -^ ... = ...' |
| 94 | cfg.swift:94:3:94:5 | add | 'add -> Argument -V -^ add(...)' |
| 94 | cfg.swift:94:3:94:5 | add | 'add -> Argument -V temp -^ & ... -^ add(...)' |
| 95 | cfg.swift:95:3:95:30 | var tempOptional | 'var tempOptional -V tempOptional -> Optional -> Int -^ GenericTypeExpr -> 10' |
| 96 | cfg.swift:96:3:96:13 | addOptional | 'addOptional -> Argument -V -^ addOptional(...)' |
| 96 | cfg.swift:96:3:96:13 | addOptional | 'addOptional -> Argument -V tempOptional -^ & ... -^ addOptional(...)' |
| 97 | cfg.swift:97:10:97:13 | temp | 'temp -> tempOptional -^ ... ! -^ ... + ... -^ ReturnExpr' |
| 100 | cfg.swift:100:1:109:1 | class C | 'class C -V C' |
| 101 | cfg.swift:101:3:101:16 | let myInt | 'let myInt -V myInt -> Int' |
Expand Down
Loading