Skip to content

Commit c4d9363

Browse files
sverweijmarijnh
authored andcommitted
[mscgen mode] adds support for language constants
and adds the xù specific keyword 'xu'
1 parent 7b00c30 commit c4d9363

File tree

5 files changed

+38
-8
lines changed

5 files changed

+38
-8
lines changed

mode/mscgen/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ <h2>Xù mode</h2>
5959
# Xù - expansions to MscGen to support inline expressions
6060
# https://github.com/sverweij/mscgen_js/blob/master/wikum/xu.md
6161
# More samples: https://sverweij.github.io/mscgen_js
62-
msc {
62+
xu {
6363
hscale="0.8",
6464
width="700";
6565

mode/mscgen/mscgen.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
mscgen: {
2424
"keywords" : ["msc"],
2525
"options" : ["hscale", "width", "arcgradient", "wordwraparcs"],
26+
"constants" : ["true", "false", "on", "off"],
2627
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
2728
"brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
2829
"arcsWords" : ["note", "abox", "rbox", "box"],
@@ -31,8 +32,9 @@
3132
"operators" : ["="]
3233
},
3334
xu: {
34-
"keywords" : ["msc"],
35+
"keywords" : ["msc", "xu"],
3536
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
37+
"constants" : ["true", "false", "on", "off", "auto"],
3638
"attributes" : ["label", "idurl", "id", "url", "linecolor", "linecolour", "textcolor", "textcolour", "textbgcolor", "textbgcolour", "arclinecolor", "arclinecolour", "arctextcolor", "arctextcolour", "arctextbgcolor", "arctextbgcolour", "arcskip"],
3739
"brackets" : ["\\{", "\\}"], // [ and ] are brackets too, but these get handled in with lists
3840
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
@@ -43,6 +45,7 @@
4345
msgenny: {
4446
"keywords" : null,
4547
"options" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark"],
48+
"constants" : ["true", "false", "on", "off", "auto"],
4649
"attributes" : null,
4750
"brackets" : ["\\{", "\\}"],
4851
"arcsWords" : ["note", "abox", "rbox", "box", "alt", "else", "opt", "break", "par", "seq", "strict", "neg", "critical", "ignore", "consider", "assert", "loop", "ref", "exc"],
@@ -146,6 +149,9 @@
146149
if (!!pConfig.operators && pStream.match(wordRegexp(pConfig.operators), true, true))
147150
return "operator";
148151

152+
if (!!pConfig.constants && pStream.match(wordRegexp(pConfig.constants), true, true))
153+
return "variable";
154+
149155
/* attribute lists */
150156
if (!pConfig.inAttributeList && !!pConfig.attributes && pStream.match(/\[/, true, true)) {
151157
pConfig.inAttributeList = true;

mode/mscgen/mscgen_test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
"[base alt loop opt ref else break par seq assert]"
3030
);
3131

32+
MT("xù/ msgenny constants classify as 'base'",
33+
"[base auto]"
34+
);
35+
36+
MT("mscgen constants classify as 'variable'",
37+
"[variable true]", "[variable false]", "[variable on]", "[variable off]"
38+
);
39+
3240
MT("mscgen options classify as keyword",
3341
"[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
3442
);
@@ -63,7 +71,7 @@
6371
MT("a typical program",
6472
"[comment # typical mscgen program]",
6573
"[keyword msc][base ][bracket {]",
66-
"[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
74+
"[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
6775
"[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
6876
"[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
6977
"[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",

mode/mscgen/msgenny_test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
2424
);
2525

26+
MT("xù/ msgenny constants classify as 'variable'",
27+
"[variable auto]",
28+
"[variable true]", "[variable false]", "[variable on]", "[variable off]"
29+
);
30+
2631
MT("mscgen options classify as keyword",
2732
"[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
2833
);
@@ -56,7 +61,7 @@
5661

5762
MT("a typical program",
5863
"[comment # typical msgenny program]",
59-
"[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
64+
"[keyword wordwraparcs][operator =][variable true][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30;]",
6065
"[base a : ][string \"Entity A\"][base ,]",
6166
"[base b : Entity B,]",
6267
"[base c : Entity C;]",

mode/mscgen/xu_test.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
"[keyword msc][bracket {]",
1010
"[base ]",
1111
"[bracket }]"
12-
);
12+
);
13+
14+
MT("empty chart",
15+
"[keyword xu][bracket {]",
16+
"[base ]",
17+
"[bracket }]"
18+
);
1319

1420
MT("comments",
1521
"[comment // a single line comment]",
@@ -29,6 +35,11 @@
2935
"[keyword alt]","[keyword loop]","[keyword opt]","[keyword ref]","[keyword else]","[keyword break]","[keyword par]","[keyword seq]","[keyword assert]"
3036
);
3137

38+
MT("xù/ msgenny constants classify as 'variable'",
39+
"[variable auto]",
40+
"[variable true]", "[variable false]", "[variable on]", "[variable off]"
41+
);
42+
3243
MT("mscgen options classify as keyword",
3344
"[keyword hscale]", "[keyword width]", "[keyword arcgradient]", "[keyword wordwraparcs]"
3445
);
@@ -61,9 +72,9 @@
6172
);
6273

6374
MT("a typical program",
64-
"[comment # typical mscgen program]",
65-
"[keyword msc][base ][bracket {]",
66-
"[keyword wordwraparcs][operator =][string \"true\"][keyword hscale][operator =][string \"0.8\"][keyword arcgradient][operator =][base 30;]",
75+
"[comment # typical xu program]",
76+
"[keyword xu][base ][bracket {]",
77+
"[keyword wordwraparcs][operator =][string \"true\"][base , ][keyword hscale][operator =][string \"0.8\"][base , ][keyword arcgradient][operator =][base 30, ][keyword width][operator =][variable auto][base ;]",
6778
"[base a][bracket [[][attribute label][operator =][string \"Entity A\"][bracket ]]][base ,]",
6879
"[base b][bracket [[][attribute label][operator =][string \"Entity B\"][bracket ]]][base ,]",
6980
"[base c][bracket [[][attribute label][operator =][string \"Entity C\"][bracket ]]][base ;]",

0 commit comments

Comments
 (0)