Skip to content

Commit 37adf54

Browse files
committed
Support raw identifiers
Closes #68
1 parent 43293d0 commit 37adf54

File tree

4 files changed

+1033
-975
lines changed

4 files changed

+1033
-975
lines changed

corpus/expressions.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ fn main() {
1212
(function_item (identifier) (parameters) (block
1313
(identifier))))
1414

15+
============================================
16+
Raw identifiers
17+
============================================
18+
19+
fn main() {
20+
(r#abc as r#Def).r#ghi;
21+
}
22+
23+
---
24+
25+
(source_file
26+
(function_item
27+
(identifier)
28+
(parameters)
29+
(block
30+
(field_expression
31+
(parenthesized_expression
32+
(type_cast_expression (identifier) (type_identifier)))
33+
(field_identifier)))))
34+
1535
============================================
1636
Unary operator expressions
1737
============================================

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ module.exports = grammar({
14161416
$.scoped_identifier
14171417
),
14181418

1419-
identifier: $ => /[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ\d_]*/,
1419+
identifier: $ => /(r#)?[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ\d_]*/,
14201420

14211421
_reserved_identifier: $ => alias(choice(
14221422
'default',

src/grammar.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8176,7 +8176,7 @@
81768176
},
81778177
"identifier": {
81788178
"type": "PATTERN",
8179-
"value": "[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ\\d_]*"
8179+
"value": "(r#)?[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ\\d_]*"
81808180
},
81818181
"_reserved_identifier": {
81828182
"type": "ALIAS",

0 commit comments

Comments
 (0)