Skip to content

Commit 36870ca

Browse files
committed
Parse unicode identifiers in clike, clojure, d, go, haskell, js, octave, ruby, and tcl modes
1 parent 31a4d5b commit 36870ca

File tree

9 files changed

+18
-16
lines changed

9 files changed

+18
-16
lines changed

mode/clike/clike.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
5757
stream.eatWhile(isOperatorChar);
5858
return "operator";
5959
}
60-
stream.eatWhile(/[\w\$_]/);
60+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
6161
var cur = stream.current();
6262
if (keywords.propertyIsEnumerable(cur)) {
6363
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";

mode/clojure/clojure.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
CodeMirror.defineMode("clojure", function (options) {
2020
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
21-
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
21+
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable";
2222
var INDENT_WORD_SKIP = options.indentUnit || 2;
2323
var NORMAL_INDENT_UNIT = options.indentUnit || 2;
2424

@@ -59,7 +59,7 @@ CodeMirror.defineMode("clojure", function (options) {
5959
sign: /[+-]/,
6060
exponent: /e/i,
6161
keyword_char: /[^\s\(\[\;\)\]]/,
62-
symbol: /[\w*+!\-\._?:<>\/]/
62+
symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/
6363
};
6464

6565
function stateStack(indent, type, prev) { // represents a state stack object
@@ -220,7 +220,9 @@ CodeMirror.defineMode("clojure", function (options) {
220220
returnType = BUILTIN;
221221
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
222222
returnType = ATOM;
223-
} else returnType = null;
223+
} else {
224+
returnType = VAR;
225+
}
224226
}
225227
}
226228

mode/d/d.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
6060
stream.eatWhile(isOperatorChar);
6161
return "operator";
6262
}
63-
stream.eatWhile(/[\w\$_]/);
63+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
6464
var cur = stream.current();
6565
if (keywords.propertyIsEnumerable(cur)) {
6666
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";

mode/go/go.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ CodeMirror.defineMode("go", function(config) {
7171
stream.eatWhile(isOperatorChar);
7272
return "operator";
7373
}
74-
stream.eatWhile(/[\w\$_]/);
74+
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
7575
var cur = stream.current();
7676
if (keywords.propertyIsEnumerable(cur)) {
7777
if (cur == "case" || cur == "default") curPunc = "case";

mode/haskell/haskell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ CodeMirror.defineMode("haskell", function(_config, modeConfig) {
2424
var digitRE = /\d/;
2525
var hexitRE = /[0-9A-Fa-f]/;
2626
var octitRE = /[0-7]/;
27-
var idRE = /[a-z_A-Z0-9']/;
27+
var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/;
2828
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
2929
var specialRE = /[(),;[\]`{}]/;
3030
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer

mode/javascript/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
1919
var jsonldMode = parserConfig.jsonld;
2020
var jsonMode = parserConfig.json || jsonldMode;
2121
var isTS = parserConfig.typescript;
22-
var wordRE = parserConfig.wordCharacters || /[\w$]/;
22+
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
2323

2424
// Tokenizer
2525

mode/octave/octave.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ CodeMirror.defineMode("octave", function() {
2222
var doubleDelimiters = new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))");
2323
var tripleDelimiters = new RegExp("^((>>=)|(<<=))");
2424
var expressionEnd = new RegExp("^[\\]\\)]");
25-
var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
25+
var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*");
2626

2727
var builtins = wordRegexp([
2828
'error', 'eval', 'function', 'abs', 'acos', 'atan', 'asin', 'cos',

mode/ruby/ruby.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ CodeMirror.defineMode("ruby", function(config) {
107107
}
108108

109109
// Symbols can't start by a digit
110-
if (stream.eat(/[a-zA-Z$@_]/)) {
111-
stream.eatWhile(/[\w]/);
110+
if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
111+
stream.eatWhile(/[\w$\xa1-\uffff]/);
112112
// Only one ? ! = is allowed and only as the last character
113113
stream.eat(/[\?\!\=]/);
114114
return "atom";
115115
}
116116
return "operator";
117-
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_]/)) {
117+
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
118118
stream.eat("@");
119-
stream.eatWhile(/[\w]/);
119+
stream.eatWhile(/[\w\xa1-\uffff]/);
120120
return "variable-2";
121121
} else if (ch == "$") {
122122
if (stream.eat(/[a-zA-Z_]/)) {
@@ -127,8 +127,8 @@ CodeMirror.defineMode("ruby", function(config) {
127127
stream.next(); // Must be a special global like $: or $!
128128
}
129129
return "variable-3";
130-
} else if (/[a-zA-Z_]/.test(ch)) {
131-
stream.eatWhile(/[\w]/);
130+
} else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
131+
stream.eatWhile(/[\w\xa1-\uffff]/);
132132
stream.eat(/[\?\!]/);
133133
if (stream.eat(":")) return "atom";
134134
return "ident";

mode/tcl/tcl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ CodeMirror.defineMode("tcl", function() {
7878
return "comment";
7979
}
8080
else {
81-
stream.eatWhile(/[\w\$_{}]/);
81+
stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
8282
var word = stream.current().toLowerCase();
8383
if (keywords && keywords.propertyIsEnumerable(word))
8484
return "keyword";

0 commit comments

Comments
 (0)