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("apl", function() {
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"],
49
"∪": ["unique", "union"],
50
"∩": [null, "intersection"],
51
"∼": ["not", "without"],
56
"⍴": ["shapeOf", "reshape"],
57
",": ["ravel", "catenate"],
58
"⍪": [null, "firstAxisCatenate"],
59
"⌽": ["reverse", "rotate"],
60
"⊖": ["axis1Reverse", "axis1Rotate"],
61
"⍉": ["transpose", null],
62
"↑": ["first", "take"],
64
"⊂": ["enclose", "partitionWithAxis"],
65
"⊃": ["diclose", "pick"],
67
"⍋": ["gradeUp", null],
68
"⍒": ["gradeDown", null],
69
"⊤": ["encode", null],
70
"⊥": ["decode", null],
71
"⍕": ["format", "formatByExample"],
72
"⍎": ["execute", null],
73
"⊣": ["stop", "left"],
74
"⊢": ["pass", "right"]
77
var isOperator = /[\.\/⌿⍀¨⍣]/;
79
var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
81
var isComment = /[⍝#].*$/;
83
var stringEater = function(type) {
95
startState: function() {
104
token: function(stream, state) {
106
if (stream.eatSpace()) {
110
if (ch === '"' || ch === "'") {
111
stream.eatWhile(stringEater(ch));
116
if (/[\[{\(]/.test(ch)) {
120
if (/[\]}\)]/.test(ch)) {
124
if (isNiladic.test(ch)) {
128
if (/[¯\d]/.test(ch)) {
135
stream.eatWhile(/[\w\.]/);
138
if (isOperator.test(ch)) {
139
return "operator apl-" + builtInOps[ch];
141
if (isArrow.test(ch)) {
144
if (isFunction.test(ch)) {
146
if (builtInFuncs[ch] != null) {
148
funcName += builtInFuncs[ch][1];
150
funcName += builtInFuncs[ch][0];
155
return "function " + funcName;
157
if (isComment.test(ch)) {
161
if (ch === "∘" && stream.peek() === ".") {
163
return "function jot-dot";
165
stream.eatWhile(/[\w\$_]/);
172
CodeMirror.defineMIME("text/apl", "apl");