Skip to content

Commit db0cc94

Browse files
authored
Macro name can be qualified with a path (#72)
1 parent 7963508 commit db0cc94

File tree

5 files changed

+70305
-65612
lines changed

5 files changed

+70305
-65612
lines changed

corpus/macros.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ Macro invocation - no arguments
55
a!();
66
b![];
77
c!{};
8+
d::e!();
9+
f::g::h!{};
810

911
---
1012

1113
(source_file
1214
(macro_invocation (identifier) (token_tree))
1315
(macro_invocation (identifier) (token_tree))
14-
(macro_invocation (identifier) (token_tree)))
16+
(macro_invocation (identifier) (token_tree))
17+
(macro_invocation (scoped_identifier (identifier) (identifier)) (token_tree))
18+
(macro_invocation (scoped_identifier (scoped_identifier (identifier) (identifier)) (identifier)) (token_tree)))
1519

1620
============================================
1721
Macro invocation - arbitrary tokens

grammar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,10 @@ module.exports = grammar({
875875
),
876876

877877
macro_invocation: $ => seq(
878-
field('macro', $.identifier),
878+
field('macro', choice(
879+
$.scoped_identifier,
880+
$.identifier
881+
)),
879882
'!',
880883
$.token_tree
881884
),

src/grammar.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@
755755
},
756756
{
757757
"type": "PATTERN",
758-
"value": "[/_\\-=->,;:::!=?.@*=/='&=#%=^=+<>|~]+"
758+
"value": "[\\/_\\-=->,;:::!=?.@*=\\/='&=#%=^=+<>|~]+"
759759
},
760760
{
761761
"type": "STRING",
@@ -4829,8 +4829,17 @@
48294829
"type": "FIELD",
48304830
"name": "macro",
48314831
"content": {
4832-
"type": "SYMBOL",
4833-
"name": "identifier"
4832+
"type": "CHOICE",
4833+
"members": [
4834+
{
4835+
"type": "SYMBOL",
4836+
"name": "scoped_identifier"
4837+
},
4838+
{
4839+
"type": "SYMBOL",
4840+
"name": "identifier"
4841+
}
4842+
]
48344843
}
48354844
},
48364845
{

src/node-types.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,6 +2305,10 @@
23052305
{
23062306
"type": "identifier",
23072307
"named": true
2308+
},
2309+
{
2310+
"type": "scoped_identifier",
2311+
"named": true
23082312
}
23092313
]
23102314
}

0 commit comments

Comments
 (0)