Updated codemirror to 5.4.0

This commit is contained in:
Wu Cheng-Han 2015-07-04 11:31:01 +08:00
parent 1d843c8ac2
commit 01685c255f
69 changed files with 2988 additions and 558 deletions

View file

@ -154,20 +154,12 @@ CodeMirror.defineMode("dylan", function(_config) {
return f(stream, state);
}
var type, content;
function ret(_type, style, _content) {
type = _type;
content = _content;
return style;
}
function tokenBase(stream, state) {
// String
var ch = stream.peek();
if (ch == "'" || ch == '"') {
stream.next();
return chain(stream, state, tokenString(ch, "string", "string"));
return chain(stream, state, tokenString(ch, "string"));
}
// Comment
else if (ch == "/") {
@ -176,16 +168,16 @@ CodeMirror.defineMode("dylan", function(_config) {
return chain(stream, state, tokenComment);
} else if (stream.eat("/")) {
stream.skipToEnd();
return ret("comment", "comment");
return "comment";
} else {
stream.skipTo(" ");
return ret("operator", "operator");
return "operator";
}
}
// Decimal
else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
return ret("number", "number");
return "number";
}
// Hash
else if (ch == "#") {
@ -194,33 +186,33 @@ CodeMirror.defineMode("dylan", function(_config) {
ch = stream.peek();
if (ch == '"') {
stream.next();
return chain(stream, state, tokenString('"', "symbol", "string-2"));
return chain(stream, state, tokenString('"', "string-2"));
}
// Binary number
else if (ch == "b") {
stream.next();
stream.eatWhile(/[01]/);
return ret("number", "number");
return "number";
}
// Hex number
else if (ch == "x") {
stream.next();
stream.eatWhile(/[\da-f]/i);
return ret("number", "number");
return "number";
}
// Octal number
else if (ch == "o") {
stream.next();
stream.eatWhile(/[0-7]/);
return ret("number", "number");
return "number";
}
// Hash symbol
else {
stream.eatWhile(/[-a-zA-Z]/);
return ret("hash", "keyword");
return "keyword";
}
} else if (stream.match("end")) {
return ret("end", "keyword");
return "keyword";
}
for (var name in patterns) {
if (patterns.hasOwnProperty(name)) {
@ -228,21 +220,21 @@ CodeMirror.defineMode("dylan", function(_config) {
if ((pattern instanceof Array && pattern.some(function(p) {
return stream.match(p);
})) || stream.match(pattern))
return ret(name, patternStyles[name], stream.current());
return patternStyles[name];
}
}
if (stream.match("define")) {
return ret("definition", "def");
return "def";
} else {
stream.eatWhile(/[\w\-]/);
// Keyword
if (wordLookup[stream.current()]) {
return ret(wordLookup[stream.current()], styleLookup[stream.current()], stream.current());
return styleLookup[stream.current()];
} else if (stream.current().match(symbol)) {
return ret("variable", "variable");
return "variable";
} else {
stream.next();
return ret("other", "variable-2");
return "variable-2";
}
}
}
@ -257,10 +249,10 @@ CodeMirror.defineMode("dylan", function(_config) {
}
maybeEnd = (ch == "*");
}
return ret("comment", "comment");
return "comment";
}
function tokenString(quote, type, style) {
function tokenString(quote, style) {
return function(stream, state) {
var next, end = false;
while ((next = stream.next()) != null) {
@ -271,7 +263,7 @@ CodeMirror.defineMode("dylan", function(_config) {
}
if (end)
state.tokenize = tokenBase;
return ret(type, style);
return style;
};
}