13
if ( typeof exports == "object" && typeof module == "object")
14
mod(require("../../lib/codemirror"));
15
else if ( typeof define == "function" && define.amd)
16
define(["../../lib/codemirror"], mod);
19
})(function(CodeMirror) {
25
"options" : ["hscale", "width", "arcgradient", "wordwraparcs"],
26
"constants" : ["true", "false", "on", "off"],
27
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
28
"brackets" : ["\\{", "\\}"],
29
"arcsWords" : ["note", "abox", "rbox", "box"],
30
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
31
"singlecomment" : ["//", "#"],
35
"keywords" : ["msc", "xu"],
36
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"],
37
"constants" : ["true", "false", "on", "off", "auto"],
38
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip", "title", "deactivate", "activate", "activation"],
39
"brackets" : ["\\{", "\\}"],
40
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
41
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
42
"singlecomment" : ["//", "#"],
47
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "wordwrapentities", "watermark"],
48
"constants" : ["true", "false", "on", "off", "auto"],
50
"brackets" : ["\\{", "\\}"],
51
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
52
"arcsOthers" : ["\\|\\|\\|", "\\.\\.\\.", "---", "--", "<->", "==", "<<=>>", "<=>", "\\.\\.", "<<>>", "::", "<:>", "->", "=>>", "=>", ">>", ":>", "<-", "<<=", "<=", "<<", "<:", "x-", "-x"],
53
"singlecomment" : ["//", "#"],
58
CodeMirror.defineMode("mscgen", function(_, modeConfig) {
59
var language = languages[modeConfig && modeConfig.language || "mscgen"]
61
startState: startStateFn,
62
copyState: copyStateFn,
63
token: produceTokenFunction(language),
65
blockCommentStart : "/*",
66
blockCommentEnd : "*/"
70
CodeMirror.defineMIME("text/x-mscgen", "mscgen");
71
CodeMirror.defineMIME("text/x-xu", {name: "mscgen", language: "xu"});
72
CodeMirror.defineMIME("text/x-msgenny", {name: "mscgen", language: "msgenny"});
74
function wordRegexpBoundary(pWords) {
75
return new RegExp("^\\b(?:" + pWords.join("|") + ")\\b", "i");
78
function wordRegexp(pWords) {
79
return new RegExp("^(?:" + pWords.join("|") + ")", "i");
82
function startStateFn() {
86
inAttributeList : false,
91
function copyStateFn(pState) {
93
inComment : pState.inComment,
94
inString : pState.inString,
95
inAttributeList : pState.inAttributeList,
96
inScript : pState.inScript
100
function produceTokenFunction(pConfig) {
102
return function(pStream, pState) {
103
if (pStream.match(wordRegexp(pConfig.brackets), true, true)) {
107
if (!pState.inComment) {
108
if (pStream.match(/\/\*[^\*\/]*/, true, true)) {
109
pState.inComment = true;
112
if (pStream.match(wordRegexp(pConfig.singlecomment), true, true)) {
117
if (pState.inComment) {
118
if (pStream.match(/[^\*\/]*\*\//, true, true))
119
pState.inComment = false;
125
if (!pState.inString && pStream.match(/\"(\\\"|[^\"])*/, true, true)) {
126
pState.inString = true;
129
if (pState.inString) {
130
if (pStream.match(/[^\"]*\"/, true, true))
131
pState.inString = false;
137
if (!!pConfig.keywords && pStream.match(wordRegexpBoundary(pConfig.keywords), true, true))
140
if (pStream.match(wordRegexpBoundary(pConfig.options), true, true))
143
if (pStream.match(wordRegexpBoundary(pConfig.arcsWords), true, true))
146
if (pStream.match(wordRegexp(pConfig.arcsOthers), true, true))
149
if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true))
152
if (!!pConfig.constants && pStream.match(wordRegexp(pConfig.constants), true, true))
156
if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match('[', true, true)) {
157
pConfig.inAttributeList = true;
160
if (pConfig.inAttributeList) {
161
if (pConfig.attributes !== null && pStream.match(wordRegexpBoundary(pConfig.attributes), true, true)) {
164
if (pStream.match(']', true, true)) {
165
pConfig.inAttributeList = false;