Skip to content

Commit f44b017

Browse files
committed
Parse macro invocations containing $
1 parent e4e3d80 commit f44b017

File tree

4 files changed

+69869
-68882
lines changed

4 files changed

+69869
-68882
lines changed

grammar.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,23 @@ module.exports = grammar({
891891
$._reserved_identifier,
892892
)),
893893
'!',
894-
$.token_tree
894+
alias($.delim_token_tree, $.token_tree)
895+
),
896+
897+
delim_token_tree: $ => choice(
898+
seq('(', repeat($._delim_tokens), ')'),
899+
seq('[', repeat($._delim_tokens), ']'),
900+
seq('{', repeat($._delim_tokens), '}')
901+
),
902+
903+
_delim_tokens: $ => choice(
904+
$._non_delim_token,
905+
alias($.delim_token_tree, $.token_tree),
906+
),
907+
908+
_non_delim_token: $ => choice(
909+
$._non_special_token,
910+
'$'
895911
),
896912

897913
scoped_identifier: $ => seq(

src/grammar.json

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4927,9 +4927,110 @@
49274927
"type": "STRING",
49284928
"value": "!"
49294929
},
4930+
{
4931+
"type": "ALIAS",
4932+
"content": {
4933+
"type": "SYMBOL",
4934+
"name": "delim_token_tree"
4935+
},
4936+
"named": true,
4937+
"value": "token_tree"
4938+
}
4939+
]
4940+
},
4941+
"delim_token_tree": {
4942+
"type": "CHOICE",
4943+
"members": [
4944+
{
4945+
"type": "SEQ",
4946+
"members": [
4947+
{
4948+
"type": "STRING",
4949+
"value": "("
4950+
},
4951+
{
4952+
"type": "REPEAT",
4953+
"content": {
4954+
"type": "SYMBOL",
4955+
"name": "_delim_tokens"
4956+
}
4957+
},
4958+
{
4959+
"type": "STRING",
4960+
"value": ")"
4961+
}
4962+
]
4963+
},
4964+
{
4965+
"type": "SEQ",
4966+
"members": [
4967+
{
4968+
"type": "STRING",
4969+
"value": "["
4970+
},
4971+
{
4972+
"type": "REPEAT",
4973+
"content": {
4974+
"type": "SYMBOL",
4975+
"name": "_delim_tokens"
4976+
}
4977+
},
4978+
{
4979+
"type": "STRING",
4980+
"value": "]"
4981+
}
4982+
]
4983+
},
4984+
{
4985+
"type": "SEQ",
4986+
"members": [
4987+
{
4988+
"type": "STRING",
4989+
"value": "{"
4990+
},
4991+
{
4992+
"type": "REPEAT",
4993+
"content": {
4994+
"type": "SYMBOL",
4995+
"name": "_delim_tokens"
4996+
}
4997+
},
4998+
{
4999+
"type": "STRING",
5000+
"value": "}"
5001+
}
5002+
]
5003+
}
5004+
]
5005+
},
5006+
"_delim_tokens": {
5007+
"type": "CHOICE",
5008+
"members": [
49305009
{
49315010
"type": "SYMBOL",
4932-
"name": "token_tree"
5011+
"name": "_non_delim_token"
5012+
},
5013+
{
5014+
"type": "ALIAS",
5015+
"content": {
5016+
"type": "SYMBOL",
5017+
"name": "delim_token_tree"
5018+
},
5019+
"named": true,
5020+
"value": "token_tree"
5021+
}
5022+
]
5023+
},
5024+
"_non_delim_token": {
5025+
"type": "CHOICE",
5026+
"members": [
5027+
{
5028+
"type": "SYMBOL",
5029+
"name": "_non_special_token"
5030+
},
5031+
{
5032+
"type": "STRING",
5033+
"value": "$"
49335034
}
49345035
]
49355036
},

0 commit comments

Comments
 (0)