Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(codemirror): colour Mermaid requirement keys and names
Elian Doran04df74109331
diff --git a/packages/codemirror/src/languages/mermaid/mermaid.spec.ts b/packages/codemirror/src/languages/mermaid/mermaid.spec.tsindex d698069680..02d73d4992 100644--- a/packages/codemirror/src/languages/mermaid/mermaid.spec.ts+++ b/packages/codemirror/src/languages/mermaid/mermaid.spec.ts@@ -179,6 +179,26 @@ describe("shape metadata", () => {});});+describe("requirement highlighting", () => {+ it("colours names, keys and values apart", () => {+ const doc = [+ "requirementDiagram", " requirement test_req {", " id: 1",+ " text: the test text.", " risk: high", " }", " element \"test entity\" {",+ " type: simulation", " }", " test_entity - satisfies -> test_req"+ ].join("\n");+ const diagramKeywords = /^(requirementDiagram|requirement|element|-|->) /;+ expect(styles(doc).filter((style) => !diagramKeywords.test(style))).toEqual([+ "test_req tok-variableName", "{ tok-punctuation", "id tok-propertyName",+ ": tok-punctuation", "1 tok-number", "text tok-propertyName", ": tok-punctuation",+ "the test text. tok-string", "risk tok-propertyName", ": tok-punctuation",+ "high tok-keyword", "} tok-punctuation", "\"test entity\" tok-variableName",+ "{ tok-punctuation", "type tok-propertyName", ": tok-punctuation",+ "simulation tok-string", "} tok-punctuation", "test_entity tok-variableName",+ "satisfies tok-keyword", "test_req tok-variableName"+ ]);+ });+});+describe("mindmap highlighting", () => {it("colours each node by its level, and ids, shapes, icons and classes apart", () => {const doc = [diff --git a/packages/codemirror/src/languages/mermaid/parsers/requirement/highlight.ts b/packages/codemirror/src/languages/mermaid/parsers/requirement/highlight.tsindex 9a97b1e5b1..6c9ada8bd9 100644--- a/packages/codemirror/src/languages/mermaid/parsers/requirement/highlight.ts+++ b/packages/codemirror/src/languages/mermaid/parsers/requirement/highlight.ts@@ -1,13 +1,15 @@-import { styleTags } from "@lezer/highlight";+import { styleTags, tags as t } from "@lezer/highlight";import { requirementTags } from "../../tags/index.js";export const requirementHighlighting = styleTags({+ "{ }": t.brace,+ ":": t.punctuation,"DiagramName SubDiagramType": requirementTags.diagramName,"LineComment": requirementTags.lineComment,"IDNumber": requirementTags.number,- "UnquotedString RelationshipStart": requirementTags.unquotedString,- "QuotedString": requirementTags.quotedString,- "PropKeyword": requirementTags.unquotedString,+ "UnquotedString QuotedString": requirementTags.string,+ "Name/UnquotedString Name/QuotedString RelationshipStart": requirementTags.name,+ "PropKeyword": requirementTags.property,"Keyword": requirementTags.keyword,"ForwardArrow BackArrow Hyphen": requirementTags.arrow});diff --git a/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.terms.ts b/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.terms.tsindex 1f2375192c..137ad187f0 100644--- a/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.terms.ts+++ b/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.terms.ts@@ -6,21 +6,22 @@ export constRequirementDiagram = 3,DiagramName = 4,SubDiagramType = 5,- UnquotedString = 6,- QuotedString = 7,- ID = 8,- PropKeyword = 44,- IDNumber = 12,- Text = 13,- Risk = 16,- RiskType = 19,- Keyword = 61,- VerifyMethod = 26,- VerifyMethodType = 30,- Type = 39,- DocRef = 42,- RelationshipLine = 45,- Hyphen = 46,- RelationshipType = 47,- ForwardArrow = 62,- BackArrow = 63+ Name = 6,+ UnquotedString = 7,+ QuotedString = 8,+ ID = 11,+ PropKeyword = 48,+ IDNumber = 16,+ Text = 17,+ Risk = 20,+ RiskType = 23,+ Keyword = 65,+ VerifyMethod = 30,+ VerifyMethodType = 34,+ Type = 43,+ DocRef = 46,+ RelationshipLine = 49,+ Hyphen = 50,+ RelationshipType = 51,+ ForwardArrow = 66,+ BackArrow = 67diff --git a/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.ts b/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.tsindex fffcf4f26a..77bf78733d 100644--- a/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.ts+++ b/packages/codemirror/src/languages/mermaid/parsers/requirement/parser.ts@@ -3,20 +3,20 @@import {LRParser} from "@lezer/lr"import {relationshipStart} from "./tokens.js"import {requirementHighlighting} from "./highlight.js"-const spec_word = {__proto__:null,requirementDiagram:144, requirement:150, Requirement:152, functionalRequirement:154, FunctionalRequirement:156, performanceRequirement:158, PerformanceRequirement:160, interfaceRequirement:162, InterfaceRequirement:164, physicalRequirement:166, PhysicalRequirement:168, designConstraint:170, DesignConstraint:172, element:174, Element:176, id:18, Id:20, ID:22, text:28, Text:30, risk:34, Risk:36, low:40, Low:42, medium:44, Medium:46, high:48, High:50, verifymethod:54, verifyMethod:56, VerifyMethod:58, analysis:62, Analysis:64, demonstration:66, Demonstration:68, inspection:70, Inspection:72, test:74, Test:76, type:80, Type:82, docRef:86, DocRef:88, contains:96, Contains:98, copies:100, Copies:102, derives:104, Derives:106, satisfies:108, Satisfies:110, verifies:112, Verifies:114, refines:116, Refines:118, traces:120, Traces:122}+const spec_word = {__proto__:null,requirementDiagram:152, requirement:158, Requirement:160, functionalRequirement:162, FunctionalRequirement:164, performanceRequirement:166, PerformanceRequirement:168, interfaceRequirement:170, InterfaceRequirement:172, physicalRequirement:174, PhysicalRequirement:176, designConstraint:178, DesignConstraint:180, element:182, Element:184, id:24, Id:26, ID:28, text:36, Text:38, risk:42, Risk:44, low:48, Low:50, medium:52, Medium:54, high:56, High:58, verifymethod:62, verifyMethod:64, VerifyMethod:66, analysis:70, Analysis:72, demonstration:74, Demonstration:76, inspection:78, Inspection:80, test:82, Test:84, type:88, Type:90, docRef:94, DocRef:96, contains:104, Contains:106, copies:108, Copies:110, derives:112, Derives:114, satisfies:116, Satisfies:118, verifies:120, Verifies:122, refines:124, Refines:126, traces:128, Traces:130}export const parser = LRParser.deserialize({version: 14,- states: ")`OYQQOOO_QQO'#DtQOQQOOOOQO'#C`'#C`O!kQRO,5:`O!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zO~O#P!OO~P&XO#S!PO~O#S!QO~O#S!RO~O!k!SOX#QXY#QXZ#QX^#QX_#QXa#QXb#QXk#QXl#QXm#QXx#QXy#QX{#QX|#QX#P#QX~O#P!UO~P&XO#S!VO~O#S!WO~O#S!XO~O[!YO~Od![Oe![Of![Og![Oh![Oi![O~Oo!^Op!^Oq!^Or!^Os!^Ot!^Ou!^Ov!^O~O!k!a!g!`!O~",- goto: "%r#[PPPP#]#`#d#k#vPPPP#zPP$OPP$SPPPPPP$VPPP$ZPPPPPPPP$^PP$bPP$fP$jPPPPPPPPPPPPPPPP$p$v$|PPP%SPPP$fPPPPPPPPPPPPPPPPPPP%V%ZP%Z%Z%Z%Z%Z%_%cRPOTZSXZdZl!V!W!XSUSXZdZl!V!W!XTomtT{mtTpmtR!Z!QTqmtR!]!RT|mtT}mtTWSXQh_Rj`QXSRbXQ]TRf]QtmR!TtRQOTsmtTrmtTVSXQeZQnlQ!_!VQ!`!WR!a!X",- nodeNames: "⚠ RelationshipStart LineComment RequirementDiagram DiagramName SubDiagramType UnquotedString QuotedString ID PropKeyword PropKeyword PropKeyword IDNumber Text PropKeyword PropKeyword Risk PropKeyword PropKeyword RiskType Keyword Keyword Keyword Keyword Keyword Keyword VerifyMethod PropKeyword PropKeyword PropKeyword VerifyMethodType Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Type PropKeyword PropKeyword DocRef PropKeyword PropKeyword RelationshipLine Hyphen RelationshipType Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword ForwardArrow BackArrow",- maxTerm: 103,+ states: ")fOYQQOOO_QQO'#DxQOQQOOOOQO'#C`'#C`O!kQRO,5:dO!rOSO'#CdO!zQWO'#D|OOQO'#Eh'#EhO#SQQO'#D_O#[QRO'#DrO$fQRO1G0OOOQO'#Ca'#CaOOOO'#Ds'#DsO$mOSO,59OOOQP,59O,59OOOQP'#Cc'#CcOOQP'#Cb'#CbO$uQQO,5:hO$zQ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`!YO~Oh!^Oi!^Oj!^Ok!^Ol!^Om!^O~Os!`Ot!`Ou!`Ov!`Ow!`Ox!`Oy!`Oz!`O~O!o!e!k!d!S~",+ goto: "%w#]PPPP#^#a#e#k#tPP$RPPPPP$VPP$ZPP$_PPPPPP$bPPP$fPPPPPPPP$iPP$mPP$qP$uPPPPPPPPPPPPPPPP${%R%XPPP%_PPP$qPPPPPPPPPPPPPPPPP%b%f%f%j%f%f%f%f%sRPOTUSYQaUR!OmS`UmV!Z!Q!T!USVSYS`UmV!Z!Q!T!UTnlvTolvTplvR!]!RTqlvR!_!STrlvTslvTXSYQibRkcQYSReYQ]TRf]QvlR!WvRQOTulvTtlvQ![!QQ!a!TR!b!UTWSY",+ nodeNames: "⚠ RelationshipStart LineComment RequirementDiagram DiagramName SubDiagramType Name UnquotedString QuotedString { } ID PropKeyword PropKeyword PropKeyword : IDNumber Text PropKeyword PropKeyword Risk PropKeyword PropKeyword RiskType Keyword Keyword Keyword Keyword Keyword Keyword VerifyMethod PropKeyword PropKeyword PropKeyword VerifyMethodType Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Type PropKeyword PropKeyword DocRef PropKeyword PropKeyword RelationshipLine Hyphen RelationshipType Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword ForwardArrow BackArrow",+ maxTerm: 104,propSources: [requirementHighlighting],skippedNodes: [0,2],repeatNodeCount: 3,- tokenData: "1g~R{OX#xXY$aYZ&SZ^$a^p#xpq$aqr#xrs'}su#xuv(Sv}#x}!O)v!O!Q#x!Q![*t![!]+|!]!^#x!^!_,a!_!c#x!c!}-]!}#T#x#T#o-]#o#p0o#p#q#x#q#r1S#r#y#x#y#z$a#z$f#x$f$g$a$g#BY#x#BY#BZ$a#BZ$IS#x$IS$I_$a$I_$I|#x$I|$JO$a$JO$JT#x$JT$JU$a$JU$KV#x$KV$KW$a$KW&FU#x&FU&FV$a&FV;'S#x;'S;=`$Z<%lO#xQ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Or#xs!`#x!`!a*a!a;'S#x;'S;=`$Z<%lO#xR*hS#RQ!dPOr#xs;'S#x;'S;=`$Z<%lO#xR*{W`P#RQOr#xs!O#x!O!P+e!P!Q#x!Q![*t![;'S#x;'S;=`$Z<%lO#xR+jU#RQOr#xs!Q#x!Q![*t![;'S#x;'S;=`$Z<%lO#xR,TS_P#RQOr#xs;'S#x;'S;=`$Z<%lO#xR,fU#RQOr#xs}#x}!O,x!O;'S#x;'S;=`$Z<%lO#xR-PS#RQ!ePOr#xs;'S#x;'S;=`$Z<%lO#xV-fe#RQ#PS!mPOX.wXY0WYZ#xZ].w]^#x^p.wpq0Wqr.wrs1es}.w}!O#x!O!^.w!^!a#x!a!c.w!c!}-]!}#T.w#T#o-]#o#p#x#p;'S.w;'S;=`3X<%lO.wU/Ob#RQ#PSOX.wXY0WYZ#xZ].w]^#x^p.wpq0Wqr.wrs1es}.w}!O#x!O!^.w!^!a#x!a#o.w#o#p#x#p;'S.w;'S;=`3X<%lO.wU0]b#RQOX.wXY0WYZ#xZ].w]^#x^p.wpq0Wqr.wrs1es}.w}!O#x!O!^.w!^!a#x!a#o.w#o#p#x#p;'S.w;'S;=`3X<%lO.wS1jZ#PSOX1eXY2]Z]1e^p1epq2]q}1e!O!^1e!a#o1e#p;'S1e;'S;=`3R<%lO1eS2`ZOX1eXY2]Z]1e^p1epq2]q}1e!O!^1e!a#o1e#p;'S1e;'S;=`3R<%lO1eS3UP;=`<%l1eU3[P;=`<%l.wR3fSXP#RQOr#xs;'S#x;'S;=`$Z<%lO#xR3ySYP#RQOr#xs;'S#x;'S;=`$Z<%lO#x",tokenizers: [relationshipStart, 0, 1, 2],topRules: {"RequirementDiagram":[0,3]},- specialized: [{term: 71, get: (value: keyof typeof spec_word) => spec_word[value] || -1}],+ specialized: [{term: 75, get: (value: keyof typeof spec_word) => spec_word[value] || -1}],tokenPrec: 428})diff --git a/packages/codemirror/src/languages/mermaid/parsers/requirement/requirement.grammar b/packages/codemirror/src/languages/mermaid/parsers/requirement/requirement.grammarindex ed6184a6d1..28abdd2d74 100644--- a/packages/codemirror/src/languages/mermaid/parsers/requirement/requirement.grammar+++ b/packages/codemirror/src/languages/mermaid/parsers/requirement/requirement.grammar@@ -18,11 +18,11 @@ document {}subDiagram {- SubDiagramType subDiagramName "{" newlines "}" |- SubDiagramType subDiagramName "{" newlines subDiagramLine+ "}"+ SubDiagramType Name "{" newlines "}" |+ SubDiagramType Name "{" newlines subDiagramLine+ "}"}-subDiagramName {+Name {UnquotedString | QuotedString}@@ -66,18 +66,14 @@ textContent {}RelationshipLine {- relationshipStart Hyphen RelationshipType ForwardArrow relationshipEnd |- relationshipStart BackArrow RelationshipType Hyphen relationshipEnd+ relationshipStart Hyphen RelationshipType ForwardArrow Name |+ relationshipStart BackArrow RelationshipType Hyphen Name}relationshipStart {RelationshipStart | QuotedString}-relationshipEnd {- UnquotedString | QuotedString-}-DiagramName { diagramKw<"requirementDiagram"> }SubDiagramType {@@ -136,12 +132,13 @@ kw<term> { @specialize[@name=Keyword]<word, term> }spaces { @whitespace+ }newlines { $[\n]+ }LineComment { "%%" ![\n]* }- unquotedString { word ![\r\n\{\<\>\-\=]* }+ unquotedString { word ($[ \t]* ![ \t\r\n\{\<\>\-\=])* }IDNumber { @digit+ ("." @digit+)* }stringContent { !["]+ }ForwardArrow { "->"}BackArrow { "<-"}Hyphen { "-" }+ "{" "}" ":"@precedence { newlines, spaces }@precedence { ForwardArrow, Hyphen }diff --git a/packages/codemirror/src/languages/mermaid/tags/index.ts b/packages/codemirror/src/languages/mermaid/tags/index.tsindex 323e595e87..ad184e760b 100644--- a/packages/codemirror/src/languages/mermaid/tags/index.ts+++ b/packages/codemirror/src/languages/mermaid/tags/index.ts@@ -77,9 +77,10 @@ export const requirementTags = {arrow: Tag.define(t.contentSeparator),keyword: Tag.define(t.keyword),lineComment: Tag.define(t.lineComment),+ name: Tag.define(t.variableName),number: Tag.define(t.number),- quotedString: Tag.define(t.string),- unquotedString: Tag.define(t.content)+ property: Tag.define(t.propertyName),+ string: Tag.define(t.string)};export const ganttTags = {diff --git a/packages/codemirror/src/languages/mermaid/test/requirement.txt b/packages/codemirror/src/languages/mermaid/test/requirement.txtindex 5218194949..eae190f259 100644--- a/packages/codemirror/src/languages/mermaid/test/requirement.txt+++ b/packages/codemirror/src/languages/mermaid/test/requirement.txt@@ -24,7 +24,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString))# Requirement Section with Quoted String@@ -36,7 +36,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,QuotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(QuotedString))# Requirement Section - IDNumber with zero decimals@@ -48,7 +48,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber)# Requirement Section - IDNumber with one decimal@@ -60,7 +60,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber)# Requirement Section - IDNumber with two decimals@@ -72,7 +72,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber)# Requirement Section - IDNumber with multidigit numbers and decimals@@ -84,7 +84,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber)# Requirement Section - Text@@ -96,7 +96,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,Text(PropKeyword),UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),Text(PropKeyword),UnquotedString)# Requirement Section - Risk@@ -108,7 +108,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,Risk(PropKeyword),RiskType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),Risk(PropKeyword),RiskType(Keyword))# Requirement Section - ID + Text@@ -121,7 +121,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString)# Requirement Section - All fields@@ -136,7 +136,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))# functionalRequirement Section - All fields@@ -151,7 +151,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))# performanceRequirement Section - All fields@@ -166,7 +166,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))# interfaceRequirement Section - All fields@@ -181,7 +181,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))# physicalRequirement Section - All fields@@ -196,7 +196,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))# designConstraint Section - All fields@@ -211,7 +211,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword))# Element Line with Unquoted String - Type@@ -223,7 +223,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,Type(PropKeyword),UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),Type(PropKeyword),UnquotedString)# Element Line with Unquoted String - All fields@@ -236,7 +236,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,Type(PropKeyword),UnquotedString,DocRef(PropKeyword),UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),Type(PropKeyword),UnquotedString,DocRef(PropKeyword),UnquotedString)# Element Line with Quoted String - All fields@@ -249,7 +249,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,Type(PropKeyword),QuotedString,DocRef(PropKeyword),UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),Type(PropKeyword),QuotedString,DocRef(PropKeyword),UnquotedString)# Relationship Line with Forward Arrow@@ -258,7 +258,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString))+RequirementDiagram(DiagramName,RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)))# Relationship Line with Back Arrow@@ -267,7 +267,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,RelationshipLine(RelationshipStart,BackArrow,RelationshipType(Keyword),Hyphen,UnquotedString))+RequirementDiagram(DiagramName,RelationshipLine(RelationshipStart,BackArrow,RelationshipType(Keyword),Hyphen,Name(UnquotedString)))# All SubDiagram Types@@ -331,7 +331,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,Type(PropKeyword),UnquotedString,SubDiagramType,UnquotedString,Type(PropKeyword),UnquotedString,DocRef(PropKeyword),UnquotedString,SubDiagramType,UnquotedString,Type(PropKeyword),QuotedString,DocRef(PropKeyword),UnquotedString)+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),Type(PropKeyword),UnquotedString,SubDiagramType,Name(UnquotedString),Type(PropKeyword),UnquotedString,DocRef(PropKeyword),UnquotedString,SubDiagramType,Name(UnquotedString),Type(PropKeyword),QuotedString,DocRef(PropKeyword),UnquotedString)# All Features@@ -405,7 +405,7 @@ requirementDiagram==>-RequirementDiagram(DiagramName,SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,UnquotedString,Type(PropKeyword),UnquotedString,SubDiagramType,UnquotedString,Type(PropKeyword),UnquotedString,DocRef(PropKeyword),UnquotedString,SubDiagramType,UnquotedString,Type(PropKeyword),QuotedString,DocRef(PropKeyword),UnquotedString,RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,UnquotedString),RelationshipLine(RelationshipStart,BackArrow,RelationshipType(Keyword),Hyphen,UnquotedString))+RequirementDiagram(DiagramName,SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),ID(PropKeyword),IDNumber,Text(PropKeyword),UnquotedString,Risk(PropKeyword),RiskType(Keyword),VerifyMethod(PropKeyword),VerifyMethodType(Keyword),SubDiagramType,Name(UnquotedString),Type(PropKeyword),UnquotedString,SubDiagramType,Name(UnquotedString),Type(PropKeyword),UnquotedString,DocRef(PropKeyword),UnquotedString,SubDiagramType,Name(UnquotedString),Type(PropKeyword),QuotedString,DocRef(PropKeyword),UnquotedString,RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,Hyphen,RelationshipType(Keyword),ForwardArrow,Name(UnquotedString)),RelationshipLine(RelationshipStart,BackArrow,RelationshipType(Keyword),Hyphen,Name(UnquotedString)))# Element name at the end of input