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