9
if (typeof exports == "object" && typeof module == "object")
10
mod(require("../../lib/codemirror"));
11
else if (typeof define == "function" && define.amd)
12
define(["../../lib/codemirror"], mod);
15
})(function(CodeMirror) {
18
CodeMirror.defineMode("mumps", function() {
19
function wordRegexp(words) {
20
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
23
var singleOperators = new RegExp("^[\\+\\-\\*/&#!_?\\\\<>=\\'\\[\\]]");
24
var doubleOperators = new RegExp("^(('=)|(<=)|(>=)|('>)|('<)|([[)|(]])|(^$))");
25
var singleDelimiters = new RegExp("^[\\.,:]");
26
var brackets = new RegExp("[()]");
27
var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*");
28
var commandKeywords = ["break","close","do","else","for","goto", "halt", "hang", "if", "job","kill","lock","merge","new","open", "quit", "read", "set", "tcommit", "trollback", "tstart", "use", "view", "write", "xecute", "b","c","d","e","f","g", "h", "i", "j","k","l","m","n","o", "q", "r", "s", "tc", "tro", "ts", "u", "v", "w", "x"];
30
var intrinsicFuncsWords = ["\\$ascii", "\\$char", "\\$data", "\\$ecode", "\\$estack", "\\$etrap", "\\$extract", "\\$find", "\\$fnumber", "\\$get", "\\$horolog", "\\$io", "\\$increment", "\\$job", "\\$justify", "\\$length", "\\$name", "\\$next", "\\$order", "\\$piece", "\\$qlength", "\\$qsubscript", "\\$query", "\\$quit", "\\$random", "\\$reverse", "\\$select", "\\$stack", "\\$test", "\\$text", "\\$translate", "\\$view", "\\$x", "\\$y", "\\$a", "\\$c", "\\$d", "\\$e", "\\$ec", "\\$es", "\\$et", "\\$f", "\\$fn", "\\$g", "\\$h", "\\$i", "\\$j", "\\$l", "\\$n", "\\$na", "\\$o", "\\$p", "\\$q", "\\$ql", "\\$qs", "\\$r", "\\$re", "\\$s", "\\$st", "\\$t", "\\$tr", "\\$v", "\\$z"];
31
var intrinsicFuncs = wordRegexp(intrinsicFuncsWords);
32
var command = wordRegexp(commandKeywords);
34
function tokenBase(stream, state) {
37
state.commandMode = 0;
46
var ch = stream.peek();
48
if (ch == " " || ch == "\t") {
50
if (state.commandMode == 0)
51
state.commandMode = 1;
52
else if ((state.commandMode < 0) || (state.commandMode == 2))
53
state.commandMode = 0;
54
} else if ((ch != ".") && (state.commandMode > 0)) {
56
state.commandMode = -1;
58
state.commandMode = 2;
62
if ((ch === "(") || (ch === "\u0009"))
72
if (stream.match(/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?/))
77
if (stream.skipTo('"')) {
87
if (stream.match(doubleOperators) || stream.match(singleOperators))
91
if (stream.match(singleDelimiters))
94
if (brackets.test(ch)) {
99
if (state.commandMode > 0 && stream.match(command))
102
if (stream.match(intrinsicFuncs))
105
if (stream.match(identifiers))
110
if (ch === "$" || ch === "^") {
121
if (/[\w%]/.test(ch)) {
122
stream.eatWhile(/[\w%]/);
132
startState: function() {
139
token: function(stream, state) {
140
var style = tokenBase(stream, state);
141
if (state.label) return "tag";
147
CodeMirror.defineMIME("text/x-mumps", "mumps");