LaravelTest
174 строки · 4.6 Кб
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("apl", function() {15var builtInOps = {16".": "innerProduct",17"\\": "scan",18"/": "reduce",19"⌿": "reduce1Axis",20"⍀": "scan1Axis",21"¨": "each",22"⍣": "power"23};24var builtInFuncs = {25"+": ["conjugate", "add"],26"−": ["negate", "subtract"],27"×": ["signOf", "multiply"],28"÷": ["reciprocal", "divide"],29"⌈": ["ceiling", "greaterOf"],30"⌊": ["floor", "lesserOf"],31"∣": ["absolute", "residue"],32"⍳": ["indexGenerate", "indexOf"],33"?": ["roll", "deal"],34"⋆": ["exponentiate", "toThePowerOf"],35"⍟": ["naturalLog", "logToTheBase"],36"○": ["piTimes", "circularFuncs"],37"!": ["factorial", "binomial"],38"⌹": ["matrixInverse", "matrixDivide"],39"<": [null, "lessThan"],40"≤": [null, "lessThanOrEqual"],41"=": [null, "equals"],42">": [null, "greaterThan"],43"≥": [null, "greaterThanOrEqual"],44"≠": [null, "notEqual"],45"≡": ["depth", "match"],46"≢": [null, "notMatch"],47"∈": ["enlist", "membership"],48"⍷": [null, "find"],49"∪": ["unique", "union"],50"∩": [null, "intersection"],51"∼": ["not", "without"],52"∨": [null, "or"],53"∧": [null, "and"],54"⍱": [null, "nor"],55"⍲": [null, "nand"],56"⍴": ["shapeOf", "reshape"],57",": ["ravel", "catenate"],58"⍪": [null, "firstAxisCatenate"],59"⌽": ["reverse", "rotate"],60"⊖": ["axis1Reverse", "axis1Rotate"],61"⍉": ["transpose", null],62"↑": ["first", "take"],63"↓": [null, "drop"],64"⊂": ["enclose", "partitionWithAxis"],65"⊃": ["diclose", "pick"],66"⌷": [null, "index"],67"⍋": ["gradeUp", null],68"⍒": ["gradeDown", null],69"⊤": ["encode", null],70"⊥": ["decode", null],71"⍕": ["format", "formatByExample"],72"⍎": ["execute", null],73"⊣": ["stop", "left"],74"⊢": ["pass", "right"]75};76
77var isOperator = /[\.\/⌿⍀¨⍣]/;78var isNiladic = /⍬/;79var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;80var isArrow = /←/;81var isComment = /[⍝#].*$/;82
83var stringEater = function(type) {84var prev;85prev = false;86return function(c) {87prev = c;88if (c === type) {89return prev === "\\";90}91return true;92};93};94return {95startState: function() {96return {97prev: false,98func: false,99op: false,100string: false,101escape: false102};103},104token: function(stream, state) {105var ch, funcName;106if (stream.eatSpace()) {107return null;108}109ch = stream.next();110if (ch === '"' || ch === "'") {111stream.eatWhile(stringEater(ch));112stream.next();113state.prev = true;114return "string";115}116if (/[\[{\(]/.test(ch)) {117state.prev = false;118return null;119}120if (/[\]}\)]/.test(ch)) {121state.prev = true;122return null;123}124if (isNiladic.test(ch)) {125state.prev = false;126return "niladic";127}128if (/[¯\d]/.test(ch)) {129if (state.func) {130state.func = false;131state.prev = false;132} else {133state.prev = true;134}135stream.eatWhile(/[\w\.]/);136return "number";137}138if (isOperator.test(ch)) {139return "operator apl-" + builtInOps[ch];140}141if (isArrow.test(ch)) {142return "apl-arrow";143}144if (isFunction.test(ch)) {145funcName = "apl-";146if (builtInFuncs[ch] != null) {147if (state.prev) {148funcName += builtInFuncs[ch][1];149} else {150funcName += builtInFuncs[ch][0];151}152}153state.func = true;154state.prev = false;155return "function " + funcName;156}157if (isComment.test(ch)) {158stream.skipToEnd();159return "comment";160}161if (ch === "∘" && stream.peek() === ".") {162stream.next();163return "function jot-dot";164}165stream.eatWhile(/[\w\$_]/);166state.prev = true;167return "keyword";168}169};170});171
172CodeMirror.defineMIME("text/apl", "apl");173
174});175