Skip to content

Commit e3ad491

Browse files
committed
Parse macro invocations containing $
1 parent 3b94fc3 commit e3ad491

File tree

3 files changed

+62764
-61589
lines changed

3 files changed

+62764
-61589
lines changed

grammar.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,23 @@ module.exports = grammar({
879879
$.identifier
880880
)),
881881
'!',
882-
$.token_tree
882+
alias($.delim_token_tree, $.token_tree)
883+
),
884+
885+
delim_token_tree: $ => choice(
886+
seq('(', repeat($._delim_tokens), ')'),
887+
seq('[', repeat($._delim_tokens), ']'),
888+
seq('{', repeat($._delim_tokens), '}')
889+
),
890+
891+
_delim_tokens: $ => choice(
892+
$._non_delim_token,
893+
alias($.delim_token_tree, $.token_tree),
894+
),
895+
896+
_non_delim_token: $ => choice(
897+
$._non_special_token,
898+
'$'
883899
),
884900

885901
scoped_identifier: $ => seq(

src/grammar.json

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4856,9 +4856,110 @@
48564856
"type": "STRING",
48574857
"value": "!"
48584858
},
4859+
{
4860+
"type": "ALIAS",
4861+
"content": {
4862+
"type": "SYMBOL",
4863+
"name": "delim_token_tree"
4864+
},
4865+
"named": true,
4866+
"value": "token_tree"
4867+
}
4868+
]
4869+
},
4870+
"delim_token_tree": {
4871+
"type": "CHOICE",
4872+
"members": [
4873+
{
4874+
"type": "SEQ",
4875+
"members": [
4876+
{
4877+
"type": "STRING",
4878+
"value": "("
4879+
},
4880+
{
4881+
"type": "REPEAT",
4882+
"content": {
4883+
"type": "SYMBOL",
4884+
"name": "_delim_tokens"
4885+
}
4886+
},
4887+
{
4888+
"type": "STRING",
4889+
"value": ")"
4890+
}
4891+
]
4892+
},
4893+
{
4894+
"type": "SEQ",
4895+
"members": [
4896+
{
4897+
"type": "STRING",
4898+
"value": "["
4899+
},
4900+
{
4901+
"type": "REPEAT",
4902+
"content": {
4903+
"type": "SYMBOL",
4904+
"name": "_delim_tokens"
4905+
}
4906+
},
4907+
{
4908+
"type": "STRING",
4909+
"value": "]"
4910+
}
4911+
]
4912+
},
4913+
{
4914+
"type": "SEQ",
4915+
"members": [
4916+
{
4917+
"type": "STRING",
4918+
"value": "{"
4919+
},
4920+
{
4921+
"type": "REPEAT",
4922+
"content": {
4923+
"type": "SYMBOL",
4924+
"name": "_delim_tokens"
4925+
}
4926+
},
4927+
{
4928+
"type": "STRING",
4929+
"value": "}"
4930+
}
4931+
]
4932+
}
4933+
]
4934+
},
4935+
"_delim_tokens": {
4936+
"type": "CHOICE",
4937+
"members": [
48594938
{
48604939
"type": "SYMBOL",
4861-
"name": "token_tree"
4940+
"name": "_non_delim_token"
4941+
},
4942+
{
4943+
"type": "ALIAS",
4944+
"content": {
4945+
"type": "SYMBOL",
4946+
"name": "delim_token_tree"
4947+
},
4948+
"named": true,
4949+
"value": "token_tree"
4950+
}
4951+
]
4952+
},
4953+
"_non_delim_token": {
4954+
"type": "CHOICE",
4955+
"members": [
4956+
{
4957+
"type": "SYMBOL",
4958+
"name": "_non_special_token"
4959+
},
4960+
{
4961+
"type": "STRING",
4962+
"value": "$"
48624963
}
48634964
]
48644965
},

0 commit comments

Comments
 (0)