Skip to content

Commit

Permalink
Support raw identifiers
Browse files Browse the repository at this point in the history
Closes #68
  • Loading branch information
maxbrunsfeld committed May 4, 2020
1 parent 43293d0 commit 37adf54
Show file tree
Hide file tree
Showing 4 changed files with 1,033 additions and 975 deletions.
20 changes: 20 additions & 0 deletions corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@ fn main() {
(function_item (identifier) (parameters) (block
(identifier))))

============================================
Raw identifiers
============================================

fn main() {
(r#abc as r#Def).r#ghi;
}

---

(source_file
(function_item
(identifier)
(parameters)
(block
(field_expression
(parenthesized_expression
(type_cast_expression (identifier) (type_identifier)))
(field_identifier)))))

============================================
Unary operator expressions
============================================
Expand Down
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ module.exports = grammar({
$.scoped_identifier
),

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

_reserved_identifier: $ => alias(choice(
'default',
Expand Down
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -8176,7 +8176,7 @@
},
"identifier": {
"type": "PATTERN",
"value": "[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ\\d_]*"
"value": "(r#)?[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ\\d_]*"
},
"_reserved_identifier": {
"type": "ALIAS",
Expand Down

0 comments on commit 37adf54

Please sign in to comment.