mirror of
https://github.com/github/codeql.git
synced 2026-05-14 03:09:26 +02:00
unified: Group more paired items
Same as in the preceding commit, these items do not make sense as separate fields on the parent node, so we materialise (or create new) intermediate nodes to group them together.
This commit is contained in:
@@ -105,8 +105,8 @@ module.exports = grammar({
|
||||
// { (foo, bar) ...
|
||||
[$.expression, $.lambda_parameter],
|
||||
[$._primary_expression, $.lambda_parameter],
|
||||
// (start: start, end: end)
|
||||
[$._tuple_type_item_identifier, $.tuple_expression],
|
||||
// (foo) where foo could be a binding pattern or a tuple expression item.
|
||||
[$._binding_pattern_with_expr, $.tuple_expression_item],
|
||||
// After a `{` in a function or switch context, it's ambigous whether we're starting a set of local statements or
|
||||
// applying some modifiers to a capture or pattern.
|
||||
[$.modifiers],
|
||||
@@ -931,26 +931,25 @@ module.exports = grammar({
|
||||
PRECS.tuple,
|
||||
seq(
|
||||
"(",
|
||||
sep1Opt(
|
||||
seq(
|
||||
optional(seq(field("name", $.simple_identifier), ":")),
|
||||
field("value", $.expression)
|
||||
),
|
||||
","
|
||||
),
|
||||
sep1Opt(field("element", $.tuple_expression_item), ","),
|
||||
")"
|
||||
)
|
||||
),
|
||||
tuple_expression_item: ($) =>
|
||||
seq(
|
||||
optional(seq(field("name", $.simple_identifier), ":")),
|
||||
field("value", $.expression)
|
||||
),
|
||||
array_literal: ($) =>
|
||||
seq("[", optional(sep1Opt(field("element", $.expression), ",")), "]"),
|
||||
dictionary_literal: ($) =>
|
||||
seq(
|
||||
"[",
|
||||
choice(":", sep1Opt($._dictionary_literal_item, ",")),
|
||||
choice(":", sep1Opt(field("element", $.dictionary_literal_item), ",")),
|
||||
optional(","),
|
||||
"]"
|
||||
),
|
||||
_dictionary_literal_item: ($) =>
|
||||
dictionary_literal_item: ($) =>
|
||||
seq(field("key", $.expression), ":", field("value", $.expression)),
|
||||
special_literal: ($) =>
|
||||
seq(
|
||||
@@ -968,11 +967,13 @@ module.exports = grammar({
|
||||
playground_literal: ($) =>
|
||||
seq(
|
||||
$._hash_symbol,
|
||||
choice("colorLiteral", "fileLiteral", "imageLiteral"),
|
||||
field("kind", choice("colorLiteral", "fileLiteral", "imageLiteral")),
|
||||
"(",
|
||||
sep1Opt(seq(field("name", $.simple_identifier), ":", field("value", $.expression)), ","),
|
||||
sep1Opt(field("argument", $.playground_literal_argument), ","),
|
||||
")"
|
||||
),
|
||||
playground_literal_argument: ($) =>
|
||||
seq(field("name", $.simple_identifier), ":", field("value", $.expression)),
|
||||
lambda_literal: ($) =>
|
||||
prec.left(
|
||||
PRECS.lambda,
|
||||
|
||||
@@ -248,8 +248,10 @@ named:
|
||||
entry*: [bin_literal, boolean_literal, hex_literal, integer_literal, line_string_literal, multi_line_string_literal, "nil", oct_literal, raw_string_literal, real_literal, regex_literal, simple_identifier]
|
||||
diagnostic:
|
||||
dictionary_literal:
|
||||
key*: expression
|
||||
value*: expression
|
||||
element*: dictionary_literal_item
|
||||
dictionary_literal_item:
|
||||
key: expression
|
||||
value: expression
|
||||
dictionary_type:
|
||||
key: type
|
||||
value: type
|
||||
@@ -483,8 +485,11 @@ named:
|
||||
bound_identifier?: simple_identifier
|
||||
kind: [binding_pattern, case_pattern, expression, tuple_pattern, type_casting_pattern, wildcard_pattern]
|
||||
playground_literal:
|
||||
name+: simple_identifier
|
||||
value+: expression
|
||||
argument+: playground_literal_argument
|
||||
kind: ["colorLiteral", "fileLiteral", "imageLiteral"]
|
||||
playground_literal_argument:
|
||||
name: simple_identifier
|
||||
value: expression
|
||||
postfix_expression:
|
||||
operation: ["++", "--", bang]
|
||||
target: expression
|
||||
@@ -613,8 +618,10 @@ named:
|
||||
operator: try_operator
|
||||
try_operator:
|
||||
tuple_expression:
|
||||
name*: simple_identifier
|
||||
value+: expression
|
||||
element+: tuple_expression_item
|
||||
tuple_expression_item:
|
||||
name?: simple_identifier
|
||||
value: expression
|
||||
tuple_pattern:
|
||||
item+: tuple_pattern_item
|
||||
tuple_pattern_item:
|
||||
|
||||
Reference in New Issue
Block a user