LaravelTest
136 строк · 4.1 Кб
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("pascal", function() {15function words(str) {16var obj = {}, words = str.split(" ");17for (var i = 0; i < words.length; ++i) obj[words[i]] = true;18return obj;19}20var keywords = words(21"absolute and array asm begin case const constructor destructor div do " +22"downto else end file for function goto if implementation in inherited " +23"inline interface label mod nil not object of operator or packed procedure " +24"program record reintroduce repeat self set shl shr string then to type " +25"unit until uses var while with xor as class dispinterface except exports " +26"finalization finally initialization inline is library on out packed " +27"property raise resourcestring threadvar try absolute abstract alias " +28"assembler bitpacked break cdecl continue cppdecl cvar default deprecated " +29"dynamic enumerator experimental export external far far16 forward generic " +30"helper implements index interrupt iocheck local message name near " +31"nodefault noreturn nostackframe oldfpccall otherwise overload override " +32"pascal platform private protected public published read register " +33"reintroduce result safecall saveregisters softfloat specialize static " +34"stdcall stored strict unaligned unimplemented varargs virtual write");35var atoms = {"null": true};36
37var isOperatorChar = /[+\-*&%=<>!?|\/]/;38
39function tokenBase(stream, state) {40var ch = stream.next();41if (ch == "#" && state.startOfLine) {42stream.skipToEnd();43return "meta";44}45if (ch == '"' || ch == "'") {46state.tokenize = tokenString(ch);47return state.tokenize(stream, state);48}49if (ch == "(" && stream.eat("*")) {50state.tokenize = tokenComment;51return tokenComment(stream, state);52}53if (ch == "{") {54state.tokenize = tokenCommentBraces;55return tokenCommentBraces(stream, state);56}57if (/[\[\]\(\),;\:\.]/.test(ch)) {58return null;59}60if (/\d/.test(ch)) {61stream.eatWhile(/[\w\.]/);62return "number";63}64if (ch == "/") {65if (stream.eat("/")) {66stream.skipToEnd();67return "comment";68}69}70if (isOperatorChar.test(ch)) {71stream.eatWhile(isOperatorChar);72return "operator";73}74stream.eatWhile(/[\w\$_]/);75var cur = stream.current();76if (keywords.propertyIsEnumerable(cur)) return "keyword";77if (atoms.propertyIsEnumerable(cur)) return "atom";78return "variable";79}80
81function tokenString(quote) {82return function(stream, state) {83var escaped = false, next, end = false;84while ((next = stream.next()) != null) {85if (next == quote && !escaped) {end = true; break;}86escaped = !escaped && next == "\\";87}88if (end || !escaped) state.tokenize = null;89return "string";90};91}92
93function tokenComment(stream, state) {94var maybeEnd = false, ch;95while (ch = stream.next()) {96if (ch == ")" && maybeEnd) {97state.tokenize = null;98break;99}100maybeEnd = (ch == "*");101}102return "comment";103}104
105function tokenCommentBraces(stream, state) {106var ch;107while (ch = stream.next()) {108if (ch == "}") {109state.tokenize = null;110break;111}112}113return "comment";114}115
116// Interface117
118return {119startState: function() {120return {tokenize: null};121},122
123token: function(stream, state) {124if (stream.eatSpace()) return null;125var style = (state.tokenize || tokenBase)(stream, state);126if (style == "comment" || style == "meta") return style;127return style;128},129
130electricChars: "{}"131};132});133
134CodeMirror.defineMIME("text/x-pascal", "pascal");135
136});137