Skip to content

Commit 9cd8d36

Browse files
authored
Merge pull request #307 from Systems-Modeling/ST6RI-487
ST6RI-487 Xtext grammar converter can't handle "use case" keyword
2 parents 23ce85a + 9fb59f6 commit 9cd8d36

9 files changed

Lines changed: 53 additions & 49 deletions

File tree

org.omg.sysml.jupyter.jupyterlab/src/main/mode.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ export function defineSysMLv2Mode(): void {
3939
name: 'clike',
4040
keywords: [
4141
"about", "abstract", "accept", "action", "actor", "alias", "all", "allocate", "allocation", "analysis",
42-
"and", "as", "assert", "assume", "attribute", "bind", "binding", "by", "calc", "case", "comment",
43-
"concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", "dependency",
44-
"derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", "expose", "feature",
45-
"filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", "implies", "import", "in",
46-
"include", "individual", "inout", "interface", "istype", "item", "join", "language", "merge", "message",
47-
"metadata", "nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package",
48-
"parallel", "part", "perform", "port", "private", "protected", "public", "readonly", "redefines", "ref",
49-
"render", "rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot",
50-
"specializes", "stakeholder", "state", "subject", "subsets", "succession", "then", "timeslice", "to",
51-
"transition", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
42+
"and", "as", "assert", "assign", "assume", "attribute", "bind", "binding", "by", "calc", "case",
43+
"comment", "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined",
44+
"dependency", "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit",
45+
"expose", "feature", "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if",
46+
"implies", "import", "in", "include", "individual", "inout", "interface", "istype", "item", "join",
47+
"language", "merge", "message", "metadata", "nonunique", "not", "objective", "occurrence", "of", "or",
48+
"ordered", "out", "package", "parallel", "part", "perform", "port", "private", "protected", "public",
49+
"readonly", "redefines", "ref", "render", "rendering", "rep", "require", "requirement", "return",
50+
"satisfy", "send", "snapshot", "specializes", "stakeholder", "state", "subject", "subsets",
51+
"succession", "then", "timeslice", "to", "transition", "use", "variant", "variation", "verification",
52+
"verify", "via", "view", "viewpoint", "xor"
5253
].reduce(f_wordify, {}),
5354
defKeywords: [
5455
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",

org.omg.sysml.jupyter.kernel/src/main/resources/kernel/kernel.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ var enableMode = function (CodeMirror) {
5151
name: "clike",
5252
keywords: words([
5353
"about", "abstract", "accept", "action", "actor", "alias", "all", "allocate", "allocation", "analysis",
54-
"and", "as", "assert", "assume", "attribute", "bind", "binding", "by", "calc", "case", "comment",
55-
"concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", "dependency",
56-
"derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", "expose", "feature",
57-
"filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", "implies", "import", "in",
58-
"include", "individual", "inout", "interface", "istype", "item", "join", "language", "merge", "message",
59-
"metadata", "nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package",
60-
"parallel", "part", "perform", "port", "private", "protected", "public", "readonly", "redefines", "ref",
61-
"render", "rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot",
62-
"specializes", "stakeholder", "state", "subject", "subsets", "succession", "then", "timeslice", "to",
63-
"transition", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
54+
"and", "as", "assert", "assign", "assume", "attribute", "bind", "binding", "by", "calc", "case",
55+
"comment", "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined",
56+
"dependency", "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit",
57+
"expose", "feature", "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if",
58+
"implies", "import", "in", "include", "individual", "inout", "interface", "istype", "item", "join",
59+
"language", "merge", "message", "metadata", "nonunique", "not", "objective", "occurrence", "of", "or",
60+
"ordered", "out", "package", "parallel", "part", "perform", "port", "private", "protected", "public",
61+
"readonly", "redefines", "ref", "render", "rendering", "rep", "require", "requirement", "return",
62+
"satisfy", "send", "snapshot", "specializes", "stakeholder", "state", "subject", "subsets",
63+
"succession", "then", "timeslice", "to", "transition", "use", "variant", "variation", "verification",
64+
"verify", "via", "view", "viewpoint", "xor"
6465
]),
6566
defKeywords: words([
6667
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",

tool-support/syntax-highlighting/jetbrains/KerML.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<option name="HAS_STRING_ESCAPES" value="true" />
1313
</options>
1414
<keywords keywords="about;abstract;alias;all;and;as;assoc;behavior;binding;bool;by;class;classifier;comment;composite;conjugate;conjugates;conjugation;connector;datatype;default;derived;disjoining;disjoint;doc;element;else;end;expr;false;feature;featured;featuring;filter;first;flow;for;from;function;hastype;if;implies;import;in;inout;interaction;inv;is;istype;language;member;metadata;multiplicity;namespace;nonunique;not;null;of;or;ordered;out;package;portion;predicate;private;protected;public;readonly;redefines;redefinition;relationship;rep;specialization;specializes;step;struct;subclassifier;subset;subsets;subtype;succession;then;to;true;type;typed;typing;xor" ignore_case="false" />
15-
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
15+
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:=;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
1616
</highlighting>
1717
<extensionMap>
1818
<mapping ext="kerml" />

tool-support/syntax-highlighting/jetbrains/SysML.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<option name="HAS_PARENS" value="true" />
1212
<option name="HAS_STRING_ESCAPES" value="true" />
1313
</options>
14-
<keywords keywords="about;abstract;accept;action;actor;alias;all;allocate;allocation;analysis;and;as;assert;assume;attribute;bind;binding;by;calc;case;comment;concern;connect;connection;constraint;decide;def;default;defined;dependency;derived;do;doc;else;end;entry;enum;event;exhibit;exit;expose;false;feature;filter;first;flow;for;fork;frame;from;hastype;if;implies;import;in;include;individual;inout;interface;istype;item;join;language;merge;message;metadata;nonunique;not;null;objective;occurrence;of;or;ordered;out;package;parallel;part;perform;port;private;protected;public;readonly;redefines;ref;render;rendering;rep;require;requirement;return;satisfy;send;snapshot;specializes;stakeholder;state;subject;subsets;succession;then;timeslice;to;transition;true;use;variant;variation;verification;verify;via;view;viewpoint;xor" ignore_case="false" />
15-
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
14+
<keywords keywords="about;abstract;accept;action;actor;alias;all;allocate;allocation;analysis;and;as;assert;assign;assume;attribute;bind;binding;by;calc;case;comment;concern;connect;connection;constraint;decide;def;default;defined;dependency;derived;do;doc;else;end;entry;enum;event;exhibit;exit;expose;false;feature;filter;first;flow;for;fork;frame;from;hastype;if;implies;import;in;include;individual;inout;interface;istype;item;join;language;merge;message;metadata;nonunique;not;null;objective;occurrence;of;or;ordered;out;package;parallel;part;perform;port;private;protected;public;readonly;redefines;ref;render;rendering;rep;require;requirement;return;satisfy;send;snapshot;specializes;stakeholder;state;subject;subsets;succession;then;timeslice;to;transition;true;use;variant;variation;verification;verify;via;view;viewpoint;xor" ignore_case="false" />
15+
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:=;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
1616
</highlighting>
1717
<extensionMap>
1818
<mapping ext="sysml" />

tool-support/syntax-highlighting/jupyter/kernel.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ var enableMode = function (CodeMirror) {
5151
name: "clike",
5252
keywords: words([
5353
"about", "abstract", "accept", "action", "actor", "alias", "all", "allocate", "allocation", "analysis",
54-
"and", "as", "assert", "assume", "attribute", "bind", "binding", "by", "calc", "case", "comment",
55-
"concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", "dependency",
56-
"derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", "expose", "feature",
57-
"filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", "implies", "import", "in",
58-
"include", "individual", "inout", "interface", "istype", "item", "join", "language", "merge", "message",
59-
"metadata", "nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package",
60-
"parallel", "part", "perform", "port", "private", "protected", "public", "readonly", "redefines", "ref",
61-
"render", "rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot",
62-
"specializes", "stakeholder", "state", "subject", "subsets", "succession", "then", "timeslice", "to",
63-
"transition", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
54+
"and", "as", "assert", "assign", "assume", "attribute", "bind", "binding", "by", "calc", "case",
55+
"comment", "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined",
56+
"dependency", "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit",
57+
"expose", "feature", "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if",
58+
"implies", "import", "in", "include", "individual", "inout", "interface", "istype", "item", "join",
59+
"language", "merge", "message", "metadata", "nonunique", "not", "objective", "occurrence", "of", "or",
60+
"ordered", "out", "package", "parallel", "part", "perform", "port", "private", "protected", "public",
61+
"readonly", "redefines", "ref", "render", "rendering", "rep", "require", "requirement", "return",
62+
"satisfy", "send", "snapshot", "specializes", "stakeholder", "state", "subject", "subsets",
63+
"succession", "then", "timeslice", "to", "transition", "use", "variant", "variation", "verification",
64+
"verify", "via", "view", "viewpoint", "xor"
6465
]),
6566
defKeywords: words([
6667
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",

tool-support/syntax-highlighting/jupyter/mode.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ export function defineSysMLv2Mode(): void {
3939
name: 'clike',
4040
keywords: [
4141
"about", "abstract", "accept", "action", "actor", "alias", "all", "allocate", "allocation", "analysis",
42-
"and", "as", "assert", "assume", "attribute", "bind", "binding", "by", "calc", "case", "comment",
43-
"concern", "connect", "connection", "constraint", "decide", "def", "default", "defined", "dependency",
44-
"derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit", "expose", "feature",
45-
"filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if", "implies", "import", "in",
46-
"include", "individual", "inout", "interface", "istype", "item", "join", "language", "merge", "message",
47-
"metadata", "nonunique", "not", "objective", "occurrence", "of", "or", "ordered", "out", "package",
48-
"parallel", "part", "perform", "port", "private", "protected", "public", "readonly", "redefines", "ref",
49-
"render", "rendering", "rep", "require", "requirement", "return", "satisfy", "send", "snapshot",
50-
"specializes", "stakeholder", "state", "subject", "subsets", "succession", "then", "timeslice", "to",
51-
"transition", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
42+
"and", "as", "assert", "assign", "assume", "attribute", "bind", "binding", "by", "calc", "case",
43+
"comment", "concern", "connect", "connection", "constraint", "decide", "def", "default", "defined",
44+
"dependency", "derived", "do", "doc", "else", "end", "entry", "enum", "event", "exhibit", "exit",
45+
"expose", "feature", "filter", "first", "flow", "for", "fork", "frame", "from", "hastype", "if",
46+
"implies", "import", "in", "include", "individual", "inout", "interface", "istype", "item", "join",
47+
"language", "merge", "message", "metadata", "nonunique", "not", "objective", "occurrence", "of", "or",
48+
"ordered", "out", "package", "parallel", "part", "perform", "port", "private", "protected", "public",
49+
"readonly", "redefines", "ref", "render", "rendering", "rep", "require", "requirement", "return",
50+
"satisfy", "send", "snapshot", "specializes", "stakeholder", "state", "subject", "subsets",
51+
"succession", "then", "timeslice", "to", "transition", "use", "variant", "variation", "verification",
52+
"verify", "via", "view", "viewpoint", "xor"
5253
].reduce(f_wordify, {}),
5354
defKeywords: [
5455
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",

tool-support/syntax-highlighting/vscode/kerml/syntaxes/kerml.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
{ "match": "(%|&|&&|\\?|\\?\\?|\\^|\\^\\^|\\||\\|\\|)", "name": "keyword.operator.logical.kerml" },
2323
{ "match": "(!|!=|\\<|\\<=|=|==|\\>|\\>=)", "name": "keyword.operator.comparison.kerml" },
2424
{ "match": "(\\*|\\*\\*|\\+|\\-|/)", "name": "keyword.operator.arithmetic.kerml" },
25-
{ "match": "(\\-\\>|\\.\\.|:|::|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.kerml" }
25+
{ "match": "(\\-\\>|\\.\\.|:|::|:=|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.kerml" }
2626
]
2727
},
2828
"strings": {

tool-support/syntax-highlighting/vscode/sysml/syntaxes/sysml.tmLanguage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"repository": {
1919
"keywords": {
2020
"patterns": [
21-
{ "match": "\\b(about|abstract|accept|action|actor|alias|all|allocate|allocation|analysis|and|as|assert|assume|attribute|bind|binding|by|calc|case|comment|concern|connect|connection|constraint|decide|def|default|defined|dependency|derived|do|doc|else|end|entry|enum|event|exhibit|exit|expose|false|feature|filter|first|flow|for|fork|frame|from|hastype|if|implies|import|in|include|individual|inout|interface|istype|item|join|language|merge|message|metadata|nonunique|not|null|objective|occurrence|of|or|ordered|out|package|parallel|part|perform|port|private|protected|public|readonly|redefines|ref|render|rendering|rep|require|requirement|return|satisfy|send|snapshot|specializes|stakeholder|state|subject|subsets|succession|then|timeslice|to|transition|true|use|variant|variation|verification|verify|via|view|viewpoint|xor)\\b", "name": "keyword.other.sysml" },
21+
{ "match": "\\b(about|abstract|accept|action|actor|alias|all|allocate|allocation|analysis|and|as|assert|assign|assume|attribute|bind|binding|by|calc|case|comment|concern|connect|connection|constraint|decide|def|default|defined|dependency|derived|do|doc|else|end|entry|enum|event|exhibit|exit|expose|false|feature|filter|first|flow|for|fork|frame|from|hastype|if|implies|import|in|include|individual|inout|interface|istype|item|join|language|merge|message|metadata|nonunique|not|null|objective|occurrence|of|or|ordered|out|package|parallel|part|perform|port|private|protected|public|readonly|redefines|ref|render|rendering|rep|require|requirement|return|satisfy|send|snapshot|specializes|stakeholder|state|subject|subsets|succession|then|timeslice|to|transition|true|use|variant|variation|verification|verify|via|view|viewpoint|xor)\\b", "name": "keyword.other.sysml" },
2222
{ "match": "(%|&|&&|\\?|\\?\\?|\\^|\\^\\^|\\||\\|\\|)", "name": "keyword.operator.logical.sysml" },
2323
{ "match": "(!|!=|\\<|\\<=|=|==|\\>|\\>=)", "name": "keyword.operator.comparison.sysml" },
2424
{ "match": "(\\*|\\*\\*|\\+|\\-|/)", "name": "keyword.operator.arithmetic.sysml" },
25-
{ "match": "(\\-\\>|\\.\\.|:|::|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.sysml" }
25+
{ "match": "(\\-\\>|\\.\\.|:|::|:=|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.sysml" }
2626
]
2727
},
2828
"strings": {

tool-support/syntax-highlighting/xtext_grammar_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ def parse_xtext_grammar(self, xtext_source_paths: List[str]):
255255
logging.info(f"{var:{max_name_len}s} = {keywords_dict[var]}")
256256
if var.endswith("DefKeyword"):
257257
def_keyword_var = keywords_dict[var][0].split()[0]
258-
def_keyword_value = [x for x in keywords_dict[def_keyword_var] if x.isalpha()][0]
259-
def_keywords_set.add(def_keyword_value)
258+
def_keyword_value = [x for x in keywords_dict[def_keyword_var] if x.replace(" ","").isalpha()][0]
259+
def_keywords_set.add(def_keyword_value.split()[-1])
260260

261261
# Remove interpunction terminals that should not be highlighted
262262
operators_set.remove(".")
@@ -353,7 +353,7 @@ def export_jupyter_syntax_highlighting_files(
353353
def_keywords_set.update(additional_def_keywords)
354354
self.def_keywords = sorted(def_keywords_set)
355355
for def_keyword in self.def_keywords:
356-
if def_keyword not in keywords_minus_atoms:
356+
if any([x not in keywords_minus_atoms for x in def_keyword.split()]):
357357
logging.error(f"def keyword '{def_keyword}' "
358358
f"is not in the list of keywords obtained from the xtext grammar")
359359

0 commit comments

Comments
 (0)