LaravelTest
160 строк · 3.7 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineMode("eiffel", function() {15function wordObj(words) {16var o = {};17for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;18return o;19}20var 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]);86var operators = wordObj([":=", "and then","and", "or","<<",">>"]);87
88function chain(newtok, stream, state) {89state.tokenize.push(newtok);90return newtok(stream, state);91}92
93function tokenBase(stream, state) {94if (stream.eatSpace()) return null;95var ch = stream.next();96if (ch == '"'||ch == "'") {97return chain(readQuoted(ch, "string"), stream, state);98} else if (ch == "-"&&stream.eat("-")) {99stream.skipToEnd();100return "comment";101} else if (ch == ":"&&stream.eat("=")) {102return "operator";103} else if (/[0-9]/.test(ch)) {104stream.eatWhile(/[xXbBCc0-9\.]/);105stream.eat(/[\?\!]/);106return "ident";107} else if (/[a-zA-Z_0-9]/.test(ch)) {108stream.eatWhile(/[a-zA-Z_0-9]/);109stream.eat(/[\?\!]/);110return "ident";111} else if (/[=+\-\/*^%<>~]/.test(ch)) {112stream.eatWhile(/[=+\-\/*^%<>~]/);113return "operator";114} else {115return null;116}117}118
119function readQuoted(quote, style, unescaped) {120return function(stream, state) {121var escaped = false, ch;122while ((ch = stream.next()) != null) {123if (ch == quote && (unescaped || !escaped)) {124state.tokenize.pop();125break;126}127escaped = !escaped && ch == "%";128}129return style;130};131}132
133return {134startState: function() {135return {tokenize: [tokenBase]};136},137
138token: function(stream, state) {139var style = state.tokenize[state.tokenize.length-1](stream, state);140if (style == "ident") {141var word = stream.current();142style = 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"150: "variable";151}152return style;153},154lineComment: "--"155};156});157
158CodeMirror.defineMIME("text/x-eiffel", "eiffel");159
160});161