1 CodeMirror.defineMode("apl", function() {
12 "+": ["conjugate", "add"],
13 "−": ["negate", "subtract"],
14 "×": ["signOf", "multiply"],
15 "÷": ["reciprocal", "divide"],
16 "⌈": ["ceiling", "greaterOf"],
17 "⌊": ["floor", "lesserOf"],
18 "∣": ["absolute", "residue"],
19 "⍳": ["indexGenerate", "indexOf"],
20 "?": ["roll", "deal"],
21 "⋆": ["exponentiate", "toThePowerOf"],
22 "⍟": ["naturalLog", "logToTheBase"],
23 "○": ["piTimes", "circularFuncs"],
24 "!": ["factorial", "binomial"],
25 "⌹": ["matrixInverse", "matrixDivide"],
26 "<": [null, "lessThan"],
27 "≤": [null, "lessThanOrEqual"],
28 "=": [null, "equals"],
29 ">": [null, "greaterThan"],
30 "≥": [null, "greaterThanOrEqual"],
31 "≠": [null, "notEqual"],
32 "≡": ["depth", "match"],
33 "≢": [null, "notMatch"],
34 "∈": ["enlist", "membership"],
36 "∪": ["unique", "union"],
37 "∩": [null, "intersection"],
38 "∼": ["not", "without"],
43 "⍴": ["shapeOf", "reshape"],
44 ",": ["ravel", "catenate"],
45 "⍪": [null, "firstAxisCatenate"],
46 "⌽": ["reverse", "rotate"],
47 "⊖": ["axis1Reverse", "axis1Rotate"],
48 "⍉": ["transpose", null],
49 "↑": ["first", "take"],
51 "⊂": ["enclose", "partitionWithAxis"],
52 "⊃": ["diclose", "pick"],
54 "⍋": ["gradeUp", null],
55 "⍒": ["gradeDown", null],
56 "⊤": ["encode", null],
57 "⊥": ["decode", null],
58 "⍕": ["format", "formatByExample"],
59 "⍎": ["execute", null],
60 "⊣": ["stop", "left"],
61 "⊢": ["pass", "right"]
64 var isOperator = /[\.\/⌿⍀¨⍣]/;
66 var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
68 var isComment = /[⍝#].*$/;
70 var stringEater = function(type) {
82 startState: function() {
91 token: function(stream, state) {
92 var ch, funcName, word;
93 if (stream.eatSpace()) {
97 if (ch === '"' || ch === "'") {
98 stream.eatWhile(stringEater(ch));
103 if (/[\[{\(]/.test(ch)) {
107 if (/[\]}\)]/.test(ch)) {
111 if (isNiladic.test(ch)) {
115 if (/[¯\d]/.test(ch)) {
122 stream.eatWhile(/[\w\.]/);
125 if (isOperator.test(ch)) {
126 return "operator apl-" + builtInOps[ch];
128 if (isArrow.test(ch)) {
131 if (isFunction.test(ch)) {
133 if (builtInFuncs[ch] != null) {
135 funcName += builtInFuncs[ch][1];
137 funcName += builtInFuncs[ch][0];
142 return "function " + funcName;
144 if (isComment.test(ch)) {
148 if (ch === "∘" && stream.peek() === ".") {
150 return "function jot-dot";
152 stream.eatWhile(/[\w\$_]/);
153 word = stream.current();
160 CodeMirror.defineMIME("text/apl", "apl");