codemirror-rails 5.1 → 5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/codemirror/rails/version.rb +2 -2
- data/vendor/assets/javascripts/codemirror.js +92 -39
- data/vendor/assets/javascripts/codemirror/addons/display/panel.js +22 -4
- data/vendor/assets/javascripts/codemirror/addons/edit/continuelist.js +5 -5
- data/vendor/assets/javascripts/codemirror/addons/hint/show-hint.js +63 -65
- data/vendor/assets/javascripts/codemirror/addons/lint/javascript-lint.js +1 -1
- data/vendor/assets/javascripts/codemirror/addons/mode/multiplex.js +14 -9
- data/vendor/assets/javascripts/codemirror/addons/scroll/annotatescrollbar.js +19 -4
- data/vendor/assets/javascripts/codemirror/addons/search/matchesonscrollbar.js +3 -1
- data/vendor/assets/javascripts/codemirror/addons/search/search.js +7 -4
- data/vendor/assets/javascripts/codemirror/addons/search/searchcursor.js +2 -2
- data/vendor/assets/javascripts/codemirror/keymaps/sublime.js +1 -1
- data/vendor/assets/javascripts/codemirror/keymaps/vim.js +117 -23
- data/vendor/assets/javascripts/codemirror/modes/clike.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/css.js +3 -1
- data/vendor/assets/javascripts/codemirror/modes/django.js +307 -24
- data/vendor/assets/javascripts/codemirror/modes/handlebars.js +53 -0
- data/vendor/assets/javascripts/codemirror/modes/javascript.js +5 -1
- data/vendor/assets/javascripts/codemirror/modes/less_test.js +3 -0
- data/vendor/assets/javascripts/codemirror/modes/markdown.js +15 -13
- data/vendor/assets/javascripts/codemirror/modes/mumps.js +148 -0
- data/vendor/assets/javascripts/codemirror/modes/python.js +2 -4
- data/vendor/assets/javascripts/codemirror/modes/scss_test.js +1 -1
- data/vendor/assets/javascripts/codemirror/modes/smarty.js +17 -6
- data/vendor/assets/javascripts/codemirror/modes/soy.js +3 -3
- data/vendor/assets/javascripts/codemirror/modes/sql.js +4 -4
- data/vendor/assets/javascripts/codemirror/modes/stylus.js +8 -3
- data/vendor/assets/javascripts/codemirror/modes/z80.js +34 -18
- data/vendor/assets/stylesheets/codemirror.css +2 -0
- data/vendor/assets/stylesheets/codemirror/themes/liquibyte.css +95 -0
- data/vendor/assets/stylesheets/codemirror/themes/monokai.css +1 -1
- data/vendor/assets/stylesheets/codemirror/themes/solarized.css +1 -1
- metadata +4 -1
@@ -72,7 +72,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
72
72
|
, ulRE = /^[*\-+]\s+/
|
73
73
|
, olRE = /^[0-9]+\.\s+/
|
74
74
|
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
75
|
-
, atxHeaderRE =
|
75
|
+
, atxHeaderRE = /^#+ ?/
|
76
76
|
, setextHeaderRE = /^(?:\={1,}|-{1,})$/
|
77
77
|
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
78
78
|
|
@@ -116,18 +116,20 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
116
116
|
|
117
117
|
var sol = stream.sol();
|
118
118
|
|
119
|
-
var prevLineIsList =
|
120
|
-
if (
|
121
|
-
if (state.indentationDiff
|
122
|
-
state.indentation
|
119
|
+
var prevLineIsList = state.list !== false;
|
120
|
+
if (prevLineIsList) {
|
121
|
+
if (state.indentationDiff >= 0) { // Continued list
|
122
|
+
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
123
|
+
state.indentation -= state.indentationDiff;
|
124
|
+
}
|
125
|
+
state.list = null;
|
126
|
+
} else if (state.indentation > 0) {
|
127
|
+
state.list = null;
|
128
|
+
state.listDepth = Math.floor(state.indentation / 4);
|
129
|
+
} else { // No longer a list
|
130
|
+
state.list = false;
|
131
|
+
state.listDepth = 0;
|
123
132
|
}
|
124
|
-
state.list = null;
|
125
|
-
} else if (state.list !== false && state.indentation > 0) {
|
126
|
-
state.list = null;
|
127
|
-
state.listDepth = Math.floor(state.indentation / 4);
|
128
|
-
} else if (state.list !== false) { // No longer a list
|
129
|
-
state.list = false;
|
130
|
-
state.listDepth = 0;
|
131
133
|
}
|
132
134
|
|
133
135
|
var match = null;
|
@@ -138,7 +140,7 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
|
138
140
|
} else if (stream.eatSpace()) {
|
139
141
|
return null;
|
140
142
|
} else if (match = stream.match(atxHeaderRE)) {
|
141
|
-
state.header = match[0].
|
143
|
+
state.header = Math.min(6, match[0].indexOf(" ") !== -1 ? match[0].length - 1 : match[0].length);
|
142
144
|
if (modeCfg.highlightFormatting) state.formatting = "header";
|
143
145
|
state.f = state.inline;
|
144
146
|
return getType(state);
|
@@ -0,0 +1,148 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
/*
|
5
|
+
This MUMPS Language script was constructed using vbscript.js as a template.
|
6
|
+
*/
|
7
|
+
|
8
|
+
(function(mod) {
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10
|
+
mod(require("../../lib/codemirror"));
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
12
|
+
define(["../../lib/codemirror"], mod);
|
13
|
+
else // Plain browser env
|
14
|
+
mod(CodeMirror);
|
15
|
+
})(function(CodeMirror) {
|
16
|
+
"use strict";
|
17
|
+
|
18
|
+
CodeMirror.defineMode("mumps", function() {
|
19
|
+
function wordRegexp(words) {
|
20
|
+
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
|
21
|
+
}
|
22
|
+
|
23
|
+
var singleOperators = new RegExp("^[\\+\\-\\*/&#!_?\\\\<>=\\'\\[\\]]");
|
24
|
+
var doubleOperators = new RegExp("^(('=)|(<=)|(>=)|('>)|('<)|([[)|(]])|(^$))");
|
25
|
+
var singleDelimiters = new RegExp("^[\\.,:]");
|
26
|
+
var brackets = new RegExp("[()]");
|
27
|
+
var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*");
|
28
|
+
var commandKeywords = ["break","close","do","else","for","goto", "halt", "hang", "if", "job","kill","lock","merge","new","open", "quit", "read", "set", "tcommit", "trollback", "tstart", "use", "view", "write", "xecute", "b","c","d","e","f","g", "h", "i", "j","k","l","m","n","o", "q", "r", "s", "tc", "tro", "ts", "u", "v", "w", "x"];
|
29
|
+
// The following list includes instrinsic functions _and_ special variables
|
30
|
+
var intrinsicFuncsWords = ["\\$ascii", "\\$char", "\\$data", "\\$ecode", "\\$estack", "\\$etrap", "\\$extract", "\\$find", "\\$fnumber", "\\$get", "\\$horolog", "\\$io", "\\$increment", "\\$job", "\\$justify", "\\$length", "\\$name", "\\$next", "\\$order", "\\$piece", "\\$qlength", "\\$qsubscript", "\\$query", "\\$quit", "\\$random", "\\$reverse", "\\$select", "\\$stack", "\\$test", "\\$text", "\\$translate", "\\$view", "\\$x", "\\$y", "\\$a", "\\$c", "\\$d", "\\$e", "\\$ec", "\\$es", "\\$et", "\\$f", "\\$fn", "\\$g", "\\$h", "\\$i", "\\$j", "\\$l", "\\$n", "\\$na", "\\$o", "\\$p", "\\$q", "\\$ql", "\\$qs", "\\$r", "\\$re", "\\$s", "\\$st", "\\$t", "\\$tr", "\\$v", "\\$z"];
|
31
|
+
var intrinsicFuncs = wordRegexp(intrinsicFuncsWords);
|
32
|
+
var command = wordRegexp(commandKeywords);
|
33
|
+
|
34
|
+
function tokenBase(stream, state) {
|
35
|
+
if (stream.sol()) {
|
36
|
+
state.label = true;
|
37
|
+
state.commandMode = 0;
|
38
|
+
}
|
39
|
+
|
40
|
+
// The <space> character has meaning in MUMPS. Ignoring consecutive
|
41
|
+
// spaces would interfere with interpreting whether the next non-space
|
42
|
+
// character belongs to the command or argument context.
|
43
|
+
|
44
|
+
// Examine each character and update a mode variable whose interpretation is:
|
45
|
+
// >0 => command 0 => argument <0 => command post-conditional
|
46
|
+
var ch = stream.peek();
|
47
|
+
|
48
|
+
if (ch == " " || ch == "\t") { // Pre-process <space>
|
49
|
+
state.label = false;
|
50
|
+
if (state.commandMode == 0)
|
51
|
+
state.commandMode = 1;
|
52
|
+
else if ((state.commandMode < 0) || (state.commandMode == 2))
|
53
|
+
state.commandMode = 0;
|
54
|
+
} else if ((ch != ".") && (state.commandMode > 0)) {
|
55
|
+
if (ch == ":")
|
56
|
+
state.commandMode = -1; // SIS - Command post-conditional
|
57
|
+
else
|
58
|
+
state.commandMode = 2;
|
59
|
+
}
|
60
|
+
|
61
|
+
// Do not color parameter list as line tag
|
62
|
+
if ((ch === "(") || (ch === "\u0009"))
|
63
|
+
state.label = false;
|
64
|
+
|
65
|
+
// MUMPS comment starts with ";"
|
66
|
+
if (ch === ";") {
|
67
|
+
stream.skipToEnd();
|
68
|
+
return "comment";
|
69
|
+
}
|
70
|
+
|
71
|
+
// Number Literals // SIS/RLM - MUMPS permits canonic number followed by concatenate operator
|
72
|
+
if (stream.match(/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?/))
|
73
|
+
return "number";
|
74
|
+
|
75
|
+
// Handle Strings
|
76
|
+
if (ch == '"') {
|
77
|
+
if (stream.skipTo('"')) {
|
78
|
+
stream.next();
|
79
|
+
return "string";
|
80
|
+
} else {
|
81
|
+
stream.skipToEnd();
|
82
|
+
return "error";
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
// Handle operators and Delimiters
|
87
|
+
if (stream.match(doubleOperators) || stream.match(singleOperators))
|
88
|
+
return "operator";
|
89
|
+
|
90
|
+
// Prevents leading "." in DO block from falling through to error
|
91
|
+
if (stream.match(singleDelimiters))
|
92
|
+
return null;
|
93
|
+
|
94
|
+
if (brackets.test(ch)) {
|
95
|
+
stream.next();
|
96
|
+
return "bracket";
|
97
|
+
}
|
98
|
+
|
99
|
+
if (state.commandMode > 0 && stream.match(command))
|
100
|
+
return "variable-2";
|
101
|
+
|
102
|
+
if (stream.match(intrinsicFuncs))
|
103
|
+
return "builtin";
|
104
|
+
|
105
|
+
if (stream.match(identifiers))
|
106
|
+
return "variable";
|
107
|
+
|
108
|
+
// Detect dollar-sign when not a documented intrinsic function
|
109
|
+
// "^" may introduce a GVN or SSVN - Color same as function
|
110
|
+
if (ch === "$" || ch === "^") {
|
111
|
+
stream.next();
|
112
|
+
return "builtin";
|
113
|
+
}
|
114
|
+
|
115
|
+
// MUMPS Indirection
|
116
|
+
if (ch === "@") {
|
117
|
+
stream.next();
|
118
|
+
return "string-2";
|
119
|
+
}
|
120
|
+
|
121
|
+
if (/[\w%]/.test(ch)) {
|
122
|
+
stream.eatWhile(/[\w%]/);
|
123
|
+
return "variable";
|
124
|
+
}
|
125
|
+
|
126
|
+
// Handle non-detected items
|
127
|
+
stream.next();
|
128
|
+
return "error";
|
129
|
+
}
|
130
|
+
|
131
|
+
return {
|
132
|
+
startState: function() {
|
133
|
+
return {
|
134
|
+
label: false,
|
135
|
+
commandMode: 0
|
136
|
+
};
|
137
|
+
},
|
138
|
+
|
139
|
+
token: function(stream, state) {
|
140
|
+
var style = tokenBase(stream, state);
|
141
|
+
if (state.label) return "tag";
|
142
|
+
return style;
|
143
|
+
}
|
144
|
+
};
|
145
|
+
});
|
146
|
+
|
147
|
+
CodeMirror.defineMIME("text/x-mumps", "mumps");
|
148
|
+
});
|
@@ -162,15 +162,13 @@
|
|
162
162
|
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters))
|
163
163
|
return null;
|
164
164
|
|
165
|
-
if (stream.match(doubleOperators)
|
166
|
-
|| stream.match(singleOperators)
|
167
|
-
|| stream.match(wordOperators))
|
165
|
+
if (stream.match(doubleOperators) || stream.match(singleOperators))
|
168
166
|
return "operator";
|
169
167
|
|
170
168
|
if (stream.match(singleDelimiters))
|
171
169
|
return null;
|
172
170
|
|
173
|
-
if (stream.match(keywords))
|
171
|
+
if (stream.match(keywords) || stream.match(wordOperators))
|
174
172
|
return "keyword";
|
175
173
|
|
176
174
|
if (stream.match(builtins))
|
@@ -73,7 +73,7 @@
|
|
73
73
|
"[tag foo]#{[variable-2 $hello]} { [property color]:[atom #000]; }");
|
74
74
|
|
75
75
|
MT('interpolation_error',
|
76
|
-
"[tag foo]#{[
|
76
|
+
"[tag foo]#{[variable foo]} { [property color]:[atom #000]; }");
|
77
77
|
|
78
78
|
MT("divide_operator",
|
79
79
|
"[tag foo] { [property width]:[number 4] [operator /] [number 2] }");
|
@@ -47,10 +47,17 @@
|
|
47
47
|
}
|
48
48
|
|
49
49
|
function tokenTop(stream, state) {
|
50
|
-
|
50
|
+
var string = stream.string;
|
51
|
+
for (var scan = stream.pos;;) {
|
52
|
+
var nextMatch = string.indexOf(leftDelimiter, scan);
|
53
|
+
scan = nextMatch + leftDelimiter.length;
|
54
|
+
if (nextMatch == -1 || !doesNotCount(stream, nextMatch + leftDelimiter.length)) break;
|
55
|
+
}
|
56
|
+
if (nextMatch == stream.pos) {
|
57
|
+
stream.match(leftDelimiter);
|
51
58
|
if (stream.eat("*")) {
|
52
59
|
return chain(stream, state, tokenBlock("comment", "*" + rightDelimiter));
|
53
|
-
} else
|
60
|
+
} else {
|
54
61
|
state.depth++;
|
55
62
|
state.tokenize = tokenSmarty;
|
56
63
|
last = "startTag";
|
@@ -58,11 +65,9 @@
|
|
58
65
|
}
|
59
66
|
}
|
60
67
|
|
68
|
+
if (nextMatch > -1) stream.string = string.slice(0, nextMatch);
|
61
69
|
var token = baseMode.token(stream, state.base);
|
62
|
-
|
63
|
-
var found = text.indexOf(leftDelimiter);
|
64
|
-
if (found > -1 && !doesNotCount(stream, stream.start + found + 1))
|
65
|
-
stream.backUp(text.length - found);
|
70
|
+
if (nextMatch > -1) stream.string = string;
|
66
71
|
return token;
|
67
72
|
}
|
68
73
|
|
@@ -205,6 +210,12 @@
|
|
205
210
|
state.last = last;
|
206
211
|
return style;
|
207
212
|
},
|
213
|
+
indent: function(state, text) {
|
214
|
+
if (state.tokenize == tokenTop && baseMode.indent)
|
215
|
+
return baseMode.indent(state.base, text);
|
216
|
+
else
|
217
|
+
return CodeMirror.Pass;
|
218
|
+
},
|
208
219
|
blockCommentStart: leftDelimiter + "*",
|
209
220
|
blockCommentEnd: "*" + rightDelimiter
|
210
221
|
};
|
@@ -96,7 +96,7 @@
|
|
96
96
|
else state.indent -= (stream.current() == "/}" || indentingTags.indexOf(state.tag) == -1 ? 2 : 1) * config.indentUnit;
|
97
97
|
state.soyState.pop();
|
98
98
|
return "keyword";
|
99
|
-
} else if (stream.match(/^(\w+)(?==)/)) {
|
99
|
+
} else if (stream.match(/^([\w?]+)(?==)/)) {
|
100
100
|
if (stream.current() == "kind" && (match = stream.match(/^="([^"]+)/, false))) {
|
101
101
|
var kind = match[1];
|
102
102
|
state.kind.push(kind);
|
@@ -134,7 +134,7 @@
|
|
134
134
|
return "comment";
|
135
135
|
} else if (stream.match(stream.sol() ? /^\s*\/\/.*/ : /^\s+\/\/.*/)) {
|
136
136
|
return "comment";
|
137
|
-
} else if (stream.match(/^\{
|
137
|
+
} else if (stream.match(/^\{\$[\w?]*/)) {
|
138
138
|
state.indent += 2 * config.indentUnit;
|
139
139
|
state.soyState.push("variable");
|
140
140
|
return "variable-2";
|
@@ -142,7 +142,7 @@
|
|
142
142
|
state.indent += config.indentUnit;
|
143
143
|
state.soyState.push("literal");
|
144
144
|
return "keyword";
|
145
|
-
} else if (match = stream.match(/^\{([\/@\\]
|
145
|
+
} else if (match = stream.match(/^\{([\/@\\]?[\w?]*)/)) {
|
146
146
|
if (match[1] != "/switch")
|
147
147
|
state.indent += (/^(\/|(else|elseif|case|default)$)/.test(match[1]) && state.tag != "switch" ? 1 : 2) * config.indentUnit;
|
148
148
|
state.tag = match[1];
|
@@ -280,7 +280,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
|
|
280
280
|
CodeMirror.defineMIME("text/x-mssql", {
|
281
281
|
name: "sql",
|
282
282
|
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
283
|
-
keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered"),
|
283
|
+
keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered declare"),
|
284
284
|
builtin: set("bigint numeric bit smallint decimal smallmoney int tinyint money float real char varchar text nchar nvarchar ntext binary varbinary image cursor timestamp hierarchyid uniqueidentifier sql_variant xml table "),
|
285
285
|
atoms: set("false true null unknown"),
|
286
286
|
operatorChars: /^[*+\-%<>!=]/,
|
@@ -327,9 +327,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
|
|
327
327
|
CodeMirror.defineMIME("text/x-cassandra", {
|
328
328
|
name: "sql",
|
329
329
|
client: { },
|
330
|
-
keywords: set("
|
331
|
-
builtin: set("ascii bigint blob boolean counter decimal double float int text timestamp uuid varchar varint"),
|
332
|
-
atoms: set("false true"),
|
330
|
+
keywords: set("add all allow alter and any apply as asc authorize batch begin by clustering columnfamily compact consistency count create custom delete desc distinct drop each_quorum exists filtering from grant if in index insert into key keyspace keyspaces level limit local_one local_quorum modify nan norecursive nosuperuser not of on one order password permission permissions primary quorum rename revoke schema select set storage superuser table three to token truncate ttl two type unlogged update use user users using values where with writetime"),
|
331
|
+
builtin: set("ascii bigint blob boolean counter decimal double float frozen inet int list map static text timestamp timeuuid tuple uuid varchar varint"),
|
332
|
+
atoms: set("false true infinity NaN"),
|
333
333
|
operatorChars: /^[<>=]/,
|
334
334
|
dateSQL: { },
|
335
335
|
support: set("commentSlashSlash decimallessFloat"),
|
@@ -323,7 +323,12 @@
|
|
323
323
|
return pushContext(state, stream, "block", 0);
|
324
324
|
}
|
325
325
|
if (type == "variable-name") {
|
326
|
-
|
326
|
+
if ((stream.indentation() == 0 && startOfLine(stream)) || wordIsBlock(firstWordOfLine(stream))) {
|
327
|
+
return pushContext(state, stream, "variableName");
|
328
|
+
}
|
329
|
+
else {
|
330
|
+
return pushContext(state, stream, "variableName", 0);
|
331
|
+
}
|
327
332
|
}
|
328
333
|
if (type == "=") {
|
329
334
|
if (!endOfLine(stream) && !wordIsBlock(firstWordOfLine(stream))) {
|
@@ -445,10 +450,10 @@
|
|
445
450
|
wordIsTag(firstWordOfLine(stream)))) {
|
446
451
|
return pushContext(state, stream, "block");
|
447
452
|
}
|
448
|
-
if (stream.string.match(
|
453
|
+
if (stream.string.match(/^[\$-]?[a-z][\w-\.\[\]\'\"]*\s*=/) ||
|
449
454
|
stream.string.match(/^\s*(\(|\)|[0-9])/) ||
|
450
455
|
stream.string.match(/^\s+[a-z][\w-]*\(/i) ||
|
451
|
-
stream.string.match(/^\s
|
456
|
+
stream.string.match(/^\s+[\$-]?[a-z]/i)) {
|
452
457
|
return pushContext(state, stream, "block", 0);
|
453
458
|
}
|
454
459
|
if (endOfLine(stream)) return pushContext(state, stream, "block");
|
@@ -3,26 +3,35 @@
|
|
3
3
|
|
4
4
|
(function(mod) {
|
5
5
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
-
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
7
|
else if (typeof define == "function" && define.amd) // AMD
|
8
|
-
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
9
|
else // Plain browser env
|
10
|
-
|
10
|
+
mod(CodeMirror);
|
11
11
|
})(function(CodeMirror) {
|
12
12
|
"use strict";
|
13
13
|
|
14
|
-
CodeMirror.defineMode('z80', function() {
|
15
|
-
var
|
16
|
-
var keywords2
|
17
|
-
|
14
|
+
CodeMirror.defineMode('z80', function(_config, parserConfig) {
|
15
|
+
var ez80 = parserConfig.ez80;
|
16
|
+
var keywords1, keywords2;
|
17
|
+
if (ez80) {
|
18
|
+
keywords1 = /^(exx?|(ld|cp)([di]r?)?|[lp]ea|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|[de]i|halt|im|in([di]mr?|ir?|irx|2r?)|ot(dmr?|[id]rx|imr?)|out(0?|[di]r?|[di]2r?)|tst(io)?|slp)(\.([sl]?i)?[sl])?\b/i;
|
19
|
+
keywords2 = /^(((call|j[pr]|rst|ret[in]?)(\.([sl]?i)?[sl])?)|(rs|st)mix)\b/i;
|
20
|
+
} else {
|
21
|
+
keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
|
22
|
+
keywords2 = /^(call|j[pr]|ret[in]?|b_?(call|jump))\b/i;
|
23
|
+
}
|
24
|
+
|
18
25
|
var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
|
19
26
|
var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
|
20
27
|
var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
|
21
|
-
var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+)\b/i;
|
28
|
+
var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+d?)\b/i;
|
22
29
|
|
23
30
|
return {
|
24
31
|
startState: function() {
|
25
|
-
return {
|
32
|
+
return {
|
33
|
+
context: 0
|
34
|
+
};
|
26
35
|
},
|
27
36
|
token: function(stream, state) {
|
28
37
|
if (!stream.column())
|
@@ -34,14 +43,21 @@ CodeMirror.defineMode('z80', function() {
|
|
34
43
|
var w;
|
35
44
|
|
36
45
|
if (stream.eatWhile(/\w/)) {
|
46
|
+
if (ez80 && stream.eat('.')) {
|
47
|
+
stream.eatWhile(/\w/);
|
48
|
+
}
|
37
49
|
w = stream.current();
|
38
50
|
|
39
51
|
if (stream.indentation()) {
|
40
|
-
if (state.context == 1 && variables1.test(w))
|
41
|
-
|
52
|
+
if ((state.context == 1 || state.context == 4) && variables1.test(w)) {
|
53
|
+
state.context = 4;
|
54
|
+
return 'var2';
|
55
|
+
}
|
42
56
|
|
43
|
-
if (state.context == 2 && variables2.test(w))
|
44
|
-
|
57
|
+
if (state.context == 2 && variables2.test(w)) {
|
58
|
+
state.context = 4;
|
59
|
+
return 'var3';
|
60
|
+
}
|
45
61
|
|
46
62
|
if (keywords1.test(w)) {
|
47
63
|
state.context = 1;
|
@@ -49,14 +65,13 @@ CodeMirror.defineMode('z80', function() {
|
|
49
65
|
} else if (keywords2.test(w)) {
|
50
66
|
state.context = 2;
|
51
67
|
return 'keyword';
|
52
|
-
} else if (
|
53
|
-
|
54
|
-
return 'keyword';
|
68
|
+
} else if (state.context == 4 && numbers.test(w)) {
|
69
|
+
return 'number';
|
55
70
|
}
|
56
71
|
|
57
72
|
if (errors.test(w))
|
58
73
|
return 'error';
|
59
|
-
} else if (
|
74
|
+
} else if (stream.match(numbers)) {
|
60
75
|
return 'number';
|
61
76
|
} else {
|
62
77
|
return null;
|
@@ -77,7 +92,7 @@ CodeMirror.defineMode('z80', function() {
|
|
77
92
|
if (stream.match(/\\?.'/))
|
78
93
|
return 'number';
|
79
94
|
} else if (stream.eat('.') || stream.sol() && stream.eat('#')) {
|
80
|
-
state.context =
|
95
|
+
state.context = 5;
|
81
96
|
|
82
97
|
if (stream.eatWhile(/\w/))
|
83
98
|
return 'def';
|
@@ -96,5 +111,6 @@ CodeMirror.defineMode('z80', function() {
|
|
96
111
|
});
|
97
112
|
|
98
113
|
CodeMirror.defineMIME("text/x-z80", "z80");
|
114
|
+
CodeMirror.defineMIME("text/x-ez80", { name: "z80", ez80: true });
|
99
115
|
|
100
116
|
});
|