diff options
author | Wu Cheng-Han | 2015-05-04 15:53:29 +0800 |
---|---|---|
committer | Wu Cheng-Han | 2015-05-04 15:53:29 +0800 |
commit | 4b0ca55eb79e963523eb6c8197825e9e8ae904e2 (patch) | |
tree | 574f3923af77b37b41dbf1b00bcd7827ef724a28 /public/vendor/codemirror/mode/mumps | |
parent | 61eb11d23c65c9e5c493c67d055f785cbec139e2 (diff) |
First commit, version 0.2.7
Diffstat (limited to '')
-rwxr-xr-x | public/vendor/codemirror/mode/mumps/index.html | 85 | ||||
-rwxr-xr-x | public/vendor/codemirror/mode/mumps/mumps.js | 148 |
2 files changed, 233 insertions, 0 deletions
diff --git a/public/vendor/codemirror/mode/mumps/index.html b/public/vendor/codemirror/mode/mumps/index.html new file mode 100755 index 00000000..bd1f69ae --- /dev/null +++ b/public/vendor/codemirror/mode/mumps/index.html @@ -0,0 +1,85 @@ +<!doctype html> + +<title>CodeMirror: MUMPS mode</title> +<meta charset="utf-8"/> +<link rel=stylesheet href="../../doc/docs.css"> + +<link rel="stylesheet" href="../../lib/codemirror.css"> +<script src="../../lib/codemirror.js"></script> +<script src="mumps.js"></script> +<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> +<div id=nav> + <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> + + <ul> + <li><a href="../../index.html">Home</a> + <li><a href="../../doc/manual.html">Manual</a> + <li><a href="https://github.com/codemirror/codemirror">Code</a> + </ul> + <ul> + <li><a href="../index.html">Language modes</a> + <li><a class=active href="#">MUMPS</a> + </ul> +</div> + +<article> +<h2>MUMPS mode</h2> + + +<div><textarea id="code" name="code"> + ; Lloyd Milligan + ; 03-30-2015 + ; + ; MUMPS support for Code Mirror - Excerpts below from routine ^XUS + ; +CHECKAV(X1) ;Check A/V code return DUZ or Zero. (Called from XUSRB) + N %,%1,X,Y,IEN,DA,DIK + S IEN=0 + ;Start CCOW + I $E(X1,1,7)="~~TOK~~" D Q:IEN>0 IEN + . I $E(X1,8,9)="~1" S IEN=$$CHKASH^XUSRB4($E(X1,8,255)) + . I $E(X1,8,9)="~2" S IEN=$$CHKCCOW^XUSRB4($E(X1,8,255)) + . Q + ;End CCOW + S X1=$$UP(X1) S:X1[":" XUTT=1,X1=$TR(X1,":") + S X=$P(X1,";") Q:X="^" -1 S:XUF %1="Access: "_X + Q:X'?1.20ANP 0 + S X=$$EN^XUSHSH(X) I '$D(^VA(200,"A",X)) D LBAV Q 0 + S %1="",IEN=$O(^VA(200,"A",X,0)),XUF(.3)=IEN D USER(IEN) + S X=$P(X1,";",2) S:XUF %1="Verify: "_X S X=$$EN^XUSHSH(X) + I $P(XUSER(1),"^",2)'=X D LBAV Q 0 + I $G(XUFAC(1)) S DIK="^XUSEC(4,",DA=XUFAC(1) D ^DIK + Q IEN + ; + ; Spell out commands + ; +SET2() ;EF. Return error code (also called from XUSRB) + NEW %,X + SET XUNOW=$$HTFM^XLFDT($H),DT=$P(XUNOW,".") + KILL DUZ,XUSER + SET (DUZ,DUZ(2))=0,(DUZ(0),DUZ("AG"),XUSER(0),XUSER(1),XUTT,%UCI)="" + SET %=$$INHIBIT^XUSRB() IF %>0 QUIT % + SET X=$G(^%ZIS(1,XUDEV,"XUS")),XU1=$G(^(1)) + IF $L(X) FOR I=1:1:15 IF $L($P(X,U,I)) SET $P(XOPT,U,I)=$P(X,U,I) + SET DTIME=600 + IF '$P(XOPT,U,11),$D(^%ZIS(1,XUDEV,90)),^(90)>2800000,^(90)'>DT QUIT 8 + QUIT 0 + ; + ; Spell out commands and functions + ; + IF $PIECE(XUSER(0),U,11),$PIECE(XUSER(0),U,11)'>DT QUIT 11 ;Terminated + IF $DATA(DUZ("ASH")) QUIT 0 ;If auto handle, Allow to sign-on p434 + IF $PIECE(XUSER(0),U,7) QUIT 5 ;Disuser flag set + IF '$LENGTH($PIECE(XUSER(1),U,2)) QUIT 21 ;p419, p434 + Q 0 + ; + </textarea> + <script> + var editor = CodeMirror.fromTextArea(document.getElementById("code"), { + mode: "mumps", + lineNumbers: true, + lineWrapping: true + }); + </script> + + </article> diff --git a/public/vendor/codemirror/mode/mumps/mumps.js b/public/vendor/codemirror/mode/mumps/mumps.js new file mode 100755 index 00000000..469f8c3d --- /dev/null +++ b/public/vendor/codemirror/mode/mumps/mumps.js @@ -0,0 +1,148 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +/* + This MUMPS Language script was constructed using vbscript.js as a template. +*/ + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + CodeMirror.defineMode("mumps", function() { + function wordRegexp(words) { + return new RegExp("^((" + words.join(")|(") + "))\\b", "i"); + } + + var singleOperators = new RegExp("^[\\+\\-\\*/&#!_?\\\\<>=\\'\\[\\]]"); + var doubleOperators = new RegExp("^(('=)|(<=)|(>=)|('>)|('<)|([[)|(]])|(^$))"); + var singleDelimiters = new RegExp("^[\\.,:]"); + var brackets = new RegExp("[()]"); + var identifiers = new RegExp("^[%A-Za-z][A-Za-z0-9]*"); + 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"]; + // The following list includes instrinsic functions _and_ special variables + 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"]; + var intrinsicFuncs = wordRegexp(intrinsicFuncsWords); + var command = wordRegexp(commandKeywords); + + function tokenBase(stream, state) { + if (stream.sol()) { + state.label = true; + state.commandMode = 0; + } + + // The <space> character has meaning in MUMPS. Ignoring consecutive + // spaces would interfere with interpreting whether the next non-space + // character belongs to the command or argument context. + + // Examine each character and update a mode variable whose interpretation is: + // >0 => command 0 => argument <0 => command post-conditional + var ch = stream.peek(); + + if (ch == " " || ch == "\t") { // Pre-process <space> + state.label = false; + if (state.commandMode == 0) + state.commandMode = 1; + else if ((state.commandMode < 0) || (state.commandMode == 2)) + state.commandMode = 0; + } else if ((ch != ".") && (state.commandMode > 0)) { + if (ch == ":") + state.commandMode = -1; // SIS - Command post-conditional + else + state.commandMode = 2; + } + + // Do not color parameter list as line tag + if ((ch === "(") || (ch === "\u0009")) + state.label = false; + + // MUMPS comment starts with ";" + if (ch === ";") { + stream.skipToEnd(); + return "comment"; + } + + // Number Literals // SIS/RLM - MUMPS permits canonic number followed by concatenate operator + if (stream.match(/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?/)) + return "number"; + + // Handle Strings + if (ch == '"') { + if (stream.skipTo('"')) { + stream.next(); + return "string"; + } else { + stream.skipToEnd(); + return "error"; + } + } + + // Handle operators and Delimiters + if (stream.match(doubleOperators) || stream.match(singleOperators)) + return "operator"; + + // Prevents leading "." in DO block from falling through to error + if (stream.match(singleDelimiters)) + return null; + + if (brackets.test(ch)) { + stream.next(); + return "bracket"; + } + + if (state.commandMode > 0 && stream.match(command)) + return "variable-2"; + + if (stream.match(intrinsicFuncs)) + return "builtin"; + + if (stream.match(identifiers)) + return "variable"; + + // Detect dollar-sign when not a documented intrinsic function + // "^" may introduce a GVN or SSVN - Color same as function + if (ch === "$" || ch === "^") { + stream.next(); + return "builtin"; + } + + // MUMPS Indirection + if (ch === "@") { + stream.next(); + return "string-2"; + } + + if (/[\w%]/.test(ch)) { + stream.eatWhile(/[\w%]/); + return "variable"; + } + + // Handle non-detected items + stream.next(); + return "error"; + } + + return { + startState: function() { + return { + label: false, + commandMode: 0 + }; + }, + + token: function(stream, state) { + var style = tokenBase(stream, state); + if (state.label) return "tag"; + return style; + } + }; + }); + + CodeMirror.defineMIME("text/x-mumps", "mumps"); +}); |