Skip to content

Commit 17e60f2

Browse files
finalfantasiamarijnh
authored andcommitted
[clojure mode] More accurate symbol tokenizing
1 parent ab3e78a commit 17e60f2

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

mode/clojure/clojure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ CodeMirror.defineMode("clojure", function (options) {
157157
var coreSymbol = createLookupMap(coreSymbols);
158158
var hasBodyParameter = createLookupMap(haveBodyParameter);
159159
var numberLiteral = /^[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?/;
160-
var symbolCharacter = /[!#'*+\-.\/:<>?_\w\xa1-\uffff]/;
160+
var symbolCharacter = /[!#$&'*+\-.\/:<=>?_|\w\xa1-\uffff]/;
161161

162162
function base(stream, state) {
163163
if (stream.eatSpace()) return ["space", null];

mode/clojure/test.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
}
1010

1111
MT("atoms",
12-
"[atom nil]",
1312
"[atom false]",
13+
"[atom nil]",
1414
"[atom true]"
1515
);
1616

@@ -62,7 +62,8 @@
6262
"[string-2 \\tab]",
6363
"[string-2 \\u1000]",
6464
"[string-2 \\uAaAa]",
65-
"[string-2 \\u9F9F]"
65+
"[string-2 \\u9F9F]",
66+
"[string-2 \\o123]"
6667
);
6768

6869
MT("strings",
@@ -82,6 +83,9 @@
8283

8384
MT("reader macro characters",
8485
"[meta #][variable _]",
86+
"[meta #][variable -Inf]",
87+
"[meta ##][variable Inf]",
88+
"[meta ##][variable NaN]",
8589
"[meta @][variable x]",
8690
"[meta ^][bracket {][atom :tag] [variable String][bracket }]",
8791
"[meta `][bracket (][builtin f] [variable x][bracket )]",
@@ -96,6 +100,32 @@
96100
"[meta '#][bracket {][variable a] [number 1] [atom :foo][bracket }]"
97101
);
98102

103+
MT("symbols",
104+
"[variable foo!]",
105+
"[variable foo#]",
106+
"[variable foo$]",
107+
"[variable foo&]",
108+
"[variable foo']",
109+
"[variable foo*]",
110+
"[variable foo+]",
111+
"[variable foo-]",
112+
"[variable foo.]",
113+
"[variable foo/bar]",
114+
"[variable foo:bar]",
115+
"[variable foo<]",
116+
"[variable foo=]",
117+
"[variable foo>]",
118+
"[variable foo?]",
119+
"[variable foo_]",
120+
"[variable foo|]",
121+
"[variable foobarBaz]",
122+
"[variable foo¡]",
123+
"[variable 符号]",
124+
"[variable シンボル]",
125+
"[variable ئۇيغۇر]",
126+
"[variable 🙂❤🇺🇸]"
127+
);
128+
99129
var specialForms = [".", "catch", "def", "do", "if", "monitor-enter",
100130
"monitor-exit", "new", "quote", "recur", "set!", "throw", "try", "var"];
101131

0 commit comments

Comments
 (0)