Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50665 views
1
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2
// Distributed under an MIT license: http://codemirror.net/LICENSE
3
4
(function(mod) {
5
if (typeof exports == "object" && typeof module == "object") // CommonJS
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd) // AMD
8
define(["../../lib/codemirror"], mod);
9
else // Plain browser env
10
mod(CodeMirror);
11
})(function(CodeMirror) {
12
"use strict";
13
14
CodeMirror.defineMode("eiffel", function() {
15
function wordObj(words) {
16
var o = {};
17
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
18
return o;
19
}
20
var keywords = wordObj([
21
'note',
22
'across',
23
'when',
24
'variant',
25
'until',
26
'unique',
27
'undefine',
28
'then',
29
'strip',
30
'select',
31
'retry',
32
'rescue',
33
'require',
34
'rename',
35
'reference',
36
'redefine',
37
'prefix',
38
'once',
39
'old',
40
'obsolete',
41
'loop',
42
'local',
43
'like',
44
'is',
45
'inspect',
46
'infix',
47
'include',
48
'if',
49
'frozen',
50
'from',
51
'external',
52
'export',
53
'ensure',
54
'end',
55
'elseif',
56
'else',
57
'do',
58
'creation',
59
'create',
60
'check',
61
'alias',
62
'agent',
63
'separate',
64
'invariant',
65
'inherit',
66
'indexing',
67
'feature',
68
'expanded',
69
'deferred',
70
'class',
71
'Void',
72
'True',
73
'Result',
74
'Precursor',
75
'False',
76
'Current',
77
'create',
78
'attached',
79
'detachable',
80
'as',
81
'and',
82
'implies',
83
'not',
84
'or'
85
]);
86
var operators = wordObj([":=", "and then","and", "or","<<",">>"]);
87
var curPunc;
88
89
function chain(newtok, stream, state) {
90
state.tokenize.push(newtok);
91
return newtok(stream, state);
92
}
93
94
function tokenBase(stream, state) {
95
curPunc = null;
96
if (stream.eatSpace()) return null;
97
var ch = stream.next();
98
if (ch == '"'||ch == "'") {
99
return chain(readQuoted(ch, "string"), stream, state);
100
} else if (ch == "-"&&stream.eat("-")) {
101
stream.skipToEnd();
102
return "comment";
103
} else if (ch == ":"&&stream.eat("=")) {
104
return "operator";
105
} else if (/[0-9]/.test(ch)) {
106
stream.eatWhile(/[xXbBCc0-9\.]/);
107
stream.eat(/[\?\!]/);
108
return "ident";
109
} else if (/[a-zA-Z_0-9]/.test(ch)) {
110
stream.eatWhile(/[a-zA-Z_0-9]/);
111
stream.eat(/[\?\!]/);
112
return "ident";
113
} else if (/[=+\-\/*^%<>~]/.test(ch)) {
114
stream.eatWhile(/[=+\-\/*^%<>~]/);
115
return "operator";
116
} else {
117
return null;
118
}
119
}
120
121
function readQuoted(quote, style, unescaped) {
122
return function(stream, state) {
123
var escaped = false, ch;
124
while ((ch = stream.next()) != null) {
125
if (ch == quote && (unescaped || !escaped)) {
126
state.tokenize.pop();
127
break;
128
}
129
escaped = !escaped && ch == "%";
130
}
131
return style;
132
};
133
}
134
135
return {
136
startState: function() {
137
return {tokenize: [tokenBase]};
138
},
139
140
token: function(stream, state) {
141
var style = state.tokenize[state.tokenize.length-1](stream, state);
142
if (style == "ident") {
143
var word = stream.current();
144
style = keywords.propertyIsEnumerable(stream.current()) ? "keyword"
145
: operators.propertyIsEnumerable(stream.current()) ? "operator"
146
: /^[A-Z][A-Z_0-9]*$/g.test(word) ? "tag"
147
: /^0[bB][0-1]+$/g.test(word) ? "number"
148
: /^0[cC][0-7]+$/g.test(word) ? "number"
149
: /^0[xX][a-fA-F0-9]+$/g.test(word) ? "number"
150
: /^([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)$/g.test(word) ? "number"
151
: /^[0-9]+$/g.test(word) ? "number"
152
: "variable";
153
}
154
return style;
155
},
156
lineComment: "--"
157
};
158
});
159
160
CodeMirror.defineMIME("text/x-eiffel", "eiffel");
161
162
});
163
164