5
if (typeof exports == "object" && typeof module == "object")
6
mod(require("../../lib/codemirror"));
7
else if (typeof define == "function" && define.amd)
8
define(["../../lib/codemirror"], mod);
11
})(function(CodeMirror) {
14
CodeMirror.defineMode("eiffel", function() {
15
function wordObj(words) {
17
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
20
var keywords = wordObj([
86
var operators = wordObj([":=", "and then","and", "or","<<",">>"]);
88
function chain(newtok, stream, state) {
89
state.tokenize.push(newtok);
90
return newtok(stream, state);
93
function tokenBase(stream, state) {
94
if (stream.eatSpace()) return null;
95
var ch = stream.next();
96
if (ch == '"'||ch == "'") {
97
return chain(readQuoted(ch, "string"), stream, state);
98
} else if (ch == "-"&&stream.eat("-")) {
101
} else if (ch == ":"&&stream.eat("=")) {
103
} else if (/[0-9]/.test(ch)) {
104
stream.eatWhile(/[xXbBCc0-9\.]/);
105
stream.eat(/[\?\!]/);
107
} else if (/[a-zA-Z_0-9]/.test(ch)) {
108
stream.eatWhile(/[a-zA-Z_0-9]/);
109
stream.eat(/[\?\!]/);
111
} else if (/[=+\-\/*^%<>~]/.test(ch)) {
112
stream.eatWhile(/[=+\-\/*^%<>~]/);
119
function readQuoted(quote, style, unescaped) {
120
return function(stream, state) {
121
var escaped = false, ch;
122
while ((ch = stream.next()) != null) {
123
if (ch == quote && (unescaped || !escaped)) {
124
state.tokenize.pop();
127
escaped = !escaped && ch == "%";
134
startState: function() {
135
return {tokenize: [tokenBase]};
138
token: function(stream, state) {
139
var style = state.tokenize[state.tokenize.length-1](stream, state);
140
if (style == "ident") {
141
var word = stream.current();
142
style = keywords.propertyIsEnumerable(stream.current()) ? "keyword"
143
: operators.propertyIsEnumerable(stream.current()) ? "operator"
144
: /^[A-Z][A-Z_0-9]*$/g.test(word) ? "tag"
145
: /^0[bB][0-1]+$/g.test(word) ? "number"
146
: /^0[cC][0-7]+$/g.test(word) ? "number"
147
: /^0[xX][a-fA-F0-9]+$/g.test(word) ? "number"
148
: /^([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+)$/g.test(word) ? "number"
149
: /^[0-9]+$/g.test(word) ? "number"
158
CodeMirror.defineMIME("text/x-eiffel", "eiffel");