Skip to content

Commit 3ad0430

Browse files
committed
Don't match metavariables in macro invocations
Metavariables can only occur in macro transcribers, so matching them in invocations makes little sense. Instead, match $ and an identifier separately.
1 parent 4dc2147 commit 3ad0430

File tree

3 files changed

+65841
-65452
lines changed

3 files changed

+65841
-65452
lines changed

grammar.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ module.exports = grammar({
191191
),
192192

193193
_non_special_token: $ => choice(
194-
$._literal, $.identifier, $.metavariable, $.mutable_specifier, $.self, $.super, $.crate,
194+
$._never_special_token,
195+
$.metavariable
196+
),
197+
198+
_never_special_token: $ => choice(
199+
$._literal, $.identifier, $.mutable_specifier, $.self, $.super, $.crate,
195200
alias(choice(...primitive_types), $.primitive_type),
196201
/[/_\-=->,;:::!=?.@*&#%^+<>|~]+/,
197202
'\'',
@@ -906,7 +911,7 @@ module.exports = grammar({
906911
),
907912

908913
_non_delim_token: $ => choice(
909-
$._non_special_token,
914+
$._never_special_token,
910915
'$'
911916
),
912917

src/grammar.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,15 +658,24 @@
658658
"members": [
659659
{
660660
"type": "SYMBOL",
661-
"name": "_literal"
661+
"name": "_never_special_token"
662662
},
663663
{
664664
"type": "SYMBOL",
665-
"name": "identifier"
665+
"name": "metavariable"
666+
}
667+
]
668+
},
669+
"_never_special_token": {
670+
"type": "CHOICE",
671+
"members": [
672+
{
673+
"type": "SYMBOL",
674+
"name": "_literal"
666675
},
667676
{
668677
"type": "SYMBOL",
669-
"name": "metavariable"
678+
"name": "identifier"
670679
},
671680
{
672681
"type": "SYMBOL",
@@ -5026,7 +5035,7 @@
50265035
"members": [
50275036
{
50285037
"type": "SYMBOL",
5029-
"name": "_non_special_token"
5038+
"name": "_never_special_token"
50305039
},
50315040
{
50325041
"type": "STRING",

0 commit comments

Comments
 (0)