Skip to content

Commit 7854a53

Browse files
committed
unified: stop operators bleeding through everywhere
We make _referenceable_operator a named node. This prevents it from bleeding through to the _expression definition. It likely also makes the output easier to deal with, as bare operators used as arguments now have a named node wrapping them in the AST. Also removes a duplicated inclusion of _comparison_operator that served no purpose.
1 parent 76a1a87 commit 7854a53

2 files changed

Lines changed: 82 additions & 81 deletions

File tree

unified/extractor/tree-sitter-swift/grammar.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ module.exports = grammar({
105105
// `+(...)` is ambigously either "call the function produced by a reference to the operator `+`" or "use the unary
106106
// operator `+` on the result of the parenthetical expression."
107107
[$._additive_operator, $._prefix_unary_operator],
108-
[$._referenceable_operator, $._prefix_unary_operator],
108+
[$.referenceable_operator, $._prefix_unary_operator],
109109
// `{ [self, b, c] ...` could be a capture list or an array literal depending on what else happens.
110110
[$.capture_list_item, $._expression],
111111
[$.capture_list_item, $._expression, $._simple_user_type],
@@ -906,7 +906,7 @@ module.exports = grammar({
906906
$.super_expression,
907907
$.try_expression,
908908
$.await_expression,
909-
$._referenceable_operator,
909+
$.referenceable_operator,
910910
$.key_path_expression,
911911
$.key_path_string_expression,
912912
prec.right(
@@ -1625,16 +1625,15 @@ module.exports = grammar({
16251625
_non_constructor_function_decl: ($) =>
16261626
seq(
16271627
"func",
1628-
field("name", choice($.simple_identifier, $._referenceable_operator))
1628+
field("name", choice($.simple_identifier, $.referenceable_operator))
16291629
),
1630-
_referenceable_operator: ($) =>
1630+
referenceable_operator: ($) =>
16311631
choice(
16321632
$.custom_operator,
16331633
$._comparison_operator,
16341634
$._additive_operator,
16351635
$._multiplicative_operator,
16361636
$._equality_operator,
1637-
$._comparison_operator,
16381637
$._assignment_and_operator,
16391638
"++",
16401639
"--",
@@ -1806,7 +1805,7 @@ module.exports = grammar({
18061805
seq(
18071806
choice("prefix", "infix", "postfix"),
18081807
"operator",
1809-
$._referenceable_operator,
1808+
$.referenceable_operator,
18101809
optional(seq(":", $.simple_identifier)),
18111810
optional($.deprecated_operator_declaration_body)
18121811
),

0 commit comments

Comments
 (0)