Skip to content

Commit

Permalink
Merge pull request #307 from Systems-Modeling/ST6RI-487
Browse files Browse the repository at this point in the history
ST6RI-487 Xtext grammar converter can't handle "use case" keyword
  • Loading branch information
seidewitz authored Dec 11, 2021
2 parents 23ce85a + 9fb59f6 commit 9cd8d36
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 49 deletions.
21 changes: 11 additions & 10 deletions org.omg.sysml.jupyter.jupyterlab/src/main/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ export function defineSysMLv2Mode(): void {
name: 'clike',
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", "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", "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", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
"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", "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", "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", "use", "variant", "variation", "verification",
"verify", "via", "view", "viewpoint", "xor"
].reduce(f_wordify, {}),
defKeywords: [
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",
Expand Down
21 changes: 11 additions & 10 deletions org.omg.sysml.jupyter.kernel/src/main/resources/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ var enableMode = function (CodeMirror) {
name: "clike",
keywords: words([
"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", "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", "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", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
"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", "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", "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", "use", "variant", "variation", "verification",
"verify", "via", "view", "viewpoint", "xor"
]),
defKeywords: words([
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",
Expand Down
2 changes: 1 addition & 1 deletion tool-support/syntax-highlighting/jetbrains/KerML.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<option name="HAS_STRING_ESCAPES" value="true" />
</options>
<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" />
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:=;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
</highlighting>
<extensionMap>
<mapping ext="kerml" />
Expand Down
4 changes: 2 additions & 2 deletions tool-support/syntax-highlighting/jetbrains/SysML.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<option name="HAS_PARENS" value="true" />
<option name="HAS_STRING_ESCAPES" value="true" />
</options>
<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" />
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
<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" />
<keywords2 keywords="!;!=;%;&amp;;&amp;&amp;;*;**;+;-;-&gt;;..;/;:;::;:=;:&gt;;:&gt;&gt;;&lt;;&lt;=;=;==;=&gt;;&gt;;&gt;=;?;??;@;^;^^;|;||;~" />
</highlighting>
<extensionMap>
<mapping ext="sysml" />
Expand Down
21 changes: 11 additions & 10 deletions tool-support/syntax-highlighting/jupyter/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ var enableMode = function (CodeMirror) {
name: "clike",
keywords: words([
"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", "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", "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", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
"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", "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", "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", "use", "variant", "variation", "verification",
"verify", "via", "view", "viewpoint", "xor"
]),
defKeywords: words([
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",
Expand Down
21 changes: 11 additions & 10 deletions tool-support/syntax-highlighting/jupyter/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ export function defineSysMLv2Mode(): void {
name: 'clike',
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", "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", "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", "use", "variant", "variation", "verification", "verify", "via", "view", "viewpoint", "xor"
"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", "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", "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", "use", "variant", "variation", "verification",
"verify", "via", "view", "viewpoint", "xor"
].reduce(f_wordify, {}),
defKeywords: [
"action", "allocation", "analysis", "attribute", "binding", "calc", "case", "comment", "concern",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{ "match": "(%|&|&&|\\?|\\?\\?|\\^|\\^\\^|\\||\\|\\|)", "name": "keyword.operator.logical.kerml" },
{ "match": "(!|!=|\\<|\\<=|=|==|\\>|\\>=)", "name": "keyword.operator.comparison.kerml" },
{ "match": "(\\*|\\*\\*|\\+|\\-|/)", "name": "keyword.operator.arithmetic.kerml" },
{ "match": "(\\-\\>|\\.\\.|:|::|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.kerml" }
{ "match": "(\\-\\>|\\.\\.|:|::|:=|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.kerml" }
]
},
"strings": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"repository": {
"keywords": {
"patterns": [
{ "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" },
{ "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" },
{ "match": "(%|&|&&|\\?|\\?\\?|\\^|\\^\\^|\\||\\|\\|)", "name": "keyword.operator.logical.sysml" },
{ "match": "(!|!=|\\<|\\<=|=|==|\\>|\\>=)", "name": "keyword.operator.comparison.sysml" },
{ "match": "(\\*|\\*\\*|\\+|\\-|/)", "name": "keyword.operator.arithmetic.sysml" },
{ "match": "(\\-\\>|\\.\\.|:|::|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.sysml" }
{ "match": "(\\-\\>|\\.\\.|:|::|:=|:\\>|:\\>\\>|=\\>|@|~)", "name": "keyword.operator.other.sysml" }
]
},
"strings": {
Expand Down
6 changes: 3 additions & 3 deletions tool-support/syntax-highlighting/xtext_grammar_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def parse_xtext_grammar(self, xtext_source_paths: List[str]):
logging.info(f"{var:{max_name_len}s} = {keywords_dict[var]}")
if var.endswith("DefKeyword"):
def_keyword_var = keywords_dict[var][0].split()[0]
def_keyword_value = [x for x in keywords_dict[def_keyword_var] if x.isalpha()][0]
def_keywords_set.add(def_keyword_value)
def_keyword_value = [x for x in keywords_dict[def_keyword_var] if x.replace(" ","").isalpha()][0]
def_keywords_set.add(def_keyword_value.split()[-1])

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

Expand Down

0 comments on commit 9cd8d36

Please sign in to comment.