Skip to content

Commit 2168ab9

Browse files
maxbrunsfeldMatthew Krupcale
andcommitted
Add supertypes
Co-Authored-By: Matthew Krupcale <[email protected]>
1 parent 85b04c5 commit 2168ab9

File tree

6 files changed

+45987
-55011
lines changed

6 files changed

+45987
-55011
lines changed

corpus/expressions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ let msg = match x {
397397
(match_expression (identifier) (match_block
398398
(match_arm (match_pattern (integer_literal)) (block (string_literal)))
399399
(match_arm (match_pattern (integer_literal)) (string_literal))
400-
(match_arm (match_pattern (integer_literal)) (integer_literal))
401-
(match_arm (match_pattern (float_literal)) (integer_literal))
400+
(match_arm (match_pattern (negative_literal (integer_literal))) (integer_literal))
401+
(match_arm (match_pattern (negative_literal (float_literal))) (integer_literal))
402402
(match_arm
403403
(attribute_item (meta_item (identifier)))
404404
(match_pattern (integer_literal)) (string_literal))

grammar.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ module.exports = grammar({
4747
$.block_comment,
4848
],
4949

50+
supertypes: $ => [
51+
$._expression,
52+
$._type,
53+
$._literal,
54+
$._literal_pattern,
55+
$._declaration_statement,
56+
$._pattern,
57+
],
58+
5059
inline: $ => [
5160
$._path,
5261
$._type_identifier,
@@ -1296,9 +1305,13 @@ module.exports = grammar({
12961305
$.raw_string_literal,
12971306
$.char_literal,
12981307
$.boolean_literal,
1299-
seq(optional('-'), choice($.integer_literal, $.float_literal)),
1308+
$.integer_literal,
1309+
$.float_literal,
1310+
$.negative_literal,
13001311
),
13011312

1313+
negative_literal: $ => seq('-', choice($.integer_literal, $.float_literal)),
1314+
13021315
integer_literal: $ => token(seq(
13031316
choice(
13041317
/[0-9][0-9_]*/,

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"tree-sitter": [
2323
{
2424
"scope": "source.rust",
25-
"highlights": "src/highlights.json",
2625
"injection-regex": "rust",
2726
"file-types": [
2827
"rs"

src/grammar.json

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7436,32 +7436,36 @@
74367436
"name": "boolean_literal"
74377437
},
74387438
{
7439-
"type": "SEQ",
7439+
"type": "SYMBOL",
7440+
"name": "integer_literal"
7441+
},
7442+
{
7443+
"type": "SYMBOL",
7444+
"name": "float_literal"
7445+
},
7446+
{
7447+
"type": "SYMBOL",
7448+
"name": "negative_literal"
7449+
}
7450+
]
7451+
},
7452+
"negative_literal": {
7453+
"type": "SEQ",
7454+
"members": [
7455+
{
7456+
"type": "STRING",
7457+
"value": "-"
7458+
},
7459+
{
7460+
"type": "CHOICE",
74407461
"members": [
74417462
{
7442-
"type": "CHOICE",
7443-
"members": [
7444-
{
7445-
"type": "STRING",
7446-
"value": "-"
7447-
},
7448-
{
7449-
"type": "BLANK"
7450-
}
7451-
]
7463+
"type": "SYMBOL",
7464+
"name": "integer_literal"
74527465
},
74537466
{
7454-
"type": "CHOICE",
7455-
"members": [
7456-
{
7457-
"type": "SYMBOL",
7458-
"name": "integer_literal"
7459-
},
7460-
{
7461-
"type": "SYMBOL",
7462-
"name": "float_literal"
7463-
}
7464-
]
7467+
"type": "SYMBOL",
7468+
"name": "float_literal"
74657469
}
74667470
]
74677471
}
@@ -7980,6 +7984,13 @@
79807984
"_reserved_identifier",
79817985
"_expression_ending_with_block"
79827986
],
7983-
"supertypes": []
7987+
"supertypes": [
7988+
"_expression",
7989+
"_type",
7990+
"_literal",
7991+
"_literal_pattern",
7992+
"_declaration_statement",
7993+
"_pattern"
7994+
]
79847995
}
79857996

0 commit comments

Comments
 (0)