| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| <!doctype html> | ||
|
|
||
| <title>CodeMirror: Closure Stylesheets (GSS) mode</title> | ||
| <meta charset="utf-8"/> | ||
| <link rel=stylesheet href="../../doc/docs.css"> | ||
|
|
||
| <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
| <link rel="stylesheet" href="../../addon/hint/show-hint.css"> | ||
| <script src="../../lib/codemirror.js"></script> | ||
| <script src="css.js"></script> | ||
| <script src="../../addon/hint/show-hint.js"></script> | ||
| <script src="../../addon/hint/css-hint.js"></script> | ||
| <style>.CodeMirror {background: #f8f8f8;}</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="#">Closure Stylesheets (GSS)</a> | ||
| </ul> | ||
| </div> | ||
|
|
||
| <article> | ||
| <h2>Closure Stylesheets (GSS) mode</h2> | ||
| <form><textarea id="code" name="code"> | ||
| /* Some example Closure Stylesheets */ | ||
|
|
||
| @provide 'some.styles'; | ||
|
|
||
| @require 'other.styles'; | ||
|
|
||
| @component { | ||
|
|
||
| @def FONT_FAMILY "Times New Roman", Georgia, Serif; | ||
| @def FONT_SIZE_NORMAL 15px; | ||
| @def FONT_NORMAL normal FONT_SIZE_NORMAL FONT_FAMILY; | ||
|
|
||
| @def BG_COLOR rgb(235, 239, 249); | ||
|
|
||
| @def DIALOG_BORDER_COLOR rgb(107, 144, 218); | ||
| @def DIALOG_BG_COLOR BG_COLOR; | ||
|
|
||
| @def LEFT_HAND_NAV_WIDTH 180px; | ||
| @def LEFT_HAND_NAV_PADDING 3px; | ||
|
|
||
| @defmixin size(WIDTH, HEIGHT) { | ||
| width: WIDTH; | ||
| height: HEIGHT; | ||
| } | ||
|
|
||
| body { | ||
| background-color: BG_COLOR; | ||
| margin: 0; | ||
| padding: 3em 6em; | ||
| font: FONT_NORMAL; | ||
| color: #000; | ||
| } | ||
|
|
||
| #navigation a { | ||
| font-weight: bold; | ||
| text-decoration: none !important; | ||
| } | ||
|
|
||
| .dialog { | ||
| background-color: DIALOG_BG_COLOR; | ||
| border: 1px solid DIALOG_BORDER_COLOR; | ||
| } | ||
|
|
||
| .content { | ||
| position: absolute; | ||
| margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */ | ||
| LEFT_HAND_NAV_WIDTH, | ||
| LEFT_HAND_NAV_PADDING); /* padding right */ | ||
|
|
||
| } | ||
|
|
||
| .logo { | ||
| @mixin size(150px, 55px); | ||
| background-image: url('http://www.google.com/images/logo_sm.gif'); | ||
| } | ||
|
|
||
| } | ||
| </textarea></form> | ||
| <script> | ||
| var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
| extraKeys: {"Ctrl-Space": "autocomplete"}, | ||
| lineNumbers: true, | ||
| matchBrackets: "text/x-less", | ||
| mode: "text/x-gss" | ||
| }); | ||
| </script> | ||
|
|
||
| <p>A mode for <a href="https://github.com/google/closure-stylesheets">Closure Stylesheets</a> (GSS).</p> | ||
| <p><strong>MIME type defined:</strong> <code>text/x-gss</code>.</p> | ||
|
|
||
| <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gss_*">normal</a>, <a href="../../test/index.html#verbose,gss_*">verbose</a>.</p> | ||
|
|
||
| </article> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
| // Distributed under an MIT license: http://codemirror.net/LICENSE | ||
|
|
||
| (function() { | ||
| "use strict"; | ||
|
|
||
| var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-gss"); | ||
| function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "gss"); } | ||
|
|
||
| MT("atComponent", | ||
| "[def @component] {", | ||
| "[tag foo] {", | ||
| " [property color]: [keyword black];", | ||
| "}", | ||
| "}"); | ||
|
|
||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,4 +202,4 @@ | |
| }); | ||
|
|
||
| CodeMirror.defineMIME("text/x-elm", "elm"); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <!doctype html> | ||
|
|
||
| <title>CodeMirror: Oz 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="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="#">MscGen</a> | ||
| </ul> | ||
| </div> | ||
|
|
||
| <article> | ||
| <h2>MscGen mode</h2> | ||
|
|
||
| <div><textarea id="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> | ||
|
|
||
| <script> | ||
| var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
| lineNumbers: true, | ||
| mode: "mscgen", | ||
| }); | ||
| </script> | ||
|
|
||
| <p><strong>MIME types defined:</strong> <code>text/x-mscgen</code></p> | ||
| </article> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>CodeMirror: msgenny mode</title> | ||
| <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
| <script src="../../lib/codemirror.js"></script> | ||
| <script src="mscgen.js"></script> | ||
| <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> | ||
| </head> | ||
| <body> | ||
| <h1>CodeMirror: msgenny mode</h1> | ||
|
|
||
| <div><textarea id="code"> | ||
| # Sample msgenny program | ||
| # https://sverweij.github.io/mscgen_js for more samples | ||
|
|
||
| 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> | ||
|
|
||
| <script> | ||
| var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
| lineNumbers: true, | ||
| mode: "msgenny", | ||
| }); | ||
| </script> | ||
|
|
||
| <p><strong>MIME types defined:</strong> <code>text/x-msgenny</code></p> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>CodeMirror: xu mode</title> | ||
| <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
| <script src="../../lib/codemirror.js"></script> | ||
| <script src="mscgen.js"></script> | ||
| <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> | ||
| </head> | ||
| <body> | ||
| <h1>CodeMirror: xù mode</h1> | ||
|
|
||
| <div><textarea id="code"> | ||
| # test50 - expansions to mscgen to support inline expressions | ||
| # for now in a separate language: xù | ||
| msc { | ||
|
|
||
| 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... | ||
| /* | ||
| * Here interesting stuff happens. | ||
| * TBD | ||
| */ | ||
| 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> | ||
|
|
||
| <script> | ||
| var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
| lineNumbers: true, | ||
| mode: "xu", | ||
| }); | ||
| </script> | ||
|
|
||
| <p><strong>MIME types defined:</strong> <code>text/x-xu</code></p> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
| // Distributed under an MIT license: http://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"], | ||
| "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"], | ||
| "options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"], | ||
| "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", "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", "watermark"], | ||
| "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"; | ||
|
|
||
| /* 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"; | ||
| }; | ||
| } | ||
|
|
||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
| // Distributed under an MIT license: http://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 alt loop opt ref else break par seq assert]" | ||
| ); | ||
|
|
||
| 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 =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][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 }]" | ||
| ); | ||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
| // Distributed under an MIT license: http://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 alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]" | ||
| ); | ||
|
|
||
| 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 =][string \"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?;]" | ||
| ); | ||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
| // Distributed under an MIT license: http://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("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("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 =][string \"true\"][keyword hscale][operator =][string \"0.8\"][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 }]" | ||
| ); | ||
| })(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <!doctype html> | ||
|
|
||
| <title>CodeMirror: Oz 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="oz.js"></script> | ||
| <script type="text/javascript" src="../../addon/runmode/runmode.js"></script> | ||
| <style> | ||
| .CodeMirror {border: 1px solid #aaa;} | ||
| </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="#">Oz</a> | ||
| </ul> | ||
| </div> | ||
|
|
||
| <article> | ||
| <h2>Oz mode</h2> | ||
| <textarea id="code" name="code"> | ||
| declare | ||
| fun {Ints N Max} | ||
| if N == Max then nil | ||
| else | ||
| {Delay 1000} | ||
| N|{Ints N+1 Max} | ||
| end | ||
| end | ||
|
|
||
| fun {Sum S Stream} | ||
| case Stream of nil then S | ||
| [] H|T then S|{Sum H+S T} end | ||
| end | ||
|
|
||
| local X Y in | ||
| thread X = {Ints 0 1000} end | ||
| thread Y = {Sum 0 X} end | ||
| {Browse Y} | ||
| end | ||
| </textarea> | ||
| <p>MIME type defined: <code>text/x-oz</code>.</p> | ||
|
|
||
| <script type="text/javascript"> | ||
| var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
| lineNumbers: true, | ||
| mode: "text/x-oz", | ||
| readOnly: false | ||
| }); | ||
| </script> | ||
| </article> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
| // Distributed under an MIT license: http://codemirror.net/LICENSE | ||
|
|
||
| (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("oz", function (conf) { | ||
|
|
||
| function wordRegexp(words) { | ||
| return new RegExp("^((" + words.join(")|(") + "))\\b"); | ||
| } | ||
|
|
||
| var singleOperators = /[\^@!\|<>#~\.\*\-\+\\/,=]/; | ||
| var doubleOperators = /(<-)|(:=)|(=<)|(>=)|(<=)|(<:)|(>:)|(=:)|(\\=)|(\\=:)|(!!)|(==)|(::)/; | ||
| var tripleOperators = /(:::)|(\.\.\.)|(=<:)|(>=:)/; | ||
|
|
||
| var middle = ["in", "then", "else", "of", "elseof", "elsecase", "elseif", "catch", | ||
| "finally", "with", "require", "prepare", "import", "export", "define", "do"]; | ||
| var end = ["end"]; | ||
|
|
||
| var atoms = wordRegexp(["true", "false", "nil", "unit"]); | ||
| var commonKeywords = wordRegexp(["andthen", "at", "attr", "declare", "feat", "from", "lex", | ||
| "mod", "mode", "orelse", "parser", "prod", "prop", "scanner", "self", "syn", "token"]); | ||
| var openingKeywords = wordRegexp(["local", "proc", "fun", "case", "class", "if", "cond", "or", "dis", | ||
| "choice", "not", "thread", "try", "raise", "lock", "for", "suchthat", "meth", "functor"]); | ||
| var middleKeywords = wordRegexp(middle); | ||
| var endKeywords = wordRegexp(end); | ||
|
|
||
| // Tokenizers | ||
| function tokenBase(stream, state) { | ||
| if (stream.eatSpace()) { | ||
| return null; | ||
| } | ||
|
|
||
| // Brackets | ||
| if(stream.match(/[{}]/)) { | ||
| return "bracket"; | ||
| } | ||
|
|
||
| // Special [] keyword | ||
| if (stream.match(/(\[])/)) { | ||
| return "keyword" | ||
| } | ||
|
|
||
| // Operators | ||
| if (stream.match(tripleOperators) || stream.match(doubleOperators)) { | ||
| return "operator"; | ||
| } | ||
|
|
||
| // Atoms | ||
| if(stream.match(atoms)) { | ||
| return 'atom'; | ||
| } | ||
|
|
||
| // Opening keywords | ||
| var matched = stream.match(openingKeywords); | ||
| if (matched) { | ||
| if (!state.doInCurrentLine) | ||
| state.currentIndent++; | ||
| else | ||
| state.doInCurrentLine = false; | ||
|
|
||
| // Special matching for signatures | ||
| if(matched[0] == "proc" || matched[0] == "fun") | ||
| state.tokenize = tokenFunProc; | ||
| else if(matched[0] == "class") | ||
| state.tokenize = tokenClass; | ||
| else if(matched[0] == "meth") | ||
| state.tokenize = tokenMeth; | ||
|
|
||
| return 'keyword'; | ||
| } | ||
|
|
||
| // Middle and other keywords | ||
| if (stream.match(middleKeywords) || stream.match(commonKeywords)) { | ||
| return "keyword" | ||
| } | ||
|
|
||
| // End keywords | ||
| if (stream.match(endKeywords)) { | ||
| state.currentIndent--; | ||
| return 'keyword'; | ||
| } | ||
|
|
||
| // Eat the next char for next comparisons | ||
| var ch = stream.next(); | ||
|
|
||
| // Strings | ||
| if (ch == '"' || ch == "'") { | ||
| state.tokenize = tokenString(ch); | ||
| return state.tokenize(stream, state); | ||
| } | ||
|
|
||
| // Numbers | ||
| if (/[~\d]/.test(ch)) { | ||
| if (ch == "~") { | ||
| if(! /^[0-9]/.test(stream.peek())) | ||
| return null; | ||
| else if (( stream.next() == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)) | ||
| return "number"; | ||
| } | ||
|
|
||
| if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/)) || stream.match(/^[0-9]*(\.[0-9]+)?([eE][~+]?[0-9]+)?/)) | ||
| return "number"; | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| // Comments | ||
| if (ch == "%") { | ||
| stream.skipToEnd(); | ||
| return 'comment'; | ||
| } | ||
| else if (ch == "/") { | ||
| if (stream.eat("*")) { | ||
| state.tokenize = tokenComment; | ||
| return tokenComment(stream, state); | ||
| } | ||
| } | ||
|
|
||
| // Single operators | ||
| if(singleOperators.test(ch)) { | ||
| return "operator"; | ||
| } | ||
|
|
||
| // If nothing match, we skip the entire alphanumerical block | ||
| stream.eatWhile(/\w/); | ||
|
|
||
| return "variable"; | ||
| } | ||
|
|
||
| function tokenClass(stream, state) { | ||
| if (stream.eatSpace()) { | ||
| return null; | ||
| } | ||
| stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)/); | ||
| state.tokenize = tokenBase; | ||
| return "variable-3" | ||
| } | ||
|
|
||
| function tokenMeth(stream, state) { | ||
| if (stream.eatSpace()) { | ||
| return null; | ||
| } | ||
| stream.match(/([a-zA-Z][A-Za-z0-9_]*)|(`.+`)/); | ||
| state.tokenize = tokenBase; | ||
| return "def" | ||
| } | ||
|
|
||
| function tokenFunProc(stream, state) { | ||
| if (stream.eatSpace()) { | ||
| return null; | ||
| } | ||
|
|
||
| if(!state.hasPassedFirstStage && stream.eat("{")) { | ||
| state.hasPassedFirstStage = true; | ||
| return "bracket"; | ||
| } | ||
| else if(state.hasPassedFirstStage) { | ||
| stream.match(/([A-Z][A-Za-z0-9_]*)|(`.+`)|\$/); | ||
| state.hasPassedFirstStage = false; | ||
| state.tokenize = tokenBase; | ||
| return "def" | ||
| } | ||
| else { | ||
| state.tokenize = tokenBase; | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| function tokenComment(stream, state) { | ||
| var maybeEnd = false, ch; | ||
| while (ch = stream.next()) { | ||
| if (ch == "/" && maybeEnd) { | ||
| state.tokenize = tokenBase; | ||
| break; | ||
| } | ||
| maybeEnd = (ch == "*"); | ||
| } | ||
| return "comment"; | ||
| } | ||
|
|
||
| function tokenString(quote) { | ||
| return function (stream, state) { | ||
| var escaped = false, next, end = false; | ||
| while ((next = stream.next()) != null) { | ||
| if (next == quote && !escaped) { | ||
| end = true; | ||
| break; | ||
| } | ||
| escaped = !escaped && next == "\\"; | ||
| } | ||
| if (end || !escaped) | ||
| state.tokenize = tokenBase; | ||
| return "string"; | ||
| }; | ||
| } | ||
|
|
||
| function buildElectricInputRegEx() { | ||
| // Reindentation should occur on [] or on a match of any of | ||
| // the block closing keywords, at the end of a line. | ||
| var allClosings = middle.concat(end); | ||
| return new RegExp("[\\[\\]]|(" + allClosings.join("|") + ")$"); | ||
| } | ||
|
|
||
| return { | ||
|
|
||
| startState: function () { | ||
| return { | ||
| tokenize: tokenBase, | ||
| currentIndent: 0, | ||
| doInCurrentLine: false, | ||
| hasPassedFirstStage: false | ||
| }; | ||
| }, | ||
|
|
||
| token: function (stream, state) { | ||
| if (stream.sol()) | ||
| state.doInCurrentLine = 0; | ||
|
|
||
| return state.tokenize(stream, state); | ||
| }, | ||
|
|
||
| indent: function (state, textAfter) { | ||
| var trueText = textAfter.replace(/^\s+|\s+$/g, ''); | ||
|
|
||
| if (trueText.match(endKeywords) || trueText.match(middleKeywords) || trueText.match(/(\[])/)) | ||
| return conf.indentUnit * (state.currentIndent - 1); | ||
|
|
||
| if (state.currentIndent < 0) | ||
| return 0; | ||
|
|
||
| return state.currentIndent * conf.indentUnit; | ||
| }, | ||
| fold: "indent", | ||
| electricInput: buildElectricInputRegEx(), | ||
| lineComment: "%", | ||
| blockCommentStart: "/*", | ||
| blockCommentEnd: "*/" | ||
| }; | ||
| }); | ||
|
|
||
| CodeMirror.defineMIME("text/x-oz", "oz"); | ||
|
|
||
| }); |