From f20ea1e1f355b51fd6b681cc2e0964baa632c32c Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Fri, 25 Sep 2020 15:09:23 +0100 Subject: [PATCH] Allow some unicode for identifiers, fixes #37 --- corpus/classes.txt | 23 +++++++++++++++++++++++ grammar.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/corpus/classes.txt b/corpus/classes.txt index 6429a76..379d5f9 100644 --- a/corpus/classes.txt +++ b/corpus/classes.txt @@ -509,3 +509,26 @@ class A { parameters: (parameter_list) body: (block (return_statement (null_literal))))))) + +================================= +Class and methods with Unicode identifiers +================================= + +class Ωµ { + B.C d() { + return null; + } +} + +--- + +(compilation_unit + (class_declaration + name: (identifier) + body: (declaration_list + (method_declaration + type: (qualified_name (identifier) (identifier)) + name: (identifier) + parameters: (parameter_list) + body: (block + (return_statement (null_literal))))))) diff --git a/grammar.js b/grammar.js index e6432dd..d556522 100644 --- a/grammar.js +++ b/grammar.js @@ -1311,7 +1311,7 @@ module.exports = grammar({ ) ), - identifier: $ => token(seq(optional('@'), /[a-zA-Z_][a-zA-Z_0-9]*/)), // identifier_token in Roslyn + identifier: $ => token(seq(optional('@'), /[a-zA-Zα-ωΑ-Ωµ_][a-zA-Zα-ωΑ-Ωµ_0-9]*/)), // identifier_token in Roslyn global: $ => 'global', _identifier_or_global: $ => choice($.global, $.identifier),