Commit 8e335a7c authored by JOE Thunyathep S's avatar JOE Thunyathep S
Browse files

up

parent 43ea69a2
Pipeline #1969 passed with stage
in 36 seconds
<!doctype html>
<title>CodeMirror: Modelica 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="../../addon/edit/matchbrackets.js"></script>
<link rel="stylesheet" href="../../addon/hint/show-hint.css">
<script src="../../addon/hint/show-hint.js"></script>
<script src="modelica.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></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="#">Modelica</a>
</ul>
</div>
<article>
<h2>Modelica mode</h2>
<div><textarea id="modelica">
model BouncingBall
parameter Real e = 0.7;
parameter Real g = 9.81;
Real h(start=1);
Real v;
Boolean flying(start=true);
Boolean impact;
Real v_new;
equation
impact = h <= 0.0;
der(v) = if flying then -g else 0;
der(h) = v;
when {h <= 0.0 and v <= 0.0, impact} then
v_new = if edge(impact) then -e*pre(v) else 0;
flying = v_new > 0;
reinit(v, v_new);
end when;
annotation (uses(Modelica(version="3.2")));
end BouncingBall;
</textarea></div>
<script>
var modelicaEditor = CodeMirror.fromTextArea(document.getElementById("modelica"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-modelica"
});
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
</script>
<p>Simple mode that tries to handle Modelica as well as it can.</p>
<p><strong>MIME types defined:</strong> <code>text/x-modelica</code>
(Modlica code).</p>
</article>
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// Modelica support for CodeMirror, copyright (c) by Lennart Ochel
(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("modelica", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var keywords = parserConfig.keywords || {};
var builtin = parserConfig.builtin || {};
var atoms = parserConfig.atoms || {};
var isSingleOperatorChar = /[;=\(:\),{}.*<>+\-\/^\[\]]/;
var isDoubleOperatorChar = /(:=|<=|>=|==|<>|\.\+|\.\-|\.\*|\.\/|\.\^)/;
var isDigit = /[0-9]/;
var isNonDigit = /[_a-zA-Z]/;
function tokenLineComment(stream, state) {
stream.skipToEnd();
state.tokenize = null;
return "comment";
}
function tokenBlockComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (maybeEnd && ch == "/") {
state.tokenize = null;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function tokenString(stream, state) {
var escaped = false, ch;
while ((ch = stream.next()) != null) {
if (ch == '"' && !escaped) {
state.tokenize = null;
state.sol = false;
break;
}
escaped = !escaped && ch == "\\";
}
return "string";
}
function tokenIdent(stream, state) {
stream.eatWhile(isDigit);
while (stream.eat(isDigit) || stream.eat(isNonDigit)) { }
var cur = stream.current();
if(state.sol && (cur == "package" || cur == "model" || cur == "when" || cur == "connector")) state.level++;
else if(state.sol && cur == "end" && state.level > 0) state.level--;
state.tokenize = null;
state.sol = false;
if (keywords.propertyIsEnumerable(cur)) return "keyword";
else if (builtin.propertyIsEnumerable(cur)) return "builtin";
else if (atoms.propertyIsEnumerable(cur)) return "atom";
else return "variable";
}
function tokenQIdent(stream, state) {
while (stream.eat(/[^']/)) { }
state.tokenize = null;
state.sol = false;
if(stream.eat("'"))
return "variable";
else
return "error";
}
function tokenUnsignedNuber(stream, state) {
stream.eatWhile(isDigit);
if (stream.eat('.')) {
stream.eatWhile(isDigit);
}
if (stream.eat('e') || stream.eat('E')) {
if (!stream.eat('-'))
stream.eat('+');
stream.eatWhile(isDigit);
}
state.tokenize = null;
state.sol = false;
return "number";
}
// Interface
return {
startState: function() {
return {
tokenize: null,
level: 0,
sol: true
};
},
token: function(stream, state) {
if(state.tokenize != null) {
return state.tokenize(stream, state);
}
if(stream.sol()) {
state.sol = true;
}
// WHITESPACE
if(stream.eatSpace()) {
state.tokenize = null;
return null;
}
var ch = stream.next();
// LINECOMMENT
if(ch == '/' && stream.eat('/')) {
state.tokenize = tokenLineComment;
}
// BLOCKCOMMENT
else if(ch == '/' && stream.eat('*')) {
state.tokenize = tokenBlockComment;
}
// TWO SYMBOL TOKENS
else if(isDoubleOperatorChar.test(ch+stream.peek())) {
stream.next();
state.tokenize = null;
return "operator";
}
// SINGLE SYMBOL TOKENS
else if(isSingleOperatorChar.test(ch)) {
state.tokenize = null;
return "operator";
}
// IDENT
else if(isNonDigit.test(ch)) {
state.tokenize = tokenIdent;
}
// Q-IDENT
else if(ch == "'" && stream.peek() && stream.peek() != "'") {
state.tokenize = tokenQIdent;
}
// STRING
else if(ch == '"') {
state.tokenize = tokenString;
}
// UNSIGNED_NUBER
else if(isDigit.test(ch)) {
state.tokenize = tokenUnsignedNuber;
}
// ERROR
else {
state.tokenize = null;
return "error";
}
return state.tokenize(stream, state);
},
indent: function(state, textAfter) {
if (state.tokenize != null) return CodeMirror.Pass;
var level = state.level;
if(/(algorithm)/.test(textAfter)) level--;
if(/(equation)/.test(textAfter)) level--;
if(/(initial algorithm)/.test(textAfter)) level--;
if(/(initial equation)/.test(textAfter)) level--;
if(/(end)/.test(textAfter)) level--;
if(level > 0)
return indentUnit*level;
else
return 0;
},
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//"
};
});
function words(str) {
var obj = {}, words = str.split(" ");
for (var i=0; i<words.length; ++i)
obj[words[i]] = true;
return obj;
}
var modelicaKeywords = "algorithm and annotation assert block break class connect connector constant constrainedby der discrete each else elseif elsewhen encapsulated end enumeration equation expandable extends external false final flow for function if import impure in initial inner input loop model not operator or outer output package parameter partial protected public pure record redeclare replaceable return stream then true type when while within";
var modelicaBuiltin = "abs acos actualStream asin atan atan2 cardinality ceil cos cosh delay div edge exp floor getInstanceName homotopy inStream integer log log10 mod pre reinit rem semiLinear sign sin sinh spatialDistribution sqrt tan tanh";
var modelicaAtoms = "Real Boolean Integer String";
function def(mimes, mode) {
if (typeof mimes == "string")
mimes = [mimes];
var words = [];
function add(obj) {
if (obj)
for (var prop in obj)
if (obj.hasOwnProperty(prop))
words.push(prop);
}
add(mode.keywords);
add(mode.builtin);
add(mode.atoms);
if (words.length) {
mode.helperType = mimes[0];
CodeMirror.registerHelper("hintWords", mimes[0], words);
}
for (var i=0; i<mimes.length; ++i)
CodeMirror.defineMIME(mimes[i], mode);
}
def(["text/x-modelica"], {
name: "modelica",
keywords: words(modelicaKeywords),
builtin: words(modelicaBuiltin),
atoms: words(modelicaAtoms)
});
});
<!doctype html>
<title>CodeMirror: MscGen 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="mscgen.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></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="#">MscGen</a>
</ul>
</div>
<article>
<h2>MscGen mode</h2>
<div><textarea id="mscgen-code">
# Sample mscgen program
# See http://www.mcternan.me.uk/mscgen or
# https://sverweij.github.io/mscgen_js for more samples
msc {
# options
hscale="1.2";
# entities/ lifelines
a [label="Entity A"],
b [label="Entity B", linecolor="red", arclinecolor="red", textbgcolor="pink"],
c [label="Entity C"];
# arcs/ messages
a => c [label="doSomething(args)"];
b => c [label="doSomething(args)"];
c >> * [label="everyone asked me", arcskip="1"];
c =>> c [label="doing something"];
c -x * [label="report back", arcskip="1"];
|||;
--- [label="shows's over, however ..."];
b => a [label="did you see c doing something?"];
a -> b [label="nope"];
b :> a [label="shall we ask again?"];
a => b [label="naah"];
...;
}
</textarea></div>
<h2>Xù mode</h2>
<div><textarea id="xu-code">
# Xù - expansions to MscGen to support inline expressions
# https://github.com/sverweij/mscgen_js/blob/master/wikum/xu.md
# More samples: https://sverweij.github.io/mscgen_js
xu {
hscale="0.8",
width="700";
a,
b [label="change store"],
c,
d [label="necro queue"],
e [label="natalis queue"],
f;
a =>> b [label="get change list()"];
a alt f [label="changes found"] { /* alt is a xu specific keyword*/
b >> a [label="list of changes"];
a =>> c [label="cull old stuff (list of changes)"];
b loop e [label="for each change"] { // loop is xu specific as well...
/*
* Interesting stuff happens.
*/
c =>> b [label="get change()"];
b >> c [label="change"];
c alt e [label="change too old"] {
c =>> d [label="queue(change)"];
--- [label="change newer than latest run"];
c =>> e [label="queue(change)"];
--- [label="all other cases"];
||| [label="leave well alone"];
};
};
c >> a [label="done
processing"];
/* shucks! nothing found ...*/
--- [label="nothing found"];
b >> a [label="nothing"];
a note a [label="silent exit"];
};
}
</textarea></div>
<h2>MsGenny mode</h2>
<div><textarea id="msgenny-code">
# MsGenny - simplified version of MscGen / Xù
# https://github.com/sverweij/mscgen_js/blob/master/wikum/msgenny.md
# More samples: https://sverweij.github.io/mscgen_js
a -> b : a -> b (signal);
a => b : a => b (method);
b >> a : b >> a (return value);
a =>> b : a =>> b (callback);
a -x b : a -x b (lost);
a :> b : a :> b (emphasis);
a .. b : a .. b (dotted);
a -- b : "a -- b straight line";
a note a : a note a\n(note),
b box b : b box b\n(action);
a rbox a : a rbox a\n(reference),
b abox b : b abox b\n(state/ condition);
||| : ||| (empty row);
... : ... (omitted row);
--- : --- (comment);
</textarea></div>
<p>
Simple mode for highlighting MscGen and two derived sequence
chart languages.
</p>
<script>
var mscgenEditor = CodeMirror.fromTextArea(document.getElementById("mscgen-code"), {
lineNumbers: true,
mode: "text/x-mscgen",
});
var xuEditor = CodeMirror.fromTextArea(document.getElementById("xu-code"), {
lineNumbers: true,
mode: "text/x-xu",
});
var msgennyEditor = CodeMirror.fromTextArea(document.getElementById("msgenny-code"), {
lineNumbers: true,
mode: "text/x-msgenny",
});
</script>
<p><strong>MIME types defined:</strong>
<code>text/x-mscgen</code>
<code>text/x-xu</code>
<code>text/x-msgenny</code>
</p>
</article>
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// mode(s) for the sequence chart dsl's mscgen, xù and msgenny
// For more information on mscgen, see the site of the original author:
// http://www.mcternan.me.uk/mscgen
//
// This mode for mscgen and the two derivative languages were
// originally made for use in the mscgen_js interpreter
// (https://sverweij.github.io/mscgen_js)
(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";
var languages = {
mscgen: {
"keywords" : ["msc"],
"options" : ["hscale", "width", "arcgradient", "wordwraparcs"],
"constants" : ["true", "false", "on", "off"],
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
"brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
"arcsWords" : ["note", "abox", "rbox", "box"],
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
"singlecomment" : ["//", "#"],
"operators" : ["="]
},
xu: {
"keywords" : ["msc", "xu"],
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"],
"constants" : ["true", "false", "on", "off", "auto"],
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip", "title", "deactivate", "activate", "activation"],
"brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
"singlecomment" : ["//", "#"],
"operators" : ["="]
},
msgenny: {
"keywords" : null,
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"],
"constants" : ["true", "false", "on", "off", "auto"],
"attributes" : null,
"brackets" : ["\\{", "\\}"],
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
"singlecomment" : ["//", "#"],
"operators" : ["="]
}
}
CodeMirror.defineMode("mscgen", function(_, modeConfig) {
var language = languages[modeConfig && modeConfig.language || "mscgen"]
return {
startState: startStateFn,
copyState: copyStateFn,
token: produceTokenFunction(language),
lineComment : "#",
blockCommentStart : "/*",
blockCommentEnd : "*/"
};
});
CodeMirror.defineMIME("text/x-mscgen", "mscgen");
CodeMirror.defineMIME("text/x-xu", {name: "mscgen", language: "xu"});
CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"});
function wordRegexpBoundary(pWords) {
return new RegExp("\\b(" + pWords.join("|") + ")\\b", "i");
}
function wordRegexp(pWords) {
return new RegExp("(" + pWords.join("|") + ")", "i");
}
function startStateFn() {
return {
inComment : false,
inString : false,
inAttributeList : false,
inScript : false
};
}
function copyStateFn(pState) {
return {
inComment : pState.inComment,
inString : pState.inString,
inAttributeList : pState.inAttributeList,
inScript : pState.inScript
};
}
function produceTokenFunction(pConfig) {
return function(pStream, pState) {
if (pStream.match(wordRegexp(pConfig.brackets), true, true)) {
return "bracket";
}
/* comments */
if (!pState.inComment) {
if (pStream.match(/\/\*[^\*\/]*/, true, true)) {
pState.inComment = true;
return "comment";
}
if (pStream.match(wordRegexp(pConfig.singlecomment), true, true)) {
pStream.skipToEnd();
return "comment";
}
}
if (pState.inComment) {
if (pStream.match(/[^\*\/]*\*\//, true, true))
pState.inComment = false;
else
pStream.skipToEnd();
return "comment";
}
/* strings */
if (!pState.inString && pStream.match(/\"(\\\"|[^\"])*/, true, true)) {
pState.inString = true;
return "string";
}
if (pState.inString) {
if (pStream.match(/[^\"]*\"/, true, true))
pState.inString = false;
else
pStream.skipToEnd();
return "string";
}
/* keywords & operators */
if (!!pConfig.keywords && pStream.match(wordRegexpBoundary(pConfig.keywords), true, true))
return "keyword";
if (pStream.match(wordRegexpBoundary(pConfig.options), true, true))
return "keyword";
if (pStream.match(wordRegexpBoundary(pConfig.arcsWords), true, true))
return "keyword";
if (pStream.match(wordRegexp(pConfig.arcsOthers), true, true))
return "keyword";
if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true))
return "operator";
if (!!pConfig.constants && pStream.match(wordRegexp(pConfig.constants), true, true))
return "variable";
/* attribute lists */
if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) {
pConfig.inAttributeList = true;
return "bracket";
}
if (pConfig.inAttributeList) {
if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) {
return "attribute";
}
if (pStream.match(/]/, true, true)) {
pConfig.inAttributeList = false;
return "bracket";
}
}
pStream.next();
return "base";
};
}
});
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "mscgen");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("empty chart",
"[keyword msc][bracket {]",
"[base ]",
"[bracket }]"
);
MT("comments",
"[comment // a single line comment]",
"[comment # another single line comment /* and */ ignored here]",
"[comment /* A multi-line comment even though it contains]",
"[comment msc keywords and \"quoted text\"*/]");
MT("strings",
"[string \"// a string\"]",
"[string \"a string running over]",
"[string two lines\"]",
"[string \"with \\\"escaped quote\"]"
);
MT("xù/ msgenny keywords classify as 'base'",
"[base watermark]",
"[base wordwrapentities]",
"[base alt loop opt ref else break par seq assert]"
);
MT("xù/ msgenny constants classify as 'base'",
"[base auto]"
);
MT("mscgen constants classify as 'variable'",
"[variable true]", "[variable false]", "[variable on]", "[variable off]"
);
MT("mscgen options classify as keyword",
"[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
);
MT("mscgen arcs classify as keyword",
"[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
"[keyword |||...---]", "[keyword ..--==::]",
"[keyword ->]", "[keyword <-]", "[keyword <->]",
"[keyword =>]", "[keyword <=]", "[keyword <=>]",
"[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
"[keyword >>]", "[keyword <<]", "[keyword <<>>]",
"[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
"[keyword :>]", "[keyword <:]", "[keyword <:>]"
);
MT("within an attribute list, attributes classify as attribute",
"[bracket [[][attribute label]",
"[attribute id]","[attribute url]","[attribute idurl]",
"[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
"[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
"[attribute arcskip][bracket ]]]"
);
MT("outside an attribute list, attributes classify as base",
"[base label]",
"[base id]","[base url]","[base idurl]",
"[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
"[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
"[base arcskip]"
);
MT("a typical program",
"[comment # typical mscgen program]",
"[keyword msc][base ][bracket {]",
"[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
"[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
"[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
"[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
"[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
"[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][bracket ]]][base ;]",
"[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
"[bracket }]"
);
})();
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-msgenny");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "msgenny"); }
MT("comments",
"[comment // a single line comment]",
"[comment # another single line comment /* and */ ignored here]",
"[comment /* A multi-line comment even though it contains]",
"[comment msc keywords and \"quoted text\"*/]");
MT("strings",
"[string \"// a string\"]",
"[string \"a string running over]",
"[string two lines\"]",
"[string \"with \\\"escaped quote\"]"
);
MT("xù/ msgenny keywords classify as 'keyword'",
"[keyword watermark]",
"[keyword wordwrapentities]",
"[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
);
MT("xù/ msgenny constants classify as 'variable'",
"[variable auto]",
"[variable true]", "[variable false]", "[variable on]", "[variable off]"
);
MT("mscgen options classify as keyword",
"[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
);
MT("mscgen arcs classify as keyword",
"[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
"[keyword |||...---]", "[keyword ..--==::]",
"[keyword ->]", "[keyword <-]", "[keyword <->]",
"[keyword =>]", "[keyword <=]", "[keyword <=>]",
"[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
"[keyword >>]", "[keyword <<]", "[keyword <<>>]",
"[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
"[keyword :>]", "[keyword <:]", "[keyword <:>]"
);
MT("within an attribute list, mscgen/ xù attributes classify as base",
"[base [[label]",
"[base idurl id url]",
"[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]",
"[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]",
"[base arcskip]]]"
);
MT("outside an attribute list, mscgen/ xù attributes classify as base",
"[base label]",
"[base idurl id url]",
"[base linecolor linecolour textcolor textcolour textbgcolor textbgcolour]",
"[base arclinecolor arclinecolour arctextcolor arctextcolour arctextbgcolor arctextbgcolour]",
"[base arcskip]"
);
MT("a typical program",
"[comment # typical msgenny program]",
"[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
"[base a : ][string \"Entity A\"][base ,]",
"[base b : Entity B,]",
"[base c : Entity C;]",
"[base a ][keyword =>>][base b: ][string \"Hello entity B\"][base ;]",
"[base a ][keyword alt][base c][bracket {]",
"[base a ][keyword <<][base b: ][string \"Here's an answer dude!\"][base ;]",
"[keyword ---][base : ][string \"sorry, won't march - comm glitch\"]",
"[base a ][keyword x-][base b: ][string \"Here's an answer dude! (won't arrive...)\"][base ;]",
"[bracket }]",
"[base c ][keyword :>][base *: What about me?;]"
);
})();
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-xu");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "xu"); }
MT("empty chart",
"[keyword msc][bracket {]",
"[base ]",
"[bracket }]"
);
MT("empty chart",
"[keyword xu][bracket {]",
"[base ]",
"[bracket }]"
);
MT("comments",
"[comment // a single line comment]",
"[comment # another single line comment /* and */ ignored here]",
"[comment /* A multi-line comment even though it contains]",
"[comment msc keywords and \"quoted text\"*/]");
MT("strings",
"[string \"// a string\"]",
"[string \"a string running over]",
"[string two lines\"]",
"[string \"with \\\"escaped quote\"]"
);
MT("xù/ msgenny keywords classify as 'keyword'",
"[keyword watermark]",
"[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
);
MT("xù/ msgenny constants classify as 'variable'",
"[variable auto]",
"[variable true]", "[variable false]", "[variable on]", "[variable off]"
);
MT("mscgen options classify as keyword",
"[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
);
MT("mscgen arcs classify as keyword",
"[keyword note]","[keyword abox]","[keyword rbox]","[keyword box]",
"[keyword |||...---]", "[keyword ..--==::]",
"[keyword ->]", "[keyword <-]", "[keyword <->]",
"[keyword =>]", "[keyword <=]", "[keyword <=>]",
"[keyword =>>]", "[keyword <<=]", "[keyword <<=>>]",
"[keyword >>]", "[keyword <<]", "[keyword <<>>]",
"[keyword -x]", "[keyword x-]", "[keyword -X]", "[keyword X-]",
"[keyword :>]", "[keyword <:]", "[keyword <:>]"
);
MT("within an attribute list, attributes classify as attribute",
"[bracket [[][attribute label]",
"[attribute id]","[attribute url]","[attribute idurl]",
"[attribute linecolor]","[attribute linecolour]","[attribute textcolor]","[attribute textcolour]","[attribute textbgcolor]","[attribute textbgcolour]",
"[attribute arclinecolor]","[attribute arclinecolour]","[attribute arctextcolor]","[attribute arctextcolour]","[attribute arctextbgcolor]","[attribute arctextbgcolour]",
"[attribute arcskip]","[attribute title]",
"[attribute activate]","[attribute deactivate]","[attribute activation][bracket ]]]"
);
MT("outside an attribute list, attributes classify as base",
"[base label]",
"[base id]","[base url]","[base idurl]",
"[base linecolor]","[base linecolour]","[base textcolor]","[base textcolour]","[base textbgcolor]","[base textbgcolour]",
"[base arclinecolor]","[base arclinecolour]","[base arctextcolor]","[base arctextcolour]","[base arctextbgcolor]","[base arctextbgcolour]",
"[base arcskip]", "[base title]"
);
MT("a typical program",
"[comment # typical xu program]",
"[keyword xu][base ][bracket {]",
"[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30, ][keyword width][operator =][variable auto][base ;]",
"[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
"[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
"[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",
"[base a ][keyword =>>][base b][bracket [[][attribute label][operator =][string \"Hello entity B\"][bracket ]]][base ;]",
"[base a ][keyword <<][base b][bracket [[][attribute label][operator =][string \"Here's an answer dude!\"][base , ][attribute title][operator =][string \"This is a title for this message\"][bracket ]]][base ;]",
"[base c ][keyword :>][base *][bracket [[][attribute label][operator =][string \"What about me?\"][base , ][attribute textcolor][operator =][base red][bracket ]]][base ;]",
"[bracket }]"
);
})();
<!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>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></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></div>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "mumps",
lineNumbers: true,
lineWrapping: true
});
</script>
</article>
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://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");
});
<!doctype html>
<head>
<title>CodeMirror: NGINX 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="nginx.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<style>
body {
margin: 0em auto;
}
.CodeMirror, .CodeMirror-scroll {
height: 600px;
}
</style>
<div id=nav>
<a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></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="#">NGINX</a>
</ul>
</div>
<article>
<h2>NGINX mode</h2>
<form><textarea id="code" name="code" style="height: 800px;">
server {
listen 173.255.219.235:80;
server_name website.com.au;
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
}
server {
listen 173.255.219.235:443;
server_name website.com.au;
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
}
server {
listen 173.255.219.235:80;
server_name www.website.com.au;
root /data/www;
index index.html index.php;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file /rs/passwords/testfile; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^/(.*.php)/ /$1 last;
}
location ~ \.php$ {
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /rs/confs/nginx/fastcgi_params;
}
}
server {
listen 173.255.219.235:443;
server_name website.com.au www.website.com.au;
root /data/www;
index index.html index.php;
ssl on;
ssl_certificate /rs/ssl/ssl.crt;
ssl_certificate_key /rs/ssl/ssl.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^/(.*.php)/ /$1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite /index.php last; } ## Catch 404s that try_files miss
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /rs/confs/nginx/fastcgi_params;
fastcgi_param HTTPS on;
}
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
</script>
<p><strong>MIME types defined:</strong> <code>text/x-nginx-conf</code>.</p>
</article>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment