Skip to content

Commit ec25830

Browse files
authored
Macro call can contain char literal (#76)
* Macro call can contain char literal * Don't break lifetime in macros
1 parent 008991b commit ec25830

File tree

4 files changed

+52592
-52534
lines changed

4 files changed

+52592
-52534
lines changed

corpus/macros.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ a!(* a *);
2525
a!(& a &);
2626
a!(- a -);
2727
a!(b + c + +);
28+
a!('a'..='z');
29+
a!('\u{0}'..='\u{2}');
30+
a!('lifetime)
2831

2932
----
3033

@@ -40,7 +43,16 @@ a!(b + c + +);
4043
(token_tree (identifier)))
4144
(macro_invocation
4245
(identifier)
43-
(token_tree (identifier) (identifier))))
46+
(token_tree (identifier) (identifier)))
47+
(macro_invocation
48+
(identifier)
49+
(token_tree (char_literal) (char_literal)))
50+
(macro_invocation
51+
(identifier)
52+
(token_tree (char_literal) (char_literal)))
53+
(macro_invocation
54+
(identifier)
55+
(token_tree (identifier))))
4456

4557
============================================
4658
Macro definition

grammar.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ module.exports = grammar({
190190
_non_special_token: $ => choice(
191191
$._literal, $.identifier, $.metavariable, $.mutable_specifier, $.self, $.super, $.crate,
192192
alias(choice(...primitive_types), $.primitive_type),
193-
/[/_\-=->,;:::!=?.@*=/='&=#%=^=+<>|~]+/,
193+
/[/_\-=->,;:::!=?.@*=/=&=#%=^=+<>|~]+/,
194+
'\'',
194195
'as', 'async', 'await', 'break', 'const', 'continue', 'default', 'enum', 'fn', 'for', 'if', 'impl',
195196
'let', 'loop', 'match', 'mod', 'pub', 'return', 'static', 'struct', 'trait', 'type',
196197
'union', 'unsafe', 'use', 'where', 'while'

src/grammar.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,11 @@
755755
},
756756
{
757757
"type": "PATTERN",
758-
"value": "[\\/_\\-=->,;:::!=?.@*=\\/='&=#%=^=+<>|~]+"
758+
"value": "[\\/_\\-=->,;:::!=?.@*=\\/=&=#%=^=+<>|~]+"
759+
},
760+
{
761+
"type": "STRING",
762+
"value": "'"
759763
},
760764
{
761765
"type": "STRING",

0 commit comments

Comments
 (0)