dot-language-support 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/index.d.ts +497 -0
  2. package/dist/index.js +3853 -0
  3. package/package.json +10 -11
  4. package/.github/dependabot.yml +0 -15
  5. package/.github/workflows/CD.yml +0 -37
  6. package/.github/workflows/CI.yml +0 -28
  7. package/.github/workflows/auto-merge.yaml +0 -26
  8. package/CITATION.cff +0 -14
  9. package/biome.json +0 -48
  10. package/lib/cjs/binder.d.ts +0 -2
  11. package/lib/cjs/binder.js +0 -297
  12. package/lib/cjs/checker.d.ts +0 -15
  13. package/lib/cjs/checker.js +0 -228
  14. package/lib/cjs/core.d.ts +0 -1
  15. package/lib/cjs/core.js +0 -13
  16. package/lib/cjs/error.d.ts +0 -3
  17. package/lib/cjs/error.js +0 -12
  18. package/lib/cjs/index.d.ts +0 -5
  19. package/lib/cjs/index.js +0 -22
  20. package/lib/cjs/parser.d.ts +0 -27
  21. package/lib/cjs/parser.js +0 -664
  22. package/lib/cjs/scanner.d.ts +0 -41
  23. package/lib/cjs/scanner.js +0 -578
  24. package/lib/cjs/service/codeAction.d.ts +0 -12
  25. package/lib/cjs/service/codeAction.js +0 -245
  26. package/lib/cjs/service/colorProvider.d.ts +0 -5
  27. package/lib/cjs/service/colorProvider.js +0 -91
  28. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  29. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -42
  30. package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  31. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +0 -67
  32. package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  33. package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +0 -87
  34. package/lib/cjs/service/command/RemoveSemicolons.d.ts +0 -10
  35. package/lib/cjs/service/command/RemoveSemicolons.js +0 -39
  36. package/lib/cjs/service/command/common.d.ts +0 -31
  37. package/lib/cjs/service/command/common.js +0 -33
  38. package/lib/cjs/service/completion.d.ts +0 -4
  39. package/lib/cjs/service/completion.js +0 -173
  40. package/lib/cjs/service/hover.d.ts +0 -4
  41. package/lib/cjs/service/hover.js +0 -142
  42. package/lib/cjs/service/languageFacts.d.ts +0 -683
  43. package/lib/cjs/service/languageFacts.js +0 -996
  44. package/lib/cjs/service/reference.d.ts +0 -5
  45. package/lib/cjs/service/reference.js +0 -67
  46. package/lib/cjs/service/rename.d.ts +0 -4
  47. package/lib/cjs/service/rename.js +0 -51
  48. package/lib/cjs/service/service.d.ts +0 -28
  49. package/lib/cjs/service/service.js +0 -38
  50. package/lib/cjs/service/util.d.ts +0 -11
  51. package/lib/cjs/service/util.js +0 -49
  52. package/lib/cjs/service/validation.d.ts +0 -4
  53. package/lib/cjs/service/validation.js +0 -23
  54. package/lib/cjs/tester.d.ts +0 -1
  55. package/lib/cjs/tester.js +0 -23
  56. package/lib/cjs/types.d.ts +0 -397
  57. package/lib/cjs/types.js +0 -74
  58. package/lib/cjs/visitor.d.ts +0 -2
  59. package/lib/cjs/visitor.js +0 -76
  60. package/lib/esm/binder.d.ts +0 -2
  61. package/lib/esm/binder.js +0 -294
  62. package/lib/esm/checker.d.ts +0 -15
  63. package/lib/esm/checker.js +0 -212
  64. package/lib/esm/core.d.ts +0 -1
  65. package/lib/esm/core.js +0 -10
  66. package/lib/esm/error.d.ts +0 -3
  67. package/lib/esm/error.js +0 -8
  68. package/lib/esm/index.d.ts +0 -5
  69. package/lib/esm/index.js +0 -6
  70. package/lib/esm/parser.d.ts +0 -27
  71. package/lib/esm/parser.js +0 -714
  72. package/lib/esm/scanner.d.ts +0 -41
  73. package/lib/esm/scanner.js +0 -581
  74. package/lib/esm/service/codeAction.d.ts +0 -12
  75. package/lib/esm/service/codeAction.js +0 -207
  76. package/lib/esm/service/colorProvider.d.ts +0 -5
  77. package/lib/esm/service/colorProvider.js +0 -54
  78. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  79. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -38
  80. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  81. package/lib/esm/service/command/ChangeEdgeOpCommand.js +0 -30
  82. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  83. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +0 -83
  84. package/lib/esm/service/command/RemoveSemicolons.d.ts +0 -10
  85. package/lib/esm/service/command/RemoveSemicolons.js +0 -35
  86. package/lib/esm/service/command/common.d.ts +0 -31
  87. package/lib/esm/service/command/common.js +0 -25
  88. package/lib/esm/service/completion.d.ts +0 -4
  89. package/lib/esm/service/completion.js +0 -137
  90. package/lib/esm/service/hover.d.ts +0 -4
  91. package/lib/esm/service/hover.js +0 -135
  92. package/lib/esm/service/languageFacts.d.ts +0 -683
  93. package/lib/esm/service/languageFacts.js +0 -993
  94. package/lib/esm/service/reference.d.ts +0 -5
  95. package/lib/esm/service/reference.js +0 -63
  96. package/lib/esm/service/rename.d.ts +0 -4
  97. package/lib/esm/service/rename.js +0 -48
  98. package/lib/esm/service/service.d.ts +0 -28
  99. package/lib/esm/service/service.js +0 -35
  100. package/lib/esm/service/util.d.ts +0 -11
  101. package/lib/esm/service/util.js +0 -42
  102. package/lib/esm/service/validation.d.ts +0 -4
  103. package/lib/esm/service/validation.js +0 -20
  104. package/lib/esm/tester.d.ts +0 -1
  105. package/lib/esm/tester.js +0 -21
  106. package/lib/esm/types.d.ts +0 -397
  107. package/lib/esm/types.js +0 -71
  108. package/lib/esm/visitor.d.ts +0 -2
  109. package/lib/esm/visitor.js +0 -73
package/dist/index.js ADDED
@@ -0,0 +1,3853 @@
1
+ // src/core.ts
2
+ function createMapFromTemplate(template) {
3
+ const map = /* @__PURE__ */ new Map();
4
+ for (const key in template) {
5
+ if (key in template) {
6
+ map.set(key, template[key]);
7
+ }
8
+ }
9
+ return map;
10
+ }
11
+
12
+ // src/types.ts
13
+ var ErrorSource = /* @__PURE__ */ ((ErrorSource2) => {
14
+ ErrorSource2[ErrorSource2["Scan"] = 1] = "Scan";
15
+ ErrorSource2[ErrorSource2["Parse"] = 2] = "Parse";
16
+ ErrorSource2[ErrorSource2["Check"] = 4] = "Check";
17
+ return ErrorSource2;
18
+ })(ErrorSource || {});
19
+ var ParseError = /* @__PURE__ */ ((ParseError2) => {
20
+ ParseError2[ParseError2["ExpectationFailed"] = 0] = "ExpectationFailed";
21
+ ParseError2[ParseError2["TrailingData"] = 1] = "TrailingData";
22
+ ParseError2[ParseError2["FailedListParsing"] = 2] = "FailedListParsing";
23
+ return ParseError2;
24
+ })(ParseError || {});
25
+ var ScanError = /* @__PURE__ */ ((ScanError2) => {
26
+ ScanError2[ScanError2["ExpectationFailed"] = 0] = "ExpectationFailed";
27
+ ScanError2[ScanError2["Unterminated"] = 1] = "Unterminated";
28
+ return ScanError2;
29
+ })(ScanError || {});
30
+ var CheckError = /* @__PURE__ */ ((CheckError2) => {
31
+ CheckError2[CheckError2["InvalidEdgeOperation"] = 0] = "InvalidEdgeOperation";
32
+ CheckError2[CheckError2["InvalidShapeName"] = 1] = "InvalidShapeName";
33
+ return CheckError2;
34
+ })(CheckError || {});
35
+ var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
36
+ DiagnosticCategory2[DiagnosticCategory2["Error"] = 1] = "Error";
37
+ DiagnosticCategory2[DiagnosticCategory2["Warning"] = 2] = "Warning";
38
+ DiagnosticCategory2[DiagnosticCategory2["Message"] = 3] = "Message";
39
+ DiagnosticCategory2[DiagnosticCategory2["Suggestion"] = 4] = "Suggestion";
40
+ return DiagnosticCategory2;
41
+ })(DiagnosticCategory || {});
42
+ var SyntaxKind = /* @__PURE__ */ ((SyntaxKind2) => {
43
+ SyntaxKind2[SyntaxKind2["Unknown"] = 0] = "Unknown";
44
+ SyntaxKind2[SyntaxKind2["EndOfFileToken"] = 1] = "EndOfFileToken";
45
+ SyntaxKind2[SyntaxKind2["NewLineTrivia"] = 2] = "NewLineTrivia";
46
+ SyntaxKind2[SyntaxKind2["WhitespaceTrivia"] = 3] = "WhitespaceTrivia";
47
+ SyntaxKind2[SyntaxKind2["HashCommentTrivia"] = 4] = "HashCommentTrivia";
48
+ SyntaxKind2[SyntaxKind2["SingleLineCommentTrivia"] = 5] = "SingleLineCommentTrivia";
49
+ SyntaxKind2[SyntaxKind2["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia";
50
+ SyntaxKind2[SyntaxKind2["CommaToken"] = 7] = "CommaToken";
51
+ SyntaxKind2[SyntaxKind2["SemicolonToken"] = 8] = "SemicolonToken";
52
+ SyntaxKind2[SyntaxKind2["PlusToken"] = 9] = "PlusToken";
53
+ SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 10] = "OpenBraceToken";
54
+ SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 11] = "CloseBraceToken";
55
+ SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 12] = "OpenBracketToken";
56
+ SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 13] = "CloseBracketToken";
57
+ SyntaxKind2[SyntaxKind2["ColonToken"] = 14] = "ColonToken";
58
+ SyntaxKind2[SyntaxKind2["EqualsToken"] = 15] = "EqualsToken";
59
+ SyntaxKind2[SyntaxKind2["LessThan"] = 16] = "LessThan";
60
+ SyntaxKind2[SyntaxKind2["GreaterThan"] = 17] = "GreaterThan";
61
+ SyntaxKind2[SyntaxKind2["CompassNorthToken"] = 18] = "CompassNorthToken";
62
+ SyntaxKind2[SyntaxKind2["CompassNorthEastToken"] = 19] = "CompassNorthEastToken";
63
+ SyntaxKind2[SyntaxKind2["CompassEastToken"] = 20] = "CompassEastToken";
64
+ SyntaxKind2[SyntaxKind2["CompassSouthEastToken"] = 21] = "CompassSouthEastToken";
65
+ SyntaxKind2[SyntaxKind2["CompassSouthToken"] = 22] = "CompassSouthToken";
66
+ SyntaxKind2[SyntaxKind2["CompassSouthWestToken"] = 23] = "CompassSouthWestToken";
67
+ SyntaxKind2[SyntaxKind2["CompassWestToken"] = 24] = "CompassWestToken";
68
+ SyntaxKind2[SyntaxKind2["CompassNorthWestToken"] = 25] = "CompassNorthWestToken";
69
+ SyntaxKind2[SyntaxKind2["CompassCenterToken"] = 26] = "CompassCenterToken";
70
+ SyntaxKind2[SyntaxKind2["UnderscoreToken"] = 27] = "UnderscoreToken";
71
+ SyntaxKind2[SyntaxKind2["StringLiteral"] = 28] = "StringLiteral";
72
+ SyntaxKind2[SyntaxKind2["HtmlIdentifier"] = 29] = "HtmlIdentifier";
73
+ SyntaxKind2[SyntaxKind2["TextIdentifier"] = 30] = "TextIdentifier";
74
+ SyntaxKind2[SyntaxKind2["QuotedTextIdentifier"] = 31] = "QuotedTextIdentifier";
75
+ SyntaxKind2[SyntaxKind2["NumericIdentifier"] = 32] = "NumericIdentifier";
76
+ SyntaxKind2[SyntaxKind2["GraphKeyword"] = 33] = "GraphKeyword";
77
+ SyntaxKind2[SyntaxKind2["DigraphKeyword"] = 34] = "DigraphKeyword";
78
+ SyntaxKind2[SyntaxKind2["NodeKeyword"] = 35] = "NodeKeyword";
79
+ SyntaxKind2[SyntaxKind2["EdgeKeyword"] = 36] = "EdgeKeyword";
80
+ SyntaxKind2[SyntaxKind2["SubgraphKeyword"] = 37] = "SubgraphKeyword";
81
+ SyntaxKind2[SyntaxKind2["StrictKeyword"] = 38] = "StrictKeyword";
82
+ SyntaxKind2[SyntaxKind2["DirectedEdgeOp"] = 39] = "DirectedEdgeOp";
83
+ SyntaxKind2[SyntaxKind2["UndirectedEdgeOp"] = 40] = "UndirectedEdgeOp";
84
+ SyntaxKind2[SyntaxKind2["DirectedGraph"] = 41] = "DirectedGraph";
85
+ SyntaxKind2[SyntaxKind2["UndirectedGraph"] = 42] = "UndirectedGraph";
86
+ SyntaxKind2[SyntaxKind2["NodeStatement"] = 43] = "NodeStatement";
87
+ SyntaxKind2[SyntaxKind2["EdgeStatement"] = 44] = "EdgeStatement";
88
+ SyntaxKind2[SyntaxKind2["AttributeStatement"] = 45] = "AttributeStatement";
89
+ SyntaxKind2[SyntaxKind2["IdEqualsIdStatement"] = 46] = "IdEqualsIdStatement";
90
+ SyntaxKind2[SyntaxKind2["SubGraph"] = 47] = "SubGraph";
91
+ SyntaxKind2[SyntaxKind2["SubGraphStatement"] = 48] = "SubGraphStatement";
92
+ SyntaxKind2[SyntaxKind2["EdgeRhs"] = 49] = "EdgeRhs";
93
+ SyntaxKind2[SyntaxKind2["AttributeContainer"] = 50] = "AttributeContainer";
94
+ SyntaxKind2[SyntaxKind2["Assignment"] = 51] = "Assignment";
95
+ SyntaxKind2[SyntaxKind2["NormalPortDeclaration"] = 52] = "NormalPortDeclaration";
96
+ SyntaxKind2[SyntaxKind2["CompassPortDeclaration"] = 53] = "CompassPortDeclaration";
97
+ SyntaxKind2[SyntaxKind2["NodeId"] = 54] = "NodeId";
98
+ SyntaxKind2[SyntaxKind2["Count"] = 55] = "Count";
99
+ SyntaxKind2[SyntaxKind2["FirstNode"] = 41 /* DirectedGraph */] = "FirstNode";
100
+ SyntaxKind2[SyntaxKind2["CompassBegin"] = 18 /* CompassNorthToken */] = "CompassBegin";
101
+ SyntaxKind2[SyntaxKind2["CompassEnd"] = 27 /* UnderscoreToken */] = "CompassEnd";
102
+ SyntaxKind2[SyntaxKind2["LastKeyword"] = 38 /* StrictKeyword */] = "LastKeyword";
103
+ return SyntaxKind2;
104
+ })(SyntaxKind || {});
105
+ var SyntaxNodeFlags = /* @__PURE__ */ ((SyntaxNodeFlags2) => {
106
+ SyntaxNodeFlags2[SyntaxNodeFlags2["None"] = 0] = "None";
107
+ SyntaxNodeFlags2[SyntaxNodeFlags2["ContainsErrors"] = 2] = "ContainsErrors";
108
+ SyntaxNodeFlags2[SyntaxNodeFlags2["Synthesized"] = 4] = "Synthesized";
109
+ return SyntaxNodeFlags2;
110
+ })(SyntaxNodeFlags || {});
111
+ var GraphContext = /* @__PURE__ */ ((GraphContext2) => {
112
+ GraphContext2[GraphContext2["None"] = 0] = "None";
113
+ GraphContext2[GraphContext2["Strict"] = 2] = "Strict";
114
+ GraphContext2[GraphContext2["Directed"] = 4] = "Directed";
115
+ GraphContext2[GraphContext2["Undirected"] = 8] = "Undirected";
116
+ return GraphContext2;
117
+ })(GraphContext || {});
118
+ var TokenFlags = /* @__PURE__ */ ((TokenFlags2) => {
119
+ TokenFlags2[TokenFlags2["None"] = 0] = "None";
120
+ TokenFlags2[TokenFlags2["Unterminated"] = 2] = "Unterminated";
121
+ TokenFlags2[TokenFlags2["PrecedingLineBreak"] = 4] = "PrecedingLineBreak";
122
+ return TokenFlags2;
123
+ })(TokenFlags || {});
124
+ var CharacterCodes = /* @__PURE__ */ ((CharacterCodes2) => {
125
+ CharacterCodes2[CharacterCodes2["nullCharacter"] = 0] = "nullCharacter";
126
+ CharacterCodes2[CharacterCodes2["maxAsciiCharacter"] = 127] = "maxAsciiCharacter";
127
+ CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
128
+ CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
129
+ CharacterCodes2[CharacterCodes2["lineSeparator"] = 8232] = "lineSeparator";
130
+ CharacterCodes2[CharacterCodes2["paragraphSeparator"] = 8233] = "paragraphSeparator";
131
+ CharacterCodes2[CharacterCodes2["nextLine"] = 133] = "nextLine";
132
+ CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
133
+ CharacterCodes2[CharacterCodes2["nonBreakingSpace"] = 160] = "nonBreakingSpace";
134
+ CharacterCodes2[CharacterCodes2["enQuad"] = 8192] = "enQuad";
135
+ CharacterCodes2[CharacterCodes2["emQuad"] = 8193] = "emQuad";
136
+ CharacterCodes2[CharacterCodes2["enSpace"] = 8194] = "enSpace";
137
+ CharacterCodes2[CharacterCodes2["emSpace"] = 8195] = "emSpace";
138
+ CharacterCodes2[CharacterCodes2["threePerEmSpace"] = 8196] = "threePerEmSpace";
139
+ CharacterCodes2[CharacterCodes2["fourPerEmSpace"] = 8197] = "fourPerEmSpace";
140
+ CharacterCodes2[CharacterCodes2["sixPerEmSpace"] = 8198] = "sixPerEmSpace";
141
+ CharacterCodes2[CharacterCodes2["figureSpace"] = 8199] = "figureSpace";
142
+ CharacterCodes2[CharacterCodes2["punctuationSpace"] = 8200] = "punctuationSpace";
143
+ CharacterCodes2[CharacterCodes2["thinSpace"] = 8201] = "thinSpace";
144
+ CharacterCodes2[CharacterCodes2["hairSpace"] = 8202] = "hairSpace";
145
+ CharacterCodes2[CharacterCodes2["zeroWidthSpace"] = 8203] = "zeroWidthSpace";
146
+ CharacterCodes2[CharacterCodes2["narrowNoBreakSpace"] = 8239] = "narrowNoBreakSpace";
147
+ CharacterCodes2[CharacterCodes2["ideographicSpace"] = 12288] = "ideographicSpace";
148
+ CharacterCodes2[CharacterCodes2["mathematicalSpace"] = 8287] = "mathematicalSpace";
149
+ CharacterCodes2[CharacterCodes2["ogham"] = 5760] = "ogham";
150
+ CharacterCodes2[CharacterCodes2["_"] = 95] = "_";
151
+ CharacterCodes2[CharacterCodes2["$"] = 36] = "$";
152
+ CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
153
+ CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
154
+ CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
155
+ CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
156
+ CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
157
+ CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
158
+ CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
159
+ CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
160
+ CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
161
+ CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
162
+ CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
163
+ CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
164
+ CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
165
+ CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
166
+ CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
167
+ CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
168
+ CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
169
+ CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
170
+ CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
171
+ CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
172
+ CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
173
+ CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
174
+ CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
175
+ CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
176
+ CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
177
+ CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
178
+ CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
179
+ CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
180
+ CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
181
+ CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
182
+ CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
183
+ CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
184
+ CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
185
+ CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
186
+ CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
187
+ CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
188
+ CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
189
+ CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
190
+ CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
191
+ CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
192
+ CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
193
+ CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
194
+ CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
195
+ CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
196
+ CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
197
+ CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
198
+ CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
199
+ CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
200
+ CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
201
+ CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
202
+ CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
203
+ CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
204
+ CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
205
+ CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
206
+ CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
207
+ CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
208
+ CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
209
+ CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
210
+ CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
211
+ CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
212
+ CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
213
+ CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
214
+ CharacterCodes2[CharacterCodes2["ampersand"] = 38] = "ampersand";
215
+ CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
216
+ CharacterCodes2[CharacterCodes2["at"] = 64] = "at";
217
+ CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
218
+ CharacterCodes2[CharacterCodes2["backtick"] = 96] = "backtick";
219
+ CharacterCodes2[CharacterCodes2["bar"] = 124] = "bar";
220
+ CharacterCodes2[CharacterCodes2["caret"] = 94] = "caret";
221
+ CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
222
+ CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
223
+ CharacterCodes2[CharacterCodes2["closeParen"] = 41] = "closeParen";
224
+ CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
225
+ CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
226
+ CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
227
+ CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
228
+ CharacterCodes2[CharacterCodes2["equals"] = 61] = "equals";
229
+ CharacterCodes2[CharacterCodes2["exclamation"] = 33] = "exclamation";
230
+ CharacterCodes2[CharacterCodes2["greaterThan"] = 62] = "greaterThan";
231
+ CharacterCodes2[CharacterCodes2["hash"] = 35] = "hash";
232
+ CharacterCodes2[CharacterCodes2["lessThan"] = 60] = "lessThan";
233
+ CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
234
+ CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
235
+ CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
236
+ CharacterCodes2[CharacterCodes2["openParen"] = 40] = "openParen";
237
+ CharacterCodes2[CharacterCodes2["percent"] = 37] = "percent";
238
+ CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
239
+ CharacterCodes2[CharacterCodes2["question"] = 63] = "question";
240
+ CharacterCodes2[CharacterCodes2["semicolon"] = 59] = "semicolon";
241
+ CharacterCodes2[CharacterCodes2["singleQuote"] = 39] = "singleQuote";
242
+ CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
243
+ CharacterCodes2[CharacterCodes2["tilde"] = 126] = "tilde";
244
+ CharacterCodes2[CharacterCodes2["backspace"] = 8] = "backspace";
245
+ CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
246
+ CharacterCodes2[CharacterCodes2["byteOrderMark"] = 65279] = "byteOrderMark";
247
+ CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
248
+ CharacterCodes2[CharacterCodes2["verticalTab"] = 11] = "verticalTab";
249
+ return CharacterCodes2;
250
+ })(CharacterCodes || {});
251
+
252
+ // src/service/util.ts
253
+ function getStart(sourceFile, node) {
254
+ return getTokenPosOfNode(sourceFile, node);
255
+ }
256
+ function getTokenPosOfNode(sourceFile, node) {
257
+ if (nodeIsMissing(node)) return node.pos;
258
+ return skipTrivia(sourceFile.content, node.pos);
259
+ }
260
+ function nodeIsMissing(node) {
261
+ return node === void 0 ? true : node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */;
262
+ }
263
+ function syntaxNodesToRanges(doc, sourceFile, nodes) {
264
+ return nodes.map((node) => syntaxNodeToRange(doc, sourceFile, node));
265
+ }
266
+ function syntaxNodeToRange(doc, sourceFile, node) {
267
+ const start = getStart(sourceFile, node);
268
+ return {
269
+ start: doc.positionAt(start),
270
+ end: doc.positionAt(node.end)
271
+ };
272
+ }
273
+ function escapeIdentifierText(text) {
274
+ if (text === "") return quote("");
275
+ if (text.includes('"') || text.includes("\n")) {
276
+ const esc = text.replace(/"/, '\\"').replace(/\n/, "\\\n");
277
+ return quote(esc);
278
+ }
279
+ const ch = text.charCodeAt(0);
280
+ if (!isIdentifierStart(ch) || text.includes(" ")) return quote(text);
281
+ return text;
282
+ }
283
+ var quote = (s) => `"${s}"`;
284
+ function assertNever(v) {
285
+ throw new Error(`Should not have reached this. Value: ${v ?? ""}`);
286
+ }
287
+
288
+ // src/scanner.ts
289
+ var textToToken = createMapFromTemplate({
290
+ digraph: 34 /* DigraphKeyword */,
291
+ graph: 33 /* GraphKeyword */,
292
+ edge: 36 /* EdgeKeyword */,
293
+ node: 35 /* NodeKeyword */,
294
+ strict: 38 /* StrictKeyword */,
295
+ subgraph: 37 /* SubgraphKeyword */,
296
+ n: 18 /* CompassNorthToken */,
297
+ ne: 19 /* CompassNorthEastToken */,
298
+ e: 20 /* CompassEastToken */,
299
+ se: 21 /* CompassSouthEastToken */,
300
+ s: 22 /* CompassSouthToken */,
301
+ sw: 23 /* CompassSouthWestToken */,
302
+ w: 24 /* CompassWestToken */,
303
+ nw: 25 /* CompassNorthWestToken */,
304
+ c: 26 /* CompassCenterToken */,
305
+ "+": 9 /* PlusToken */,
306
+ "=": 15 /* EqualsToken */,
307
+ "->": 39 /* DirectedEdgeOp */,
308
+ "--": 40 /* UndirectedEdgeOp */,
309
+ "{": 10 /* OpenBraceToken */,
310
+ "}": 11 /* CloseBraceToken */,
311
+ "[": 12 /* OpenBracketToken */,
312
+ "]": 13 /* CloseBracketToken */,
313
+ ";": 8 /* SemicolonToken */,
314
+ ":": 14 /* ColonToken */,
315
+ _: 27 /* UnderscoreToken */,
316
+ ",": 7 /* CommaToken */,
317
+ "<": 16 /* LessThan */,
318
+ ">": 17 /* GreaterThan */
319
+ });
320
+ function makeReverseMap(source) {
321
+ const result = /* @__PURE__ */ new Map();
322
+ source.forEach((value, key) => {
323
+ result.set(value, key);
324
+ });
325
+ return result;
326
+ }
327
+ var tokenToText = makeReverseMap(textToToken);
328
+ function getTokenAsText(token) {
329
+ return tokenToText.get(token);
330
+ }
331
+ function getTextAsToken(token) {
332
+ return textToToken.get(token);
333
+ }
334
+ var DefaultScanner = class {
335
+ setText(newText, start = 0, length) {
336
+ this.text = newText || "";
337
+ this.end = length === void 0 ? this.text.length : start + length;
338
+ this.#setTextPos(start || 0);
339
+ }
340
+ setErrorCallback(cb) {
341
+ this.onError = cb;
342
+ }
343
+ #setTextPos(textPos) {
344
+ console.assert(textPos >= 0);
345
+ this.pos = textPos;
346
+ this.startPos = textPos;
347
+ this.tokenPos = textPos;
348
+ this.token = 0 /* Unknown */;
349
+ this.tokenValue = void 0;
350
+ this.tokenFlags = 0 /* None */;
351
+ }
352
+ scan(skipTrivia2 = true) {
353
+ this.startPos = this.pos;
354
+ this.tokenFlags = 0 /* None */;
355
+ this.isUnterminated = false;
356
+ while (true) {
357
+ this.tokenPos = this.pos;
358
+ if (this.pos >= this.end) {
359
+ return this.token = 1 /* EndOfFileToken */;
360
+ }
361
+ let ch = this.text.charCodeAt(this.pos);
362
+ switch (ch) {
363
+ case 10 /* lineFeed */:
364
+ case 13 /* carriageReturn */:
365
+ this.tokenFlags |= 4 /* PrecedingLineBreak */;
366
+ if (skipTrivia2) {
367
+ this.pos++;
368
+ continue;
369
+ }
370
+ if (ch === 13 /* carriageReturn */ && this.pos + 1 < this.end && this.text.charCodeAt(this.pos + 1) === 10 /* lineFeed */) {
371
+ this.pos += 2;
372
+ } else {
373
+ this.pos++;
374
+ }
375
+ return this.token = 2 /* NewLineTrivia */;
376
+ case 9 /* tab */:
377
+ case 11 /* verticalTab */:
378
+ case 12 /* formFeed */:
379
+ case 32 /* space */:
380
+ if (skipTrivia2) {
381
+ this.pos++;
382
+ continue;
383
+ }
384
+ while (this.pos < this.end && this.#isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos)))
385
+ this.pos++;
386
+ return this.token = 3 /* WhitespaceTrivia */;
387
+ case 35 /* hash */: {
388
+ const content = this.#scanHashCommentTrivia(skipTrivia2);
389
+ if (skipTrivia2) continue;
390
+ this.tokenValue = content;
391
+ return this.token = 4 /* HashCommentTrivia */;
392
+ }
393
+ case 47 /* slash */: {
394
+ if (this.pos + 1 < this.end) {
395
+ const nextChar = this.text.charCodeAt(this.pos + 1);
396
+ switch (nextChar) {
397
+ case 47 /* slash */: {
398
+ const commentContent = this.#scanSingleLineCommentTrivia(skipTrivia2);
399
+ if (skipTrivia2) continue;
400
+ this.tokenValue = commentContent;
401
+ return this.token = 5 /* SingleLineCommentTrivia */;
402
+ }
403
+ case 42 /* asterisk */: {
404
+ const commentContent = this.#scanMultiLineCommentTrivia(skipTrivia2);
405
+ if (skipTrivia2) continue;
406
+ this.tokenValue = commentContent;
407
+ return this.token = 6 /* MultiLineCommentTrivia */;
408
+ }
409
+ }
410
+ }
411
+ this.#error(
412
+ 'Unexpected "/". Did you mean to start a comment like "/*" or "//"? If you wanted to use it as an identifier, put it in double quotes.',
413
+ 0 /* ExpectationFailed */
414
+ );
415
+ ++this.pos;
416
+ break;
417
+ }
418
+ case 123 /* openBrace */:
419
+ this.pos++;
420
+ return this.token = 10 /* OpenBraceToken */;
421
+ case 125 /* closeBrace */:
422
+ this.pos++;
423
+ return this.token = 11 /* CloseBraceToken */;
424
+ case 91 /* openBracket */:
425
+ this.pos++;
426
+ return this.token = 12 /* OpenBracketToken */;
427
+ case 93 /* closeBracket */:
428
+ this.pos++;
429
+ return this.token = 13 /* CloseBracketToken */;
430
+ case 43 /* plus */:
431
+ this.pos++;
432
+ return this.token = 9 /* PlusToken */;
433
+ case 61 /* equals */:
434
+ this.pos++;
435
+ return this.token = 15 /* EqualsToken */;
436
+ case 48 /* _0 */:
437
+ case 49 /* _1 */:
438
+ case 50 /* _2 */:
439
+ case 51 /* _3 */:
440
+ case 52 /* _4 */:
441
+ case 53 /* _5 */:
442
+ case 54 /* _6 */:
443
+ case 55 /* _7 */:
444
+ case 56 /* _8 */:
445
+ case 57 /* _9 */:
446
+ case 46 /* dot */:
447
+ this.tokenValue = this.#scanNumber();
448
+ return this.token = 32 /* NumericIdentifier */;
449
+ case 45 /* minus */: {
450
+ const nextChar = this.text.charCodeAt(this.pos + 1);
451
+ switch (nextChar) {
452
+ case 45 /* minus */:
453
+ this.pos += 2;
454
+ return this.token = 40 /* UndirectedEdgeOp */;
455
+ case 62 /* greaterThan */:
456
+ this.pos += 2;
457
+ return this.token = 39 /* DirectedEdgeOp */;
458
+ case 48 /* _0 */:
459
+ case 49 /* _1 */:
460
+ case 50 /* _2 */:
461
+ case 51 /* _3 */:
462
+ case 52 /* _4 */:
463
+ case 53 /* _5 */:
464
+ case 54 /* _6 */:
465
+ case 55 /* _7 */:
466
+ case 56 /* _8 */:
467
+ case 57 /* _9 */:
468
+ case 46 /* dot */:
469
+ this.tokenValue = this.#scanNumber();
470
+ return this.token = 32 /* NumericIdentifier */;
471
+ default: {
472
+ const chr = this.text.charAt(this.pos + 1);
473
+ this.#error(
474
+ `Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`,
475
+ 0 /* ExpectationFailed */
476
+ );
477
+ break;
478
+ }
479
+ }
480
+ this.pos++;
481
+ break;
482
+ }
483
+ // TODO: Remove UnderscoreToken
484
+ case 95 /* _ */:
485
+ this.pos++;
486
+ return this.token = 27 /* UnderscoreToken */;
487
+ case 59 /* semicolon */:
488
+ this.pos++;
489
+ return this.token = 8 /* SemicolonToken */;
490
+ case 58 /* colon */:
491
+ this.pos++;
492
+ return this.token = 14 /* ColonToken */;
493
+ case 44 /* comma */:
494
+ this.pos++;
495
+ return this.token = 7 /* CommaToken */;
496
+ case 60 /* lessThan */:
497
+ this.tokenValue = this.#scanHtml();
498
+ return this.token = 29 /* HtmlIdentifier */;
499
+ case 34 /* doubleQuote */:
500
+ this.tokenValue = this.#scanString();
501
+ return this.token = 28 /* StringLiteral */;
502
+ default: {
503
+ if (isIdentifierStart(ch)) {
504
+ this.pos++;
505
+ while (this.pos < this.end && isIdentifierPart(ch = this.text.charCodeAt(this.pos)))
506
+ this.pos++;
507
+ const value = this.text.substring(this.tokenPos, this.pos);
508
+ this.tokenValue = value;
509
+ return this.token = this.#getIdentifierToken(value);
510
+ }
511
+ if (this.#isWhiteSpaceSingleLine(ch)) {
512
+ this.pos++;
513
+ continue;
514
+ }
515
+ const chr = this.text.charAt(this.pos);
516
+ this.#error(
517
+ `Unexpected "${chr}". Did you mean to start an identifier? Node names cannot start with "${chr}".`,
518
+ 0 /* ExpectationFailed */
519
+ );
520
+ this.pos++;
521
+ break;
522
+ }
523
+ }
524
+ }
525
+ }
526
+ #error(message, sub, category = 1 /* Error */, errPos = this.pos, length = 0) {
527
+ const cb = this.onError;
528
+ if (cb) {
529
+ const posSave = this.pos;
530
+ this.pos = errPos;
531
+ cb(message, category, sub, length);
532
+ this.pos = posSave;
533
+ }
534
+ }
535
+ #isWhiteSpaceSingleLine(ch) {
536
+ return ch === 32 /* space */ || ch === 9 /* tab */ || ch === 11 /* verticalTab */ || ch === 12 /* formFeed */ || ch === 160 /* nonBreakingSpace */ || ch === 133 /* nextLine */ || ch === 5760 /* ogham */ || ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || ch === 8239 /* narrowNoBreakSpace */ || ch === 8287 /* mathematicalSpace */ || ch === 12288 /* ideographicSpace */ || ch === 65279 /* byteOrderMark */;
537
+ }
538
+ #isAtMultiLineCommentEnd(pos) {
539
+ return pos + 1 < this.end && this.text.charCodeAt(pos) === 42 /* asterisk */ && this.text.charCodeAt(pos + 1) === 47 /* slash */;
540
+ }
541
+ #scanHashCommentTrivia(skip) {
542
+ ++this.pos;
543
+ const start = this.pos;
544
+ while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos))) this.pos++;
545
+ return skip ? void 0 : this.text.substring(start, this.pos);
546
+ }
547
+ #scanSingleLineCommentTrivia(skip) {
548
+ this.pos += 2;
549
+ const start = this.pos;
550
+ while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos))) this.pos++;
551
+ return skip ? void 0 : this.text.substring(start, this.pos);
552
+ }
553
+ #scanMultiLineCommentTrivia(skip) {
554
+ this.pos += 2;
555
+ const start = this.pos;
556
+ while (this.pos < this.end && !this.#isAtMultiLineCommentEnd(this.pos)) this.pos++;
557
+ const commentEnd = this.pos;
558
+ if (this.#isAtMultiLineCommentEnd(this.pos)) {
559
+ this.pos += 2;
560
+ }
561
+ return skip ? void 0 : this.text.substring(start, commentEnd);
562
+ }
563
+ #scanHtml() {
564
+ this.pos++;
565
+ let result = "";
566
+ const start = this.pos;
567
+ let subTagsLevel = 0;
568
+ while (true) {
569
+ if (this.pos >= this.end) {
570
+ result += this.text.substring(start, this.pos);
571
+ this.tokenFlags |= 2 /* Unterminated */;
572
+ this.isUnterminated = true;
573
+ this.#error("Unterminated html literal", 1 /* Unterminated */);
574
+ break;
575
+ }
576
+ const ch = this.text.charCodeAt(this.pos);
577
+ if (ch === 60 /* lessThan */) {
578
+ ++subTagsLevel;
579
+ this.pos++;
580
+ continue;
581
+ }
582
+ if (ch === 62 /* greaterThan */) {
583
+ this.pos++;
584
+ console.assert(subTagsLevel >= 0);
585
+ if (subTagsLevel === 0) {
586
+ result += this.text.substring(start, this.pos);
587
+ break;
588
+ }
589
+ --subTagsLevel;
590
+ continue;
591
+ }
592
+ this.pos++;
593
+ }
594
+ return result;
595
+ }
596
+ // biome-ignore lint/correctness/noUnusedFunctionParameters: todo
597
+ #scanString(allowEscapes = true) {
598
+ const quote2 = this.text.charCodeAt(this.pos);
599
+ this.pos++;
600
+ let result = "";
601
+ const start = this.pos;
602
+ let hasBackslash = false;
603
+ while (true) {
604
+ if (this.pos >= this.end) {
605
+ result += this.text.substring(start, this.pos);
606
+ this.tokenFlags |= 2 /* Unterminated */;
607
+ this.isUnterminated = true;
608
+ this.#error("Unterminated string", 1 /* Unterminated */);
609
+ break;
610
+ }
611
+ const ch = this.text.charCodeAt(this.pos);
612
+ if (ch === 92 /* backslash */) {
613
+ hasBackslash = true;
614
+ } else {
615
+ if (hasBackslash) {
616
+ hasBackslash = false;
617
+ } else {
618
+ if (ch === quote2) {
619
+ result += this.text.substring(start, this.pos);
620
+ this.pos++;
621
+ break;
622
+ }
623
+ if (isLineBreak(ch)) {
624
+ result += this.text.substring(start, this.pos);
625
+ this.tokenFlags |= 2 /* Unterminated */;
626
+ this.isUnterminated = true;
627
+ this.#error("Unterminated string", 1 /* Unterminated */);
628
+ break;
629
+ }
630
+ }
631
+ }
632
+ this.pos++;
633
+ }
634
+ const removedEscapes = result.replace(/\\"/g, '"').replace(/\\(\r?\n)/g, "$1");
635
+ return removedEscapes;
636
+ }
637
+ #scanNumber() {
638
+ let result = "";
639
+ let hadDot = false;
640
+ let hadMinus = false;
641
+ const start = this.pos;
642
+ while (true) {
643
+ const ch = this.text.charCodeAt(this.pos);
644
+ switch (ch) {
645
+ case 48 /* _0 */:
646
+ case 49 /* _1 */:
647
+ case 50 /* _2 */:
648
+ case 51 /* _3 */:
649
+ case 52 /* _4 */:
650
+ case 53 /* _5 */:
651
+ case 54 /* _6 */:
652
+ case 55 /* _7 */:
653
+ case 56 /* _8 */:
654
+ case 57 /* _9 */:
655
+ break;
656
+ case 46 /* dot */:
657
+ if (hadDot) {
658
+ result += this.text.substring(start, this.pos);
659
+ return result;
660
+ }
661
+ hadDot = true;
662
+ hadMinus = true;
663
+ break;
664
+ case 45 /* minus */:
665
+ if (this.pos !== start || hadMinus) {
666
+ result += this.text.substring(start, this.pos);
667
+ return result;
668
+ }
669
+ hadMinus = true;
670
+ break;
671
+ default:
672
+ result += this.text.substring(start, this.pos);
673
+ return result;
674
+ }
675
+ ++this.pos;
676
+ }
677
+ }
678
+ #getIdentifierToken(tokenValue) {
679
+ const len = tokenValue.length;
680
+ if (len >= 4 && len <= 8) {
681
+ const ch = tokenValue.charCodeAt(0);
682
+ if (ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 65 /* A */ && ch <= 90 /* Z */) {
683
+ const lowerCaseToken = tokenValue.toLowerCase();
684
+ const t = textToToken.get(lowerCaseToken);
685
+ if (t !== void 0) {
686
+ this.token = t;
687
+ return t;
688
+ }
689
+ }
690
+ }
691
+ return this.token = 30 /* TextIdentifier */;
692
+ }
693
+ lookAhead(callback) {
694
+ return this.#speculationHelper(
695
+ callback,
696
+ /*isLookahead*/
697
+ true
698
+ );
699
+ }
700
+ tryScan(callback) {
701
+ return this.#speculationHelper(
702
+ callback,
703
+ /*isLookahead*/
704
+ false
705
+ );
706
+ }
707
+ #speculationHelper(callback, isLookahead) {
708
+ const savePos = this.pos;
709
+ const saveStartPos = this.startPos;
710
+ const saveTokenPos = this.tokenPos;
711
+ const saveToken = this.token;
712
+ const saveTokenValue = this.tokenValue;
713
+ const saveTokenFlags = this.tokenFlags;
714
+ const result = callback();
715
+ if (!result || isLookahead) {
716
+ this.pos = savePos;
717
+ this.startPos = saveStartPos;
718
+ this.tokenPos = saveTokenPos;
719
+ this.token = saveToken;
720
+ this.tokenValue = saveTokenValue;
721
+ this.tokenFlags = saveTokenFlags;
722
+ }
723
+ return result;
724
+ }
725
+ };
726
+ function isIdentifierStart(ch) {
727
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 95 /* _ */ || ch === 60 /* lessThan */ || ch === 34 /* doubleQuote */;
728
+ }
729
+ function isIdentifierPart(ch) {
730
+ return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */;
731
+ }
732
+ function skipTrivia(text, pos) {
733
+ while (true) {
734
+ const ch = text.charCodeAt(pos);
735
+ switch (ch) {
736
+ case 13 /* carriageReturn */:
737
+ if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) ++pos;
738
+ continue;
739
+ case 10 /* lineFeed */:
740
+ case 9 /* tab */:
741
+ case 11 /* verticalTab */:
742
+ case 12 /* formFeed */:
743
+ case 32 /* space */:
744
+ ++pos;
745
+ continue;
746
+ case 35 /* hash */: {
747
+ ++pos;
748
+ while (pos < text.length) {
749
+ if (isLineBreak(text.charCodeAt(pos))) break;
750
+ ++pos;
751
+ }
752
+ continue;
753
+ }
754
+ case 47 /* slash */:
755
+ if (pos + 1 < text.length) {
756
+ const nextChar = text.charCodeAt(pos + 1);
757
+ switch (nextChar) {
758
+ case 47 /* slash */: {
759
+ pos += 2;
760
+ while (pos < text.length) {
761
+ if (isLineBreak(text.charCodeAt(pos))) break;
762
+ ++pos;
763
+ }
764
+ continue;
765
+ }
766
+ case 42 /* asterisk */: {
767
+ pos += 2;
768
+ while (pos < text.length) {
769
+ if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
770
+ pos += 2;
771
+ break;
772
+ }
773
+ ++pos;
774
+ }
775
+ continue;
776
+ }
777
+ }
778
+ }
779
+ break;
780
+ }
781
+ return pos;
782
+ }
783
+ }
784
+ function isLineBreak(ch) {
785
+ return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */;
786
+ }
787
+
788
+ // src/parser.ts
789
+ var ParsingContext = /* @__PURE__ */ ((ParsingContext2) => {
790
+ ParsingContext2[ParsingContext2["None"] = 0] = "None";
791
+ ParsingContext2[ParsingContext2["StatementList"] = 1] = "StatementList";
792
+ ParsingContext2[ParsingContext2["AttributeContainerList"] = 2] = "AttributeContainerList";
793
+ ParsingContext2[ParsingContext2["AssignmentList"] = 3] = "AssignmentList";
794
+ ParsingContext2[ParsingContext2["EdgeRhsList"] = 4] = "EdgeRhsList";
795
+ ParsingContext2[ParsingContext2["QuotedTextIdentifierConcatenation"] = 5] = "QuotedTextIdentifierConcatenation";
796
+ ParsingContext2[ParsingContext2["Count"] = 6] = "Count";
797
+ return ParsingContext2;
798
+ })(ParsingContext || {});
799
+ var Parser = class {
800
+ // TODO
801
+ constructor() {
802
+ this.currentToken = 0 /* Unknown */;
803
+ this.identifierCount = 0;
804
+ this.scanner = new DefaultScanner();
805
+ this.#resetState();
806
+ }
807
+ #resetState() {
808
+ this.sourceText = "";
809
+ this.scanner.setText(this.sourceText);
810
+ this.scanner.setErrorCallback(this.#scanError.bind(this));
811
+ this.identifierCount = 0;
812
+ this.identifiers = /* @__PURE__ */ new Set();
813
+ this.nodeCount = 0;
814
+ this.diagnostics = [];
815
+ this.currentNodeHasError = false;
816
+ this.currentContext = 0 /* None */;
817
+ }
818
+ #nextToken() {
819
+ this.currentToken = this.scanner.scan(true);
820
+ return this.currentToken;
821
+ }
822
+ #token() {
823
+ return this.currentToken;
824
+ }
825
+ #getLinesFromFile(sourceText) {
826
+ return sourceText.split(/\r?\n/);
827
+ }
828
+ parse(sourceText) {
829
+ this.sourceText = sourceText;
830
+ this.scanner.setText(this.sourceText);
831
+ this.#nextToken();
832
+ let graph;
833
+ if (this.#token() !== 1 /* EndOfFileToken */) {
834
+ graph = this.#parseGraph();
835
+ if (this.#token() !== 1 /* EndOfFileToken */) {
836
+ this.#parseErrorAtPosition(
837
+ this.scanner.tokenPos,
838
+ this.scanner.text.length - 1,
839
+ "Content after the end of a graph declaration is invalid.",
840
+ { source: 2 /* Parse */, sub: 1 /* TrailingData */ }
841
+ );
842
+ }
843
+ }
844
+ const result = {
845
+ content: this.sourceText,
846
+ graph,
847
+ identifiers: this.identifiers,
848
+ diagnostics: this.diagnostics
849
+ };
850
+ this.#resetState();
851
+ return result;
852
+ }
853
+ #parseGraph() {
854
+ const strictToken = this.#parseOptionalToken(38 /* StrictKeyword */);
855
+ const keyword = this.#parseExpectedTokenOneOf(34 /* DigraphKeyword */, [
856
+ 34 /* DigraphKeyword */,
857
+ 33 /* GraphKeyword */
858
+ ]);
859
+ const kind = keyword === void 0 || keyword.kind === 34 /* DigraphKeyword */ ? 41 /* DirectedGraph */ : 42 /* UndirectedGraph */;
860
+ const graphStart = strictToken ? strictToken.pos : keyword.pos;
861
+ const node = this.#createNode(kind, graphStart);
862
+ node.strict = strictToken;
863
+ node.keyword = keyword;
864
+ node.id = this.#isIdentifier() ? this.#parseIdentifier() : void 0;
865
+ this.#parseExpectedToken(10 /* OpenBraceToken */);
866
+ node.statements = this.#parseList(
867
+ 1 /* StatementList */,
868
+ () => this.#parseStatement()
869
+ );
870
+ this.#parseExpectedToken(11 /* CloseBraceToken */);
871
+ return this.#finishNode(node);
872
+ }
873
+ #parseIdentifier() {
874
+ let result;
875
+ const escapedIdTexts = [];
876
+ switch (this.#token()) {
877
+ case 30 /* TextIdentifier */:
878
+ result = this.#parseTextIdentifier();
879
+ escapedIdTexts.push(result.text);
880
+ break;
881
+ case 28 /* StringLiteral */:
882
+ result = this.#parseQuotedTextIdentifierConcatenation();
883
+ escapedIdTexts.push(...result.values.map((v) => v.text));
884
+ break;
885
+ case 29 /* HtmlIdentifier */:
886
+ result = this.#parseHtmlIdentifier();
887
+ escapedIdTexts.push(result.htmlContent);
888
+ break;
889
+ case 32 /* NumericIdentifier */:
890
+ result = this.#parseNumericIdentifier();
891
+ escapedIdTexts.push(result.text);
892
+ break;
893
+ default:
894
+ this.#reportExpectedError([30 /* TextIdentifier */]);
895
+ result = this.#createMissingNode(30 /* TextIdentifier */);
896
+ break;
897
+ }
898
+ for (const i of escapedIdTexts) {
899
+ this.#registerIdentifier(i);
900
+ }
901
+ return result;
902
+ }
903
+ #registerIdentifier(id) {
904
+ this.identifierCount++;
905
+ const has = this.identifiers.has(id);
906
+ if (!has) this.identifiers.add(id);
907
+ }
908
+ #parseTextIdentifier() {
909
+ const node = this.#createNode(30 /* TextIdentifier */);
910
+ const text = this.scanner.tokenValue;
911
+ this.#nextToken();
912
+ if (text === void 0) throw "Satisfy type checker";
913
+ node.text = text;
914
+ return this.#finishNode(node);
915
+ }
916
+ #parseQuotedTextIdentifierConcatenation() {
917
+ const node = this.#createNode(31 /* QuotedTextIdentifier */);
918
+ node.values = this.#parseList(
919
+ 5 /* QuotedTextIdentifierConcatenation */,
920
+ () => this.#parseQuotedTextIdentifier(),
921
+ /* at least one */
922
+ true
923
+ );
924
+ return this.#finishNode(node);
925
+ }
926
+ #parseQuotedTextIdentifier() {
927
+ const node = this.#createNode(28 /* StringLiteral */);
928
+ if (this.#token() === 9 /* PlusToken */) this.#nextToken();
929
+ const text = this.scanner.tokenValue;
930
+ this.#nextToken();
931
+ if (text === void 0) throw "Satisfy type checker";
932
+ node.text = text;
933
+ return this.#finishNode(node);
934
+ }
935
+ #isQuotedStringFollowing() {
936
+ this.#nextToken();
937
+ return this.#token() === 28 /* StringLiteral */;
938
+ }
939
+ #parseHtmlIdentifier() {
940
+ const node = this.#createNode(29 /* HtmlIdentifier */);
941
+ const text = this.scanner.tokenValue;
942
+ this.#nextToken();
943
+ if (text === void 0) throw "Satisfy type checker";
944
+ node.htmlContent = text;
945
+ return this.#finishNode(node);
946
+ }
947
+ #parseNumericIdentifier() {
948
+ const node = this.#createNode(32 /* NumericIdentifier */);
949
+ const text = this.scanner.tokenValue;
950
+ this.#nextToken();
951
+ if (text === void 0) throw "Satisfy type checker";
952
+ node.text = text;
953
+ node.value = Number(text);
954
+ return this.#finishNode(node);
955
+ }
956
+ #parseStatement() {
957
+ switch (this.#token()) {
958
+ case 33 /* GraphKeyword */:
959
+ case 35 /* NodeKeyword */:
960
+ case 36 /* EdgeKeyword */:
961
+ return this.#parseAttributeStatement();
962
+ case 10 /* OpenBraceToken */:
963
+ case 37 /* SubgraphKeyword */: {
964
+ const subgraph = this.#parseSubGraph();
965
+ if (this.#token() === 8 /* SemicolonToken */) {
966
+ const subgraphStatement2 = this.#createNode(
967
+ 48 /* SubGraphStatement */,
968
+ subgraph.pos
969
+ );
970
+ subgraphStatement2.subgraph = subgraph;
971
+ subgraphStatement2.terminator = this.#parseExpectedToken(
972
+ 8 /* SemicolonToken */
973
+ );
974
+ return this.#finishNode(subgraphStatement2);
975
+ }
976
+ if (this.#isEdgeOp()) return this.#parseEdgeStatement(subgraph);
977
+ const subgraphStatement = this.#createNode(
978
+ 48 /* SubGraphStatement */,
979
+ subgraph.pos
980
+ );
981
+ subgraphStatement.subgraph = subgraph;
982
+ return this.#finishNode(subgraphStatement);
983
+ }
984
+ default: {
985
+ if (!this.#isIdentifier) debugger;
986
+ if (this.#lookAhead(() => this.#isIdEqualsIdStatement())) {
987
+ return this.#parseIdEqualsIdStatement();
988
+ }
989
+ const ns = this.#parseNodeStatement();
990
+ if (ns.terminator !== void 0 || ns.attributes.length !== 0) return ns;
991
+ if (this.#isEdgeOp()) return this.#parseEdgeStatement(ns.id);
992
+ return ns;
993
+ }
994
+ }
995
+ }
996
+ #parseAttributeStatement() {
997
+ switch (this.#token()) {
998
+ case 33 /* GraphKeyword */:
999
+ case 35 /* NodeKeyword */:
1000
+ case 36 /* EdgeKeyword */: {
1001
+ const node = this.#createNode(45 /* AttributeStatement */);
1002
+ node.subject = this.#parseTokenNode();
1003
+ if (this.#token() === 12 /* OpenBracketToken */) {
1004
+ node.attributes = this.#parseList(
1005
+ 2 /* AttributeContainerList */,
1006
+ () => this.#parseAttributeContainer()
1007
+ );
1008
+ } else {
1009
+ this.#reportExpectedError([12 /* OpenBracketToken */]);
1010
+ const missingStatement = this.#createMissingNode(
1011
+ 45 /* AttributeStatement */
1012
+ );
1013
+ missingStatement.attributes = this.#createNodeArray(
1014
+ [this.#createMissingNode(50 /* AttributeContainer */)],
1015
+ this.scanner.tokenPos,
1016
+ this.scanner.tokenPos
1017
+ );
1018
+ }
1019
+ node.terminator = this.#parseOptionalToken(8 /* SemicolonToken */);
1020
+ return this.#finishNode(node);
1021
+ }
1022
+ default:
1023
+ throw "This should never happen";
1024
+ }
1025
+ }
1026
+ #parseAttributeContainer() {
1027
+ if (this.#token() !== 12 /* OpenBracketToken */) debugger;
1028
+ const node = this.#createNode(50 /* AttributeContainer */);
1029
+ node.openBracket = this.#parseExpectedToken(12 /* OpenBracketToken */);
1030
+ if (this.#isIdentifier() && this.#lookAhead(() => this.#isAssignmentStart())) {
1031
+ node.assignments = this.#parseList(
1032
+ 3 /* AssignmentList */,
1033
+ () => this.#parseAssignment()
1034
+ );
1035
+ } else {
1036
+ node.assignments = this.#createEmptyArray();
1037
+ }
1038
+ node.closeBracket = this.#parseExpectedToken(13 /* CloseBracketToken */);
1039
+ return this.#finishNode(node);
1040
+ }
1041
+ #isAssignmentStart() {
1042
+ if (!this.#isIdentifier) debugger;
1043
+ this.#nextToken();
1044
+ return this.#token() === 15 /* EqualsToken */;
1045
+ }
1046
+ #parseIdEqualsIdStatement() {
1047
+ if (!this.#isIdentifier) debugger;
1048
+ const leftIdentifier = this.#parseIdentifier();
1049
+ const node = this.#createNode(
1050
+ 46 /* IdEqualsIdStatement */,
1051
+ leftIdentifier.pos
1052
+ );
1053
+ node.leftId = leftIdentifier;
1054
+ if (this.#token() !== 15 /* EqualsToken */) debugger;
1055
+ this.#parseExpectedToken(15 /* EqualsToken */);
1056
+ node.rightId = this.#parseIdentifier();
1057
+ node.terminator = this.#parseOptionalToken(8 /* SemicolonToken */);
1058
+ return this.#finishNode(node);
1059
+ }
1060
+ #isIdEqualsIdStatement() {
1061
+ if (!this.#isIdentifier) debugger;
1062
+ this.#nextToken();
1063
+ return this.#token() === 15 /* EqualsToken */;
1064
+ }
1065
+ #parseNodeStatement() {
1066
+ if (!this.#isIdentifier) debugger;
1067
+ const node = this.#createNode(43 /* NodeStatement */);
1068
+ node.id = this.#parseNodeId();
1069
+ if (this.#token() === 12 /* OpenBracketToken */) {
1070
+ node.attributes = this.#parseList(
1071
+ 2 /* AttributeContainerList */,
1072
+ () => this.#parseAttributeContainer()
1073
+ );
1074
+ } else {
1075
+ node.attributes = this.#createEmptyArray();
1076
+ }
1077
+ node.terminator = this.#parseOptionalToken(8 /* SemicolonToken */);
1078
+ return this.#finishNode(node);
1079
+ }
1080
+ #parseEdgeStatement(precedingItem) {
1081
+ console.assert(
1082
+ precedingItem.kind === 47 /* SubGraph */ || precedingItem.kind === 54 /* NodeId */
1083
+ );
1084
+ console.assert(precedingItem.pos !== void 0);
1085
+ if (!this.#isEdgeOp()) debugger;
1086
+ const node = this.#createNode(44 /* EdgeStatement */, precedingItem.pos);
1087
+ node.source = precedingItem;
1088
+ node.rhs = this.#parseList(4 /* EdgeRhsList */, () => this.#parseEdgeRhs());
1089
+ if (this.#token() === 12 /* OpenBracketToken */) {
1090
+ node.attributes = this.#parseList(
1091
+ 2 /* AttributeContainerList */,
1092
+ () => this.#parseAttributeContainer()
1093
+ );
1094
+ } else {
1095
+ node.attributes = this.#createEmptyArray();
1096
+ }
1097
+ node.terminator = this.#parseOptionalToken(8 /* SemicolonToken */);
1098
+ return this.#finishNode(node);
1099
+ }
1100
+ #parseEdgeRhs() {
1101
+ const node = this.#createNode(49 /* EdgeRhs */);
1102
+ const op = this.#parseExpectedTokenOneOf(39 /* DirectedEdgeOp */, [
1103
+ 39 /* DirectedEdgeOp */,
1104
+ 40 /* UndirectedEdgeOp */
1105
+ ]);
1106
+ node.operation = op;
1107
+ switch (this.#token()) {
1108
+ case 37 /* SubgraphKeyword */:
1109
+ case 10 /* OpenBraceToken */:
1110
+ node.target = this.#parseSubGraph();
1111
+ break;
1112
+ default: {
1113
+ node.target = this.#parseNodeId();
1114
+ break;
1115
+ }
1116
+ }
1117
+ return this.#finishNode(node);
1118
+ }
1119
+ #createMissingNode(kind) {
1120
+ const result = this.#createNode(kind);
1121
+ if (isIdentifierNode(result)) {
1122
+ switch (result.kind) {
1123
+ case 31 /* QuotedTextIdentifier */: {
1124
+ const literal = this.#createNode(28 /* StringLiteral */);
1125
+ literal.text = "";
1126
+ const values = this.#createNodeArray([literal], result.pos, result.pos);
1127
+ result.values = values;
1128
+ break;
1129
+ }
1130
+ case 29 /* HtmlIdentifier */:
1131
+ result.htmlContent = "";
1132
+ break;
1133
+ case 30 /* TextIdentifier */:
1134
+ case 32 /* NumericIdentifier */:
1135
+ result.text = "";
1136
+ break;
1137
+ }
1138
+ }
1139
+ return this.#finishNode(result);
1140
+ }
1141
+ #parseAssignment() {
1142
+ if (!this.#isIdentifier) debugger;
1143
+ const node = this.#createNode(51 /* Assignment */);
1144
+ node.leftId = this.#parseIdentifier();
1145
+ this.#parseExpectedToken(15 /* EqualsToken */);
1146
+ node.rightId = this.#parseIdentifier();
1147
+ let terminator = this.#parseOptionalToken(
1148
+ 7 /* CommaToken */
1149
+ );
1150
+ if (terminator === void 0)
1151
+ terminator = this.#parseOptionalToken(8 /* SemicolonToken */);
1152
+ node.terminator = terminator;
1153
+ return this.#finishNode(node);
1154
+ }
1155
+ #parseSubGraph() {
1156
+ console.assert(
1157
+ this.#token() === 37 /* SubgraphKeyword */ || this.#token() === 10 /* OpenBraceToken */
1158
+ );
1159
+ const subGraph = this.#parseOptionalToken(37 /* SubgraphKeyword */);
1160
+ const subGraphStart = subGraph !== void 0 ? subGraph.pos : void 0;
1161
+ const node = this.#createNode(47 /* SubGraph */, subGraphStart);
1162
+ const identifier = subGraph !== void 0 && this.#isIdentifier() ? this.#parseIdentifier() : void 0;
1163
+ node.id = identifier;
1164
+ this.#parseExpectedToken(10 /* OpenBraceToken */);
1165
+ node.statements = this.#parseList(
1166
+ 1 /* StatementList */,
1167
+ () => this.#parseStatement()
1168
+ );
1169
+ this.#parseExpectedToken(11 /* CloseBraceToken */);
1170
+ return this.#finishNode(node);
1171
+ }
1172
+ #parseNodeId() {
1173
+ if (!this.#isIdentifier) debugger;
1174
+ const node = this.#createNode(54 /* NodeId */);
1175
+ node.id = this.#parseIdentifier();
1176
+ node.port = this.#token() === 14 /* ColonToken */ ? this.#parsePortDeclaration() : void 0;
1177
+ return this.#finishNode(node);
1178
+ }
1179
+ #parseCompassPortDeclaration() {
1180
+ console.assert(this.#token() === 14 /* ColonToken */);
1181
+ const node = this.#createNode(53 /* CompassPortDeclaration */);
1182
+ node.colon = this.#parseTokenNode();
1183
+ node.compassPt = this.#parseTokenNode();
1184
+ return this.#finishNode(node);
1185
+ }
1186
+ #parseNormalPortDeclaration() {
1187
+ console.assert(this.#token() === 14 /* ColonToken */);
1188
+ const node = this.#createNode(52 /* NormalPortDeclaration */);
1189
+ node.colon = this.#parseTokenNode();
1190
+ node.id = this.#parseIdentifier();
1191
+ node.compassPt = this.#token() === 14 /* ColonToken */ ? this.#parseCompassPortDeclaration() : void 0;
1192
+ return this.#finishNode(node);
1193
+ }
1194
+ #parsePortDeclaration() {
1195
+ console.assert(this.#token() === 14 /* ColonToken */);
1196
+ if (this.#lookAhead(() => this.#isCompassPort()))
1197
+ return this.#parseCompassPortDeclaration();
1198
+ return this.#parseNormalPortDeclaration();
1199
+ }
1200
+ #isCompassPort() {
1201
+ console.assert(this.#token() === 14 /* ColonToken */);
1202
+ if (this.#token() !== 14 /* ColonToken */) return false;
1203
+ this.#nextToken();
1204
+ return this.#isCompassPortKind(this.#token());
1205
+ }
1206
+ #parseList(context, parseElement, atLeastOne = false) {
1207
+ const saveParsingContext = this.currentContext;
1208
+ this.currentContext |= 1 << context;
1209
+ let isListTerminated = atLeastOne ? false : this.#isListTerminator(context);
1210
+ const startPos = this.scanner.startPos;
1211
+ const elements = [];
1212
+ while (!isListTerminated) {
1213
+ if (this.#isListElement(context, false)) {
1214
+ const element = parseElement();
1215
+ elements.push(element);
1216
+ isListTerminated = this.#isListTerminator(context);
1217
+ continue;
1218
+ }
1219
+ if (this.#abortListParsing(context)) break;
1220
+ }
1221
+ this.currentContext = saveParsingContext;
1222
+ return this.#createNodeArray(elements, startPos);
1223
+ }
1224
+ #getContextParseError(context) {
1225
+ switch (context) {
1226
+ case 1 /* StatementList */:
1227
+ return "Assignment, node definition, graph/node/edge attribute or edge definition expected.";
1228
+ case 3 /* AssignmentList */:
1229
+ return "Assignment expected.";
1230
+ case 4 /* EdgeRhsList */:
1231
+ return "Edge operation expected.";
1232
+ case 5 /* QuotedTextIdentifierConcatenation */:
1233
+ return "Quoted identifier expected";
1234
+ case 2 /* AttributeContainerList */:
1235
+ return "Attribute marker expected.";
1236
+ // TODO: Was besseres finden
1237
+ case 0 /* None */:
1238
+ return "Wat, no parsing context";
1239
+ case 6 /* Count */:
1240
+ return "Wat, 'Count' parsing context";
1241
+ default:
1242
+ return assertNever(context);
1243
+ }
1244
+ }
1245
+ #isInSomeParsingContext() {
1246
+ for (let ctx = 0; ctx < 6 /* Count */; ctx++) {
1247
+ if (this.currentContext & 1 << ctx) {
1248
+ if (this.#isListElement(
1249
+ ctx,
1250
+ /*inErrorRecovery*/
1251
+ true
1252
+ ) || this.#isListTerminator(ctx)) {
1253
+ return true;
1254
+ }
1255
+ }
1256
+ }
1257
+ return false;
1258
+ }
1259
+ #abortListParsing(context) {
1260
+ this.#parseErrorAtCurrentToken(
1261
+ this.#getContextParseError(context),
1262
+ 2 /* FailedListParsing */
1263
+ );
1264
+ if (this.#isInSomeParsingContext()) {
1265
+ return true;
1266
+ }
1267
+ this.#nextToken();
1268
+ return false;
1269
+ }
1270
+ #isListElement(context, _inErrorRecovery) {
1271
+ switch (context) {
1272
+ case 3 /* AssignmentList */:
1273
+ return this.#isIdentifier();
1274
+ case 2 /* AttributeContainerList */:
1275
+ return this.#token() === 12 /* OpenBracketToken */;
1276
+ case 4 /* EdgeRhsList */:
1277
+ return this.#token() === 39 /* DirectedEdgeOp */ || this.#token() === 40 /* UndirectedEdgeOp */;
1278
+ case 5 /* QuotedTextIdentifierConcatenation */:
1279
+ return this.#token() === 28 /* StringLiteral */ || this.#token() === 9 /* PlusToken */;
1280
+ case 1 /* StatementList */:
1281
+ return this.#isIdentifier() || this.#token() === 37 /* SubgraphKeyword */ || this.#token() === 10 /* OpenBraceToken */ || this.#token() === 33 /* GraphKeyword */ || this.#token() === 36 /* EdgeKeyword */ || this.#token() === 35 /* NodeKeyword */;
1282
+ default:
1283
+ throw "This should never happen";
1284
+ }
1285
+ }
1286
+ #isListTerminator(context) {
1287
+ const token = this.#token();
1288
+ if (token === 1 /* EndOfFileToken */) return true;
1289
+ switch (context) {
1290
+ case 1 /* StatementList */:
1291
+ return token === 11 /* CloseBraceToken */;
1292
+ case 2 /* AttributeContainerList */:
1293
+ return token !== 12 /* OpenBracketToken */;
1294
+ case 3 /* AssignmentList */:
1295
+ return token === 13 /* CloseBracketToken */;
1296
+ case 4 /* EdgeRhsList */:
1297
+ return token !== 39 /* DirectedEdgeOp */ && token !== 40 /* UndirectedEdgeOp */;
1298
+ case 5 /* QuotedTextIdentifierConcatenation */:
1299
+ return token !== 9 /* PlusToken */;
1300
+ default:
1301
+ throw "Unsupported parsing context";
1302
+ }
1303
+ }
1304
+ #createEmptyArray() {
1305
+ const startPos = this.scanner.startPos;
1306
+ const elements = [];
1307
+ return this.#createNodeArray(elements, startPos);
1308
+ }
1309
+ #finishNode(node, end) {
1310
+ node.end = end === void 0 ? this.scanner.startPos : end;
1311
+ if (this.currentNodeHasError) {
1312
+ this.currentNodeHasError = false;
1313
+ node.flags |= 2 /* ContainsErrors */;
1314
+ }
1315
+ return node;
1316
+ }
1317
+ #createNode(kind, pos) {
1318
+ this.nodeCount++;
1319
+ const p = pos !== void 0 && pos >= 0 ? pos : this.scanner.startPos;
1320
+ if (isNodeKind(kind) || kind === 0 /* Unknown */) return newNode(kind, p, p);
1321
+ return isIdentifier(kind) ? newIdentifier(kind, p, p) : newToken(kind, p, p);
1322
+ }
1323
+ #createNodeArray(elements, pos, end) {
1324
+ const length = elements.length;
1325
+ const array = length >= 1 && length <= 4 ? elements.slice() : elements;
1326
+ array.pos = pos;
1327
+ array.end = end === void 0 ? this.scanner.startPos : end;
1328
+ return array;
1329
+ }
1330
+ #parseTokenNode() {
1331
+ const node = this.#createNode(this.#token());
1332
+ this.#nextToken();
1333
+ return this.#finishNode(node);
1334
+ }
1335
+ #getLastError(diagnostics) {
1336
+ return diagnostics && diagnostics.length > 0 ? diagnostics[diagnostics.length - 1] : void 0;
1337
+ }
1338
+ #parseErrorAtPosition(start, end, message, code) {
1339
+ const ds = this.diagnostics;
1340
+ const lastError = this.#getLastError(ds);
1341
+ if (!lastError || start !== lastError.start) {
1342
+ ds.push({
1343
+ category: 1 /* Error */,
1344
+ start,
1345
+ end,
1346
+ message,
1347
+ code
1348
+ });
1349
+ }
1350
+ this.currentNodeHasError = true;
1351
+ }
1352
+ #parseErrorAtCurrentToken(message, sub) {
1353
+ const error = {
1354
+ source: 2 /* Parse */,
1355
+ sub
1356
+ };
1357
+ return this.#parseErrorAtPosition(this.scanner.tokenPos, this.scanner.pos, message, error);
1358
+ }
1359
+ #scanError(message, _category, sub, length) {
1360
+ const errorPos = this.scanner.pos;
1361
+ const err = {
1362
+ source: 1 /* Scan */,
1363
+ sub
1364
+ };
1365
+ this.#parseErrorAtPosition(errorPos, errorPos + length, message, err);
1366
+ }
1367
+ #reportExpectedError(expectedKinds) {
1368
+ const found = this.#isIdentifier() ? "identifier" : this.#token() === 1 /* EndOfFileToken */ ? "end of file" : `"${getTokenAsText(this.#token())}"`;
1369
+ const expected = expectedKinds.map((k) => {
1370
+ if (isIdentifier(k)) {
1371
+ return "identifier";
1372
+ }
1373
+ if (k === 1 /* EndOfFileToken */) {
1374
+ return "end of file";
1375
+ }
1376
+ return `"${getTokenAsText(k)}"`;
1377
+ });
1378
+ const lastExpected = expected.pop();
1379
+ const expectedJoined = expected.join(", ");
1380
+ const msg = expected.length > 0 ? `Expected ${expectedJoined} or ${lastExpected} but found ${found} instead.` : `Expected ${lastExpected} but found ${found} instead.`;
1381
+ this.#parseErrorAtCurrentToken(msg, 0 /* ExpectationFailed */);
1382
+ }
1383
+ #parseExpectedOneOf(...kinds) {
1384
+ if (kinds.length < 2) {
1385
+ console.assert(false);
1386
+ debugger;
1387
+ }
1388
+ for (const kind of kinds) {
1389
+ if (this.#token() === kind) {
1390
+ this.#nextToken();
1391
+ return true;
1392
+ }
1393
+ }
1394
+ this.#reportExpectedError(kinds);
1395
+ return false;
1396
+ }
1397
+ #parseExpectedTokenOneOf(fallback, kinds) {
1398
+ if (kinds.length < 2) {
1399
+ console.assert(false);
1400
+ debugger;
1401
+ }
1402
+ for (const kind of kinds) {
1403
+ if (this.#token() === kind) {
1404
+ const node = this.#createNode(this.#token());
1405
+ this.#nextToken();
1406
+ return this.#finishNode(node);
1407
+ }
1408
+ }
1409
+ this.#reportExpectedError(kinds);
1410
+ return this.#createMissingNode(fallback);
1411
+ }
1412
+ #parseExpectedToken(kind) {
1413
+ const tokenNode = this.#parseOptionalToken(kind);
1414
+ if (tokenNode !== void 0) return tokenNode;
1415
+ this.#reportExpectedError([kind]);
1416
+ return this.#createMissingNode(kind);
1417
+ }
1418
+ #parseExpected(kind) {
1419
+ const res = this.#parseOptional(kind);
1420
+ if (!res) this.#reportExpectedError([kind]);
1421
+ return res;
1422
+ }
1423
+ #parseOptionalToken(t) {
1424
+ if (this.#token() === t) {
1425
+ return this.#parseTokenNode();
1426
+ }
1427
+ return void 0;
1428
+ }
1429
+ #parseOptional(t) {
1430
+ if (this.#token() === t) {
1431
+ this.#nextToken();
1432
+ return true;
1433
+ }
1434
+ return false;
1435
+ }
1436
+ #isEdgeOp() {
1437
+ switch (this.#token()) {
1438
+ case 39 /* DirectedEdgeOp */:
1439
+ case 40 /* UndirectedEdgeOp */:
1440
+ return true;
1441
+ default:
1442
+ return false;
1443
+ }
1444
+ }
1445
+ #isIdentifier() {
1446
+ switch (this.#token()) {
1447
+ case 30 /* TextIdentifier */:
1448
+ case 32 /* NumericIdentifier */:
1449
+ case 28 /* StringLiteral */:
1450
+ case 29 /* HtmlIdentifier */:
1451
+ return true;
1452
+ default:
1453
+ return false;
1454
+ }
1455
+ }
1456
+ #isCompassPortKind(kind) {
1457
+ return kind >= 26 /* CompassCenterToken */ && kind <= 27 /* CompassEnd */;
1458
+ }
1459
+ #speculationHelper(callback, isLookAhead) {
1460
+ const saveToken = this.#token();
1461
+ const saveDiagnosticsLength = this.diagnostics.length;
1462
+ const result = isLookAhead ? this.scanner.lookAhead(callback) : this.scanner.tryScan(callback);
1463
+ if (!result || isLookAhead) {
1464
+ this.currentToken = saveToken;
1465
+ this.diagnostics.length = saveDiagnosticsLength;
1466
+ }
1467
+ return result;
1468
+ }
1469
+ /** Invokes the provided callback then unconditionally restores the parser to the state it
1470
+ * was in immediately prior to invoking the callback. The result of invoking the callback
1471
+ * is returned from this function.
1472
+ */
1473
+ #lookAhead(callback) {
1474
+ return this.#speculationHelper(
1475
+ callback,
1476
+ /*isLookAhead*/
1477
+ true
1478
+ );
1479
+ }
1480
+ /** Invokes the provided callback. If the callback returns something falsy, then it restores
1481
+ * the parser to the state it was in immediately prior to invoking the callback. If the
1482
+ * callback returns something truthy, then the parser state is not rolled back. The result
1483
+ * of invoking the callback is returned from this function.
1484
+ */
1485
+ #tryParse(callback) {
1486
+ return this.#speculationHelper(
1487
+ callback,
1488
+ /*isLookAhead*/
1489
+ false
1490
+ );
1491
+ }
1492
+ };
1493
+ function newNode(kind, pos, end) {
1494
+ return {
1495
+ kind,
1496
+ flags: 0 /* None */,
1497
+ end,
1498
+ pos,
1499
+ parent: void 0
1500
+ };
1501
+ }
1502
+ var newIdentifier = newNode;
1503
+ var newToken = newNode;
1504
+ function isNodeKind(kind) {
1505
+ return kind >= 41 /* FirstNode */;
1506
+ }
1507
+ function isIdentifier(kind) {
1508
+ return kind === 29 /* HtmlIdentifier */ || kind === 32 /* NumericIdentifier */ || kind === 30 /* TextIdentifier */ || kind === 31 /* QuotedTextIdentifier */;
1509
+ }
1510
+ function isIdentifierNode(node) {
1511
+ return isIdentifier(node.kind);
1512
+ }
1513
+
1514
+ // src/service/languageFacts.ts
1515
+ var shapes = Object.freeze([
1516
+ "box",
1517
+ "polygon",
1518
+ "ellipse",
1519
+ "oval",
1520
+ "circle",
1521
+ "point",
1522
+ "egg",
1523
+ "triangle",
1524
+ "plaintext",
1525
+ "plain",
1526
+ "diamond",
1527
+ "trapezium",
1528
+ "parallelogram",
1529
+ "house",
1530
+ "pentagon",
1531
+ "hexagon",
1532
+ "septagon",
1533
+ "octagon",
1534
+ "doublecircle",
1535
+ "doubleoctagon",
1536
+ "tripleoctagon",
1537
+ "invtriangle",
1538
+ "invtrapezium",
1539
+ "invhouse",
1540
+ "Mdiamond",
1541
+ "Msquare",
1542
+ "Mcircle",
1543
+ "record",
1544
+ "rect",
1545
+ "rectangle",
1546
+ "square",
1547
+ "star",
1548
+ "none",
1549
+ "underline",
1550
+ "cylinder",
1551
+ "note",
1552
+ "tab",
1553
+ "folder",
1554
+ "box3d",
1555
+ "component",
1556
+ "promoter",
1557
+ "cds",
1558
+ "terminator",
1559
+ "utr",
1560
+ "primersite",
1561
+ "restrictionsite",
1562
+ "fivepoverhang",
1563
+ "threepoverhang",
1564
+ "noverhang",
1565
+ "assembly",
1566
+ "signature",
1567
+ "insulator",
1568
+ "ribosite",
1569
+ "rnastab",
1570
+ "proteasesite",
1571
+ "proteinstab",
1572
+ "rpromoter",
1573
+ "rarrow",
1574
+ "larrow",
1575
+ "lpromoter"
1576
+ ]);
1577
+ var edgeAttributes = Object.freeze([
1578
+ "URL",
1579
+ "arrowhead",
1580
+ "arrowsize",
1581
+ "arrowtail",
1582
+ "color",
1583
+ "colorscheme",
1584
+ "comment",
1585
+ "constraint",
1586
+ "decorate",
1587
+ "dir",
1588
+ "edgeURL",
1589
+ "edgehref",
1590
+ "edgetarget",
1591
+ "edgetooltip",
1592
+ "fillcolor",
1593
+ "fontcolor",
1594
+ "fontname",
1595
+ "fontsize",
1596
+ "headURL",
1597
+ "head_lp",
1598
+ "headclip",
1599
+ "headhref",
1600
+ "headlabel",
1601
+ "headport",
1602
+ "headtarget",
1603
+ "headtooltip",
1604
+ "href",
1605
+ "id",
1606
+ "label",
1607
+ "labelURL",
1608
+ "labelangle",
1609
+ "labeldistance",
1610
+ "labelfloat",
1611
+ "labelfontcolor",
1612
+ "labelfontname",
1613
+ "labelfontsize",
1614
+ "labelhref",
1615
+ "labeltarget",
1616
+ "labeltooltip",
1617
+ "layer",
1618
+ "len",
1619
+ "lhead",
1620
+ "lp",
1621
+ "ltail",
1622
+ "minlen",
1623
+ "nojustify",
1624
+ "penwidth",
1625
+ "pos",
1626
+ "samehead",
1627
+ "sametail",
1628
+ "showboxes",
1629
+ "style",
1630
+ "tailURL",
1631
+ "tail_lp",
1632
+ "tailclip",
1633
+ "tailhref",
1634
+ "taillabel",
1635
+ "tailport",
1636
+ "tailtarget",
1637
+ "tailtooltip",
1638
+ "target",
1639
+ "tooltip",
1640
+ "weight",
1641
+ "xlabel",
1642
+ "xlp"
1643
+ ]);
1644
+ var nodeAttributes = Object.freeze([
1645
+ "URL",
1646
+ "area",
1647
+ "color",
1648
+ "colorscheme",
1649
+ "comment",
1650
+ "distortion",
1651
+ "fillcolor",
1652
+ "fixedsize",
1653
+ "fontcolor",
1654
+ "fontname",
1655
+ "fontsize",
1656
+ "gradientangle",
1657
+ "group",
1658
+ "height",
1659
+ "href",
1660
+ "id",
1661
+ "image",
1662
+ "imagepos",
1663
+ "imagescale",
1664
+ "label",
1665
+ "labelloc",
1666
+ "layer",
1667
+ "margin",
1668
+ "nojustify",
1669
+ "ordering",
1670
+ "orientation",
1671
+ "penwidth",
1672
+ "peripheries",
1673
+ "pin",
1674
+ "pos",
1675
+ "rects",
1676
+ "regular",
1677
+ "root",
1678
+ "samplepoints",
1679
+ "shape",
1680
+ "shapefile",
1681
+ "showboxes",
1682
+ "sides",
1683
+ "skew",
1684
+ "sortv",
1685
+ "style",
1686
+ "target",
1687
+ "tooltip",
1688
+ "vertices",
1689
+ "width",
1690
+ "xlabel",
1691
+ "xlp",
1692
+ "z"
1693
+ ]);
1694
+ var graphAttributes = Object.freeze([
1695
+ "Damping",
1696
+ "K",
1697
+ "URL",
1698
+ "_background",
1699
+ "bb",
1700
+ "bgcolor",
1701
+ "center",
1702
+ "charset",
1703
+ "clusterrank",
1704
+ "colorscheme",
1705
+ "comment",
1706
+ "compound",
1707
+ "concentrate",
1708
+ "defaultdist",
1709
+ "dim",
1710
+ "dimen",
1711
+ "diredgeconstraints",
1712
+ "dpi",
1713
+ "epsilon",
1714
+ "esep",
1715
+ "fontcolor",
1716
+ "fontname",
1717
+ "fontnames",
1718
+ "fontpath",
1719
+ "fontsize",
1720
+ "forcelabels",
1721
+ "gradientangle",
1722
+ "href",
1723
+ "id",
1724
+ "imagepath",
1725
+ "inputscale",
1726
+ "label",
1727
+ "label_scheme",
1728
+ "labeljust",
1729
+ "labelloc",
1730
+ "landscape",
1731
+ "layerlistsep",
1732
+ "layers",
1733
+ "layerselect",
1734
+ "layersep",
1735
+ "layout",
1736
+ "levels",
1737
+ "levelsgap",
1738
+ "lheight",
1739
+ "lp",
1740
+ "lwidth",
1741
+ "margin",
1742
+ "maxiter",
1743
+ "mclimit",
1744
+ "mindist",
1745
+ "mode",
1746
+ "model",
1747
+ "mosek",
1748
+ "newrank",
1749
+ "nodesep",
1750
+ "nojustify",
1751
+ "normalize",
1752
+ "notranslate",
1753
+ "nslimit",
1754
+ "nslimit1",
1755
+ "ordering",
1756
+ "orientation",
1757
+ "outputorder",
1758
+ "overlap",
1759
+ "overlap_scaling",
1760
+ "overlap_shrink",
1761
+ "pack",
1762
+ "packmode",
1763
+ "pad",
1764
+ "page",
1765
+ "pagedir",
1766
+ "quadtree",
1767
+ "quantum",
1768
+ "rankdir",
1769
+ "ranksep",
1770
+ "ratio",
1771
+ "remincross",
1772
+ "repulsiveforce",
1773
+ "resolution",
1774
+ "root",
1775
+ "rotate",
1776
+ "rotation",
1777
+ "scale",
1778
+ "searchsize",
1779
+ "sep",
1780
+ "showboxes",
1781
+ "size",
1782
+ "smoothing",
1783
+ "sortv",
1784
+ "splines",
1785
+ "start",
1786
+ "style",
1787
+ "stylesheet",
1788
+ "target",
1789
+ "truecolor",
1790
+ "viewport",
1791
+ "voro_margin",
1792
+ "xdotversion"
1793
+ ]);
1794
+ var clusterAttributes = Object.freeze([
1795
+ "K",
1796
+ "URL",
1797
+ "area",
1798
+ "bgcolor",
1799
+ "color",
1800
+ "colorscheme",
1801
+ "fillcolor",
1802
+ "fontcolor",
1803
+ "fontname",
1804
+ "fontsize",
1805
+ "gradientangle",
1806
+ "href",
1807
+ "id",
1808
+ "label",
1809
+ "labeljust",
1810
+ "labelloc",
1811
+ "layer",
1812
+ "lheight",
1813
+ "lp",
1814
+ "lwidth",
1815
+ "margin",
1816
+ "nojustify",
1817
+ "pencolor",
1818
+ "penwidth",
1819
+ "peripheries",
1820
+ "sortv",
1821
+ "style",
1822
+ "target",
1823
+ "tooltip"
1824
+ ]);
1825
+ var attributes = Array.from(
1826
+ /* @__PURE__ */ new Set([...nodeAttributes, ...edgeAttributes, ...graphAttributes, ...clusterAttributes])
1827
+ ).sort();
1828
+ var colors = Object.freeze({
1829
+ aliceblue: "#f0f8ff",
1830
+ antiquewhite: "#faebd7",
1831
+ antiquewhite1: "#ffefdb",
1832
+ antiquewhite2: "#eedfcc",
1833
+ antiquewhite3: "#cdc0b0",
1834
+ antiquewhite4: "#8b8378",
1835
+ aqua: "#00ffff",
1836
+ aquamarine: "#7fffd4",
1837
+ aquamarine1: "#7fffd4",
1838
+ aquamarine2: "#76eec6",
1839
+ aquamarine3: "#66cdaa",
1840
+ aquamarine4: "#458b74",
1841
+ azure: "#f0ffff",
1842
+ azure1: "#f0ffff",
1843
+ azure2: "#e0eeee",
1844
+ azure3: "#c1cdcd",
1845
+ azure4: "#838b8b",
1846
+ beige: "#f5f5dc",
1847
+ bisque: "#ffe4c4",
1848
+ bisque1: "#ffe4c4",
1849
+ bisque2: "#eed5b7",
1850
+ bisque3: "#cdb79e",
1851
+ bisque4: "#8b7d6b",
1852
+ black: "#000000",
1853
+ blanchedalmond: "#ffebcd",
1854
+ blue: "#0000ff",
1855
+ blue1: "#0000ff",
1856
+ blue2: "#0000ee",
1857
+ blue3: "#0000cd",
1858
+ blue4: "#00008b",
1859
+ blueviolet: "#8a2be2",
1860
+ brown: "#a52a2a",
1861
+ brown1: "#ff4040",
1862
+ brown2: "#ee3b3b",
1863
+ brown3: "#cd3333",
1864
+ brown4: "#8b2323",
1865
+ burlywood: "#deb887",
1866
+ burlywood1: "#ffd39b",
1867
+ burlywood2: "#eec591",
1868
+ burlywood3: "#cdaa7d",
1869
+ burlywood4: "#8b7355",
1870
+ cadetblue: "#5f9ea0",
1871
+ cadetblue1: "#98f5ff",
1872
+ cadetblue2: "#8ee5ee",
1873
+ cadetblue3: "#7ac5cd",
1874
+ cadetblue4: "#53868b",
1875
+ chartreuse: "#7fff00",
1876
+ chartreuse1: "#7fff00",
1877
+ chartreuse2: "#76ee00",
1878
+ chartreuse3: "#66cd00",
1879
+ chartreuse4: "#458b00",
1880
+ chocolate: "#d2691e",
1881
+ chocolate1: "#ff7f24",
1882
+ chocolate2: "#ee7621",
1883
+ chocolate3: "#cd661d",
1884
+ chocolate4: "#8b4513",
1885
+ coral: "#ff7f50",
1886
+ coral1: "#ff7256",
1887
+ coral2: "#ee6a50",
1888
+ coral3: "#cd5b45",
1889
+ coral4: "#8b3e2f",
1890
+ cornflowerblue: "#6495ed",
1891
+ cornsilk: "#fff8dc",
1892
+ cornsilk1: "#fff8dc",
1893
+ cornsilk2: "#eee8cd",
1894
+ cornsilk3: "#cdc8b1",
1895
+ cornsilk4: "#8b8878",
1896
+ crimson: "#dc143c",
1897
+ cyan: "#00ffff",
1898
+ cyan1: "#00ffff",
1899
+ cyan2: "#00eeee",
1900
+ cyan3: "#00cdcd",
1901
+ cyan4: "#008b8b",
1902
+ darkblue: "#00008b",
1903
+ darkcyan: "#008b8b",
1904
+ darkgoldenrod: "#b8860b",
1905
+ darkgoldenrod1: "#ffb90f",
1906
+ darkgoldenrod2: "#eead0e",
1907
+ darkgoldenrod3: "#cd950c",
1908
+ darkgoldenrod4: "#8b6508",
1909
+ darkgray: "#a9a9a9",
1910
+ darkgreen: "#006400",
1911
+ darkgrey: "#a9a9a9",
1912
+ darkkhaki: "#bdb76b",
1913
+ darkmagenta: "#8b008b",
1914
+ darkolivegreen: "#556b2f",
1915
+ darkolivegreen1: "#caff70",
1916
+ darkolivegreen2: "#bcee68",
1917
+ darkolivegreen3: "#a2cd5a",
1918
+ darkolivegreen4: "#6e8b3d",
1919
+ darkorange: "#ff8c00",
1920
+ darkorange1: "#ff7f00",
1921
+ darkorange2: "#ee7600",
1922
+ darkorange3: "#cd6600",
1923
+ darkorange4: "#8b4500",
1924
+ darkorchid: "#9932cc",
1925
+ darkorchid1: "#bf3eff",
1926
+ darkorchid2: "#b23aee",
1927
+ darkorchid3: "#9a32cd",
1928
+ darkorchid4: "#68228b",
1929
+ darkred: "#8b0000",
1930
+ darksalmon: "#e9967a",
1931
+ darkseagreen: "#8fbc8f",
1932
+ darkseagreen1: "#c1ffc1",
1933
+ darkseagreen2: "#b4eeb4",
1934
+ darkseagreen3: "#9bcd9b",
1935
+ darkseagreen4: "#698b69",
1936
+ darkslateblue: "#483d8b",
1937
+ darkslategray: "#2f4f4f",
1938
+ darkslategray1: "#97ffff",
1939
+ darkslategray2: "#8deeee",
1940
+ darkslategray3: "#79cdcd",
1941
+ darkslategray4: "#528b8b",
1942
+ darkslategrey: "#2f4f4f",
1943
+ darkturquoise: "#00ced1",
1944
+ darkviolet: "#9400d3",
1945
+ deeppink: "#ff1493",
1946
+ deeppink1: "#ff1493",
1947
+ deeppink2: "#ee1289",
1948
+ deeppink3: "#cd1076",
1949
+ deeppink4: "#8b0a50",
1950
+ deepskyblue: "#00bfff",
1951
+ deepskyblue1: "#00bfff",
1952
+ deepskyblue2: "#00b2ee",
1953
+ deepskyblue3: "#009acd",
1954
+ deepskyblue4: "#00688b",
1955
+ dimgray: "#696969",
1956
+ dimgrey: "#696969",
1957
+ dodgerblue: "#1e90ff",
1958
+ dodgerblue1: "#1e90ff",
1959
+ dodgerblue2: "#1c86ee",
1960
+ dodgerblue3: "#1874cd",
1961
+ dodgerblue4: "#104e8b",
1962
+ firebrick: "#b22222",
1963
+ firebrick1: "#ff3030",
1964
+ firebrick2: "#ee2c2c",
1965
+ firebrick3: "#cd2626",
1966
+ firebrick4: "#8b1a1a",
1967
+ floralwhite: "#fffaf0",
1968
+ forestgreen: "#228b22",
1969
+ fuchsia: "#ff00ff",
1970
+ gainsboro: "#dcdcdc",
1971
+ ghostwhite: "#f8f8ff",
1972
+ gold: "#ffd700",
1973
+ gold1: "#ffd700",
1974
+ gold2: "#eec900",
1975
+ gold3: "#cdad00",
1976
+ gold4: "#8b7500",
1977
+ goldenrod: "#daa520",
1978
+ goldenrod1: "#ffc125",
1979
+ goldenrod2: "#eeb422",
1980
+ goldenrod3: "#cd9b1d",
1981
+ goldenrod4: "#8b6914",
1982
+ gray: "#c0c0c0",
1983
+ gray0: "#000000",
1984
+ gray1: "#030303",
1985
+ gray10: "#1a1a1a",
1986
+ gray100: "#ffffff",
1987
+ gray11: "#1c1c1c",
1988
+ gray12: "#1f1f1f",
1989
+ gray13: "#212121",
1990
+ gray14: "#242424",
1991
+ gray15: "#262626",
1992
+ gray16: "#292929",
1993
+ gray17: "#2b2b2b",
1994
+ gray18: "#2e2e2e",
1995
+ gray19: "#303030",
1996
+ gray2: "#050505",
1997
+ gray20: "#333333",
1998
+ gray21: "#363636",
1999
+ gray22: "#383838",
2000
+ gray23: "#3b3b3b",
2001
+ gray24: "#3d3d3d",
2002
+ gray25: "#404040",
2003
+ gray26: "#424242",
2004
+ gray27: "#454545",
2005
+ gray28: "#474747",
2006
+ gray29: "#4a4a4a",
2007
+ gray3: "#080808",
2008
+ gray30: "#4d4d4d",
2009
+ gray31: "#4f4f4f",
2010
+ gray32: "#525252",
2011
+ gray33: "#545454",
2012
+ gray34: "#575757",
2013
+ gray35: "#595959",
2014
+ gray36: "#5c5c5c",
2015
+ gray37: "#5e5e5e",
2016
+ gray38: "#616161",
2017
+ gray39: "#636363",
2018
+ gray4: "#0a0a0a",
2019
+ gray40: "#666666",
2020
+ gray41: "#696969",
2021
+ gray42: "#6b6b6b",
2022
+ gray43: "#6e6e6e",
2023
+ gray44: "#707070",
2024
+ gray45: "#737373",
2025
+ gray46: "#757575",
2026
+ gray47: "#787878",
2027
+ gray48: "#7a7a7a",
2028
+ gray49: "#7d7d7d",
2029
+ gray5: "#0d0d0d",
2030
+ gray50: "#7f7f7f",
2031
+ gray51: "#828282",
2032
+ gray52: "#858585",
2033
+ gray53: "#878787",
2034
+ gray54: "#8a8a8a",
2035
+ gray55: "#8c8c8c",
2036
+ gray56: "#8f8f8f",
2037
+ gray57: "#919191",
2038
+ gray58: "#949494",
2039
+ gray59: "#969696",
2040
+ gray6: "#0f0f0f",
2041
+ gray60: "#999999",
2042
+ gray61: "#9c9c9c",
2043
+ gray62: "#9e9e9e",
2044
+ gray63: "#a1a1a1",
2045
+ gray64: "#a3a3a3",
2046
+ gray65: "#a6a6a6",
2047
+ gray66: "#a8a8a8",
2048
+ gray67: "#ababab",
2049
+ gray68: "#adadad",
2050
+ gray69: "#b0b0b0",
2051
+ gray7: "#121212",
2052
+ gray70: "#b3b3b3",
2053
+ gray71: "#b5b5b5",
2054
+ gray72: "#b8b8b8",
2055
+ gray73: "#bababa",
2056
+ gray74: "#bdbdbd",
2057
+ gray75: "#bfbfbf",
2058
+ gray76: "#c2c2c2",
2059
+ gray77: "#c4c4c4",
2060
+ gray78: "#c7c7c7",
2061
+ gray79: "#c9c9c9",
2062
+ gray8: "#141414",
2063
+ gray80: "#cccccc",
2064
+ gray81: "#cfcfcf",
2065
+ gray82: "#d1d1d1",
2066
+ gray83: "#d4d4d4",
2067
+ gray84: "#d6d6d6",
2068
+ gray85: "#d9d9d9",
2069
+ gray86: "#dbdbdb",
2070
+ gray87: "#dedede",
2071
+ gray88: "#e0e0e0",
2072
+ gray89: "#e3e3e3",
2073
+ gray9: "#171717",
2074
+ gray90: "#e5e5e5",
2075
+ gray91: "#e8e8e8",
2076
+ gray92: "#ebebeb",
2077
+ gray93: "#ededed",
2078
+ gray94: "#f0f0f0",
2079
+ gray95: "#f2f2f2",
2080
+ gray96: "#f5f5f5",
2081
+ gray97: "#f7f7f7",
2082
+ gray98: "#fafafa",
2083
+ gray99: "#fcfcfc",
2084
+ green: "#00ff00",
2085
+ green1: "#00ff00",
2086
+ green2: "#00ee00",
2087
+ green3: "#00cd00",
2088
+ green4: "#008b00",
2089
+ greenyellow: "#adff2f",
2090
+ grey: "#c0c0c0",
2091
+ grey0: "#000000",
2092
+ grey1: "#030303",
2093
+ grey10: "#1a1a1a",
2094
+ grey100: "#ffffff",
2095
+ grey11: "#1c1c1c",
2096
+ grey12: "#1f1f1f",
2097
+ grey13: "#212121",
2098
+ grey14: "#242424",
2099
+ grey15: "#262626",
2100
+ grey16: "#292929",
2101
+ grey17: "#2b2b2b",
2102
+ grey18: "#2e2e2e",
2103
+ grey19: "#303030",
2104
+ grey2: "#050505",
2105
+ grey20: "#333333",
2106
+ grey21: "#363636",
2107
+ grey22: "#383838",
2108
+ grey23: "#3b3b3b",
2109
+ grey24: "#3d3d3d",
2110
+ grey25: "#404040",
2111
+ grey26: "#424242",
2112
+ grey27: "#454545",
2113
+ grey28: "#474747",
2114
+ grey29: "#4a4a4a",
2115
+ grey3: "#080808",
2116
+ grey30: "#4d4d4d",
2117
+ grey31: "#4f4f4f",
2118
+ grey32: "#525252",
2119
+ grey33: "#545454",
2120
+ grey34: "#575757",
2121
+ grey35: "#595959",
2122
+ grey36: "#5c5c5c",
2123
+ grey37: "#5e5e5e",
2124
+ grey38: "#616161",
2125
+ grey39: "#636363",
2126
+ grey4: "#0a0a0a",
2127
+ grey40: "#666666",
2128
+ grey41: "#696969",
2129
+ grey42: "#6b6b6b",
2130
+ grey43: "#6e6e6e",
2131
+ grey44: "#707070",
2132
+ grey45: "#737373",
2133
+ grey46: "#757575",
2134
+ grey47: "#787878",
2135
+ grey48: "#7a7a7a",
2136
+ grey49: "#7d7d7d",
2137
+ grey5: "#0d0d0d",
2138
+ grey50: "#7f7f7f",
2139
+ grey51: "#828282",
2140
+ grey52: "#858585",
2141
+ grey53: "#878787",
2142
+ grey54: "#8a8a8a",
2143
+ grey55: "#8c8c8c",
2144
+ grey56: "#8f8f8f",
2145
+ grey57: "#919191",
2146
+ grey58: "#949494",
2147
+ grey59: "#969696",
2148
+ grey6: "#0f0f0f",
2149
+ grey60: "#999999",
2150
+ grey61: "#9c9c9c",
2151
+ grey62: "#9e9e9e",
2152
+ grey63: "#a1a1a1",
2153
+ grey64: "#a3a3a3",
2154
+ grey65: "#a6a6a6",
2155
+ grey66: "#a8a8a8",
2156
+ grey67: "#ababab",
2157
+ grey68: "#adadad",
2158
+ grey69: "#b0b0b0",
2159
+ grey7: "#121212",
2160
+ grey70: "#b3b3b3",
2161
+ grey71: "#b5b5b5",
2162
+ grey72: "#b8b8b8",
2163
+ grey73: "#bababa",
2164
+ grey74: "#bdbdbd",
2165
+ grey75: "#bfbfbf",
2166
+ grey76: "#c2c2c2",
2167
+ grey77: "#c4c4c4",
2168
+ grey78: "#c7c7c7",
2169
+ grey79: "#c9c9c9",
2170
+ grey8: "#141414",
2171
+ grey80: "#cccccc",
2172
+ grey81: "#cfcfcf",
2173
+ grey82: "#d1d1d1",
2174
+ grey83: "#d4d4d4",
2175
+ grey84: "#d6d6d6",
2176
+ grey85: "#d9d9d9",
2177
+ grey86: "#dbdbdb",
2178
+ grey87: "#dedede",
2179
+ grey88: "#e0e0e0",
2180
+ grey89: "#e3e3e3",
2181
+ grey9: "#171717",
2182
+ grey90: "#e5e5e5",
2183
+ grey91: "#e8e8e8",
2184
+ grey92: "#ebebeb",
2185
+ grey93: "#ededed",
2186
+ grey94: "#f0f0f0",
2187
+ grey95: "#f2f2f2",
2188
+ grey96: "#f5f5f5",
2189
+ grey97: "#f7f7f7",
2190
+ grey98: "#fafafa",
2191
+ grey99: "#fcfcfc",
2192
+ honeydew: "#f0fff0",
2193
+ honeydew1: "#f0fff0",
2194
+ honeydew2: "#e0eee0",
2195
+ honeydew3: "#c1cdc1",
2196
+ honeydew4: "#838b83",
2197
+ hotpink: "#ff69b4",
2198
+ hotpink1: "#ff6eb4",
2199
+ hotpink2: "#ee6aa7",
2200
+ hotpink3: "#cd6090",
2201
+ hotpink4: "#8b3a62",
2202
+ indianred: "#cd5c5c",
2203
+ indianred1: "#ff6a6a",
2204
+ indianred2: "#ee6363",
2205
+ indianred3: "#cd5555",
2206
+ indianred4: "#8b3a3a",
2207
+ indigo: "#4b0082",
2208
+ invis: "#fffffe",
2209
+ ivory: "#fffff0",
2210
+ ivory1: "#fffff0",
2211
+ ivory2: "#eeeee0",
2212
+ ivory3: "#cdcdc1",
2213
+ ivory4: "#8b8b83",
2214
+ khaki: "#f0e68c",
2215
+ khaki1: "#fff68f",
2216
+ khaki2: "#eee685",
2217
+ khaki3: "#cdc673",
2218
+ khaki4: "#8b864e",
2219
+ lavender: "#e6e6fa",
2220
+ lavenderblush: "#fff0f5",
2221
+ lavenderblush1: "#fff0f5",
2222
+ lavenderblush2: "#eee0e5",
2223
+ lavenderblush3: "#cdc1c5",
2224
+ lavenderblush4: "#8b8386",
2225
+ lawngreen: "#7cfc00",
2226
+ lemonchiffon: "#fffacd",
2227
+ lemonchiffon1: "#fffacd",
2228
+ lemonchiffon2: "#eee9bf",
2229
+ lemonchiffon3: "#cdc9a5",
2230
+ lemonchiffon4: "#8b8970",
2231
+ lightblue: "#add8e6",
2232
+ lightblue1: "#bfefff",
2233
+ lightblue2: "#b2dfee",
2234
+ lightblue3: "#9ac0cd",
2235
+ lightblue4: "#68838b",
2236
+ lightcoral: "#f08080",
2237
+ lightcyan: "#e0ffff",
2238
+ lightcyan1: "#e0ffff",
2239
+ lightcyan2: "#d1eeee",
2240
+ lightcyan3: "#b4cdcd",
2241
+ lightcyan4: "#7a8b8b",
2242
+ lightgoldenrod: "#eedd82",
2243
+ lightgoldenrod1: "#ffec8b",
2244
+ lightgoldenrod2: "#eedc82",
2245
+ lightgoldenrod3: "#cdbe70",
2246
+ lightgoldenrod4: "#8b814c",
2247
+ lightgoldenrodyellow: "#fafad2",
2248
+ lightgray: "#d3d3d3",
2249
+ lightgreen: "#90ee90",
2250
+ lightgrey: "#d3d3d3",
2251
+ lightpink: "#ffb6c1",
2252
+ lightpink1: "#ffaeb9",
2253
+ lightpink2: "#eea2ad",
2254
+ lightpink3: "#cd8c95",
2255
+ lightpink4: "#8b5f65",
2256
+ lightsalmon: "#ffa07a",
2257
+ lightsalmon1: "#ffa07a",
2258
+ lightsalmon2: "#ee9572",
2259
+ lightsalmon3: "#cd8162",
2260
+ lightsalmon4: "#8b5742",
2261
+ lightseagreen: "#20b2aa",
2262
+ lightskyblue: "#87cefa",
2263
+ lightskyblue1: "#b0e2ff",
2264
+ lightskyblue2: "#a4d3ee",
2265
+ lightskyblue3: "#8db6cd",
2266
+ lightskyblue4: "#607b8b",
2267
+ lightslateblue: "#8470ff",
2268
+ lightslategray: "#778899",
2269
+ lightslategrey: "#778899",
2270
+ lightsteelblue: "#b0c4de",
2271
+ lightsteelblue1: "#cae1ff",
2272
+ lightsteelblue2: "#bcd2ee",
2273
+ lightsteelblue3: "#a2b5cd",
2274
+ lightsteelblue4: "#6e7b8b",
2275
+ lightyellow: "#ffffe0",
2276
+ lightyellow1: "#ffffe0",
2277
+ lightyellow2: "#eeeed1",
2278
+ lightyellow3: "#cdcdb4",
2279
+ lightyellow4: "#8b8b7a",
2280
+ lime: "#00ff00",
2281
+ limegreen: "#32cd32",
2282
+ linen: "#faf0e6",
2283
+ magenta: "#ff00ff",
2284
+ magenta1: "#ff00ff",
2285
+ magenta2: "#ee00ee",
2286
+ magenta3: "#cd00cd",
2287
+ magenta4: "#8b008b",
2288
+ maroon: "#b03060",
2289
+ maroon1: "#ff34b3",
2290
+ maroon2: "#ee30a7",
2291
+ maroon3: "#cd2990",
2292
+ maroon4: "#8b1c62",
2293
+ mediumaquamarine: "#66cdaa",
2294
+ mediumblue: "#0000cd",
2295
+ mediumorchid: "#ba55d3",
2296
+ mediumorchid1: "#e066ff",
2297
+ mediumorchid2: "#d15fee",
2298
+ mediumorchid3: "#b452cd",
2299
+ mediumorchid4: "#7a378b",
2300
+ mediumpurple: "#9370db",
2301
+ mediumpurple1: "#ab82ff",
2302
+ mediumpurple2: "#9f79ee",
2303
+ mediumpurple3: "#8968cd",
2304
+ mediumpurple4: "#5d478b",
2305
+ mediumseagreen: "#3cb371",
2306
+ mediumslateblue: "#7b68ee",
2307
+ mediumspringgreen: "#00fa9a",
2308
+ mediumturquoise: "#48d1cc",
2309
+ mediumvioletred: "#c71585",
2310
+ midnightblue: "#191970",
2311
+ mintcream: "#f5fffa",
2312
+ mistyrose: "#ffe4e1",
2313
+ mistyrose1: "#ffe4e1",
2314
+ mistyrose2: "#eed5d2",
2315
+ mistyrose3: "#cdb7b5",
2316
+ mistyrose4: "#8b7d7b",
2317
+ moccasin: "#ffe4b5",
2318
+ navajowhite: "#ffdead",
2319
+ navajowhite1: "#ffdead",
2320
+ navajowhite2: "#eecfa1",
2321
+ navajowhite3: "#cdb38b",
2322
+ navajowhite4: "#8b795e",
2323
+ navy: "#000080",
2324
+ navyblue: "#000080",
2325
+ none: "#fffffe",
2326
+ oldlace: "#fdf5e6",
2327
+ olive: "#808000",
2328
+ olivedrab: "#6b8e23",
2329
+ olivedrab1: "#c0ff3e",
2330
+ olivedrab2: "#b3ee3a",
2331
+ olivedrab3: "#9acd32",
2332
+ olivedrab4: "#698b22",
2333
+ orange: "#ffa500",
2334
+ orange1: "#ffa500",
2335
+ orange2: "#ee9a00",
2336
+ orange3: "#cd8500",
2337
+ orange4: "#8b5a00",
2338
+ orangered: "#ff4500",
2339
+ orangered1: "#ff4500",
2340
+ orangered2: "#ee4000",
2341
+ orangered3: "#cd3700",
2342
+ orangered4: "#8b2500",
2343
+ orchid: "#da70d6",
2344
+ orchid1: "#ff83fa",
2345
+ orchid2: "#ee7ae9",
2346
+ orchid3: "#cd69c9",
2347
+ orchid4: "#8b4789",
2348
+ palegoldenrod: "#eee8aa",
2349
+ palegreen: "#98fb98",
2350
+ palegreen1: "#9aff9a",
2351
+ palegreen2: "#90ee90",
2352
+ palegreen3: "#7ccd7c",
2353
+ palegreen4: "#548b54",
2354
+ paleturquoise: "#afeeee",
2355
+ paleturquoise1: "#bbffff",
2356
+ paleturquoise2: "#aeeeee",
2357
+ paleturquoise3: "#96cdcd",
2358
+ paleturquoise4: "#668b8b",
2359
+ palevioletred: "#db7093",
2360
+ palevioletred1: "#ff82ab",
2361
+ palevioletred2: "#ee799f",
2362
+ palevioletred3: "#cd6889",
2363
+ palevioletred4: "#8b475d",
2364
+ papayawhip: "#ffefd5",
2365
+ peachpuff: "#ffdab9",
2366
+ peachpuff1: "#ffdab9",
2367
+ peachpuff2: "#eecbad",
2368
+ peachpuff3: "#cdaf95",
2369
+ peachpuff4: "#8b7765",
2370
+ peru: "#cd853f",
2371
+ pink: "#ffc0cb",
2372
+ pink1: "#ffb5c5",
2373
+ pink2: "#eea9b8",
2374
+ pink3: "#cd919e",
2375
+ pink4: "#8b636c",
2376
+ plum: "#dda0dd",
2377
+ plum1: "#ffbbff",
2378
+ plum2: "#eeaeee",
2379
+ plum3: "#cd96cd",
2380
+ plum4: "#8b668b",
2381
+ powderblue: "#b0e0e6",
2382
+ purple: "#a020f0",
2383
+ purple1: "#9b30ff",
2384
+ purple2: "#912cee",
2385
+ purple3: "#7d26cd",
2386
+ purple4: "#551a8b",
2387
+ rebeccapurple: "#663399",
2388
+ red: "#ff0000",
2389
+ red1: "#ff0000",
2390
+ red2: "#ee0000",
2391
+ red3: "#cd0000",
2392
+ red4: "#8b0000",
2393
+ rosybrown: "#bc8f8f",
2394
+ rosybrown1: "#ffc1c1",
2395
+ rosybrown2: "#eeb4b4",
2396
+ rosybrown3: "#cd9b9b",
2397
+ rosybrown4: "#8b6969",
2398
+ royalblue: "#4169e1",
2399
+ royalblue1: "#4876ff",
2400
+ royalblue2: "#436eee",
2401
+ royalblue3: "#3a5fcd",
2402
+ royalblue4: "#27408b",
2403
+ saddlebrown: "#8b4513",
2404
+ salmon: "#fa8072",
2405
+ salmon1: "#ff8c69",
2406
+ salmon2: "#ee8262",
2407
+ salmon3: "#cd7054",
2408
+ salmon4: "#8b4c39",
2409
+ sandybrown: "#f4a460",
2410
+ seagreen: "#2e8b57",
2411
+ seagreen1: "#54ff9f",
2412
+ seagreen2: "#4eee94",
2413
+ seagreen3: "#43cd80",
2414
+ seagreen4: "#2e8b57",
2415
+ seashell: "#fff5ee",
2416
+ seashell1: "#fff5ee",
2417
+ seashell2: "#eee5de",
2418
+ seashell3: "#cdc5bf",
2419
+ seashell4: "#8b8682",
2420
+ sienna: "#a0522d",
2421
+ sienna1: "#ff8247",
2422
+ sienna2: "#ee7942",
2423
+ sienna3: "#cd6839",
2424
+ sienna4: "#8b4726",
2425
+ silver: "#c0c0c0",
2426
+ skyblue: "#87ceeb",
2427
+ skyblue1: "#87ceff",
2428
+ skyblue2: "#7ec0ee",
2429
+ skyblue3: "#6ca6cd",
2430
+ skyblue4: "#4a708b",
2431
+ slateblue: "#6a5acd",
2432
+ slateblue1: "#836fff",
2433
+ slateblue2: "#7a67ee",
2434
+ slateblue3: "#6959cd",
2435
+ slateblue4: "#473c8b",
2436
+ slategray: "#708090",
2437
+ slategray1: "#c6e2ff",
2438
+ slategray2: "#b9d3ee",
2439
+ slategray3: "#9fb6cd",
2440
+ slategray4: "#6c7b8b",
2441
+ slategrey: "#708090",
2442
+ snow: "#fffafa",
2443
+ snow1: "#fffafa",
2444
+ snow2: "#eee9e9",
2445
+ snow3: "#cdc9c9",
2446
+ snow4: "#8b8989",
2447
+ springgreen: "#00ff7f",
2448
+ springgreen1: "#00ff7f",
2449
+ springgreen2: "#00ee76",
2450
+ springgreen3: "#00cd66",
2451
+ springgreen4: "#008b45",
2452
+ steelblue: "#4682b4",
2453
+ steelblue1: "#63b8ff",
2454
+ steelblue2: "#5cacee",
2455
+ steelblue3: "#4f94cd",
2456
+ steelblue4: "#36648b",
2457
+ tan: "#d2b48c",
2458
+ tan1: "#ffa54f",
2459
+ tan2: "#ee9a49",
2460
+ tan3: "#cd853f",
2461
+ tan4: "#8b5a2b",
2462
+ teal: "#008080",
2463
+ thistle: "#d8bfd8",
2464
+ thistle1: "#ffe1ff",
2465
+ thistle2: "#eed2ee",
2466
+ thistle3: "#cdb5cd",
2467
+ thistle4: "#8b7b8b",
2468
+ tomato: "#ff6347",
2469
+ tomato1: "#ff6347",
2470
+ tomato2: "#ee5c42",
2471
+ tomato3: "#cd4f39",
2472
+ tomato4: "#8b3626",
2473
+ transparent: "#fffffe",
2474
+ turquoise: "#40e0d0",
2475
+ turquoise1: "#00f5ff",
2476
+ turquoise2: "#00e5ee",
2477
+ turquoise3: "#00c5cd",
2478
+ turquoise4: "#00868b",
2479
+ violet: "#ee82ee",
2480
+ violetred: "#d02090",
2481
+ violetred1: "#ff3e96",
2482
+ violetred2: "#ee3a8c",
2483
+ violetred3: "#cd3278",
2484
+ violetred4: "#8b2252",
2485
+ webgray: "#808080",
2486
+ webgreen: "#008000",
2487
+ webgrey: "#808080",
2488
+ webmaroon: "#800000",
2489
+ webpurple: "#800080",
2490
+ wheat: "#f5deb3",
2491
+ wheat1: "#ffe7ba",
2492
+ wheat2: "#eed8ae",
2493
+ wheat3: "#cdba96",
2494
+ wheat4: "#8b7e66",
2495
+ white: "#ffffff",
2496
+ whitesmoke: "#f5f5f5",
2497
+ x11gray: "#bebebe",
2498
+ x11green: "#00ff00",
2499
+ x11grey: "#bebebe",
2500
+ x11maroon: "#b03060",
2501
+ x11purple: "#a020f0",
2502
+ yellow: "#ffff00",
2503
+ yellow1: "#ffff00",
2504
+ yellow2: "#eeee00",
2505
+ yellow3: "#cdcd00",
2506
+ yellow4: "#8b8b00",
2507
+ yellowgreen: "#9acd32"
2508
+ });
2509
+
2510
+ // src/visitor.ts
2511
+ function visitNode(cbNode, node) {
2512
+ return node && cbNode(node);
2513
+ }
2514
+ function visitNodes(cbNode, cbNodes, nodes) {
2515
+ if (nodes) {
2516
+ if (cbNodes) return cbNodes(nodes);
2517
+ for (const node of nodes) {
2518
+ const result = cbNode(node);
2519
+ if (result) return result;
2520
+ }
2521
+ }
2522
+ return void 0;
2523
+ }
2524
+ function forEachChild(node, cbNode, cbNodes) {
2525
+ if (!node || node.kind <= 38 /* LastKeyword */) return;
2526
+ switch (node.kind) {
2527
+ case 41 /* DirectedGraph */:
2528
+ case 42 /* UndirectedGraph */:
2529
+ return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.strict) || visitNode(cbNode, node.id);
2530
+ case 45 /* AttributeStatement */:
2531
+ return visitNodes(cbNode, cbNodes, node.attributes) || visitNode(cbNode, node.subject) || visitNode(cbNode, node.terminator);
2532
+ case 44 /* EdgeStatement */:
2533
+ return visitNodes(cbNode, cbNodes, node.attributes) || visitNodes(cbNode, cbNodes, node.rhs) || visitNode(cbNode, node.source) || visitNode(cbNode, node.terminator);
2534
+ case 43 /* NodeStatement */:
2535
+ return visitNodes(cbNode, cbNodes, node.attributes) || visitNode(cbNode, node.id) || visitNode(cbNode, node.terminator);
2536
+ case 47 /* SubGraph */:
2537
+ return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.id);
2538
+ case 48 /* SubGraphStatement */:
2539
+ return visitNode(cbNode, node.subgraph) || visitNode(cbNode, node.terminator);
2540
+ case 46 /* IdEqualsIdStatement */:
2541
+ return visitNode(cbNode, node.leftId) || visitNode(cbNode, node.rightId) || visitNode(cbNode, node.terminator);
2542
+ case 31 /* QuotedTextIdentifier */:
2543
+ return visitNodes(cbNode, cbNodes, node.values);
2544
+ case 49 /* EdgeRhs */:
2545
+ return visitNode(cbNode, node.operation) || visitNode(cbNode, node.target);
2546
+ case 50 /* AttributeContainer */:
2547
+ return visitNodes(cbNode, cbNodes, node.assignments);
2548
+ case 51 /* Assignment */:
2549
+ return visitNode(cbNode, node.leftId) || visitNode(cbNode, node.rightId) || visitNode(cbNode, node.terminator);
2550
+ case 52 /* NormalPortDeclaration */:
2551
+ return visitNode(cbNode, node.colon) || visitNode(cbNode, node.id) || visitNode(cbNode, node.compassPt);
2552
+ case 53 /* CompassPortDeclaration */:
2553
+ return visitNode(cbNode, node.colon) || visitNode(cbNode, node.compassPt);
2554
+ case 54 /* NodeId */:
2555
+ return visitNode(cbNode, node.port) || visitNode(cbNode, node.id);
2556
+ default:
2557
+ return void 0;
2558
+ }
2559
+ }
2560
+
2561
+ // src/checker.ts
2562
+ function checkSourceFile(file) {
2563
+ const g = file.graph;
2564
+ if (g) {
2565
+ const messages = checkGraphSemantics(file, g);
2566
+ if (messages) {
2567
+ file.diagnostics.push.apply(file.diagnostics, messages);
2568
+ }
2569
+ }
2570
+ }
2571
+ function rangeContainsOffset(range, offset, inclusiveEnd) {
2572
+ return inclusiveEnd ? range.pos <= offset && offset <= range.end : range.pos <= offset && offset < range.end;
2573
+ }
2574
+ function findNodeAtOffset(root, offset, inclusiveEnd = false) {
2575
+ if (root.pos === offset && root.pos === root.end) return root;
2576
+ if (rangeContainsOffset(root, offset, inclusiveEnd)) {
2577
+ const narrowerChild = forEachChild(
2578
+ root,
2579
+ (child) => findNodeAtOffset(child, offset, inclusiveEnd)
2580
+ );
2581
+ return narrowerChild ? narrowerChild : root;
2582
+ }
2583
+ return void 0;
2584
+ }
2585
+ function getAllowedEdgeOperation(graph) {
2586
+ return graph.kind === 41 /* DirectedGraph */ ? 39 /* DirectedEdgeOp */ : 40 /* UndirectedEdgeOp */;
2587
+ }
2588
+ function checkGraphSemantics(file, root) {
2589
+ const expectedEdgeOp = getAllowedEdgeOperation(root);
2590
+ const invalidEdgeRhses = findEdgeErrors(expectedEdgeOp, root);
2591
+ const invalidShapes = checkShapeLabelValues(root);
2592
+ const invalidEdgeDiagnostics = invalidEdgeRhses === void 0 || invalidEdgeRhses.length === 0 ? [] : createEdgeViolationDiagnostics(file, expectedEdgeOp, invalidEdgeRhses);
2593
+ return [...invalidEdgeDiagnostics, ...invalidShapes];
2594
+ }
2595
+ function forEachAssignmentTransitive(root, cb) {
2596
+ forEachChild(root, (child) => {
2597
+ if (child.kind === 51 /* Assignment */) {
2598
+ cb(child);
2599
+ return;
2600
+ }
2601
+ forEachChild(child, (c) => forEachAssignmentTransitive(c, cb));
2602
+ });
2603
+ }
2604
+ function checkShapeLabelValues(root) {
2605
+ const invalidShapes = [];
2606
+ forEachAssignmentTransitive(root, (assignment) => {
2607
+ const { leftId, rightId } = assignment;
2608
+ if (leftId.kind !== 30 /* TextIdentifier */ || rightId.kind !== 30 /* TextIdentifier */) {
2609
+ return;
2610
+ }
2611
+ const leftText = leftId.text.trim();
2612
+ if (leftText.toLocaleLowerCase() !== "shape") {
2613
+ return;
2614
+ }
2615
+ const rightText = rightId.text.trim();
2616
+ const shapeCandidate = rightText.toLowerCase();
2617
+ if (shapes.includes(shapeCandidate)) {
2618
+ return;
2619
+ }
2620
+ invalidShapes.push({
2621
+ category: 2 /* Warning */,
2622
+ code: createCheckerError(1 /* InvalidShapeName */),
2623
+ message: `Unknown shape "${rightText}".`,
2624
+ start: rightId.pos,
2625
+ end: rightId.end
2626
+ });
2627
+ });
2628
+ return invalidShapes;
2629
+ }
2630
+ function findAllEdges(node) {
2631
+ const allEdges = [];
2632
+ forEachChild(node, (child) => {
2633
+ if (isEdgeStatement(child)) {
2634
+ if (child.rhs && child.rhs.length > 0) {
2635
+ for (const edgeRhs of child.rhs) allEdges.push(edgeRhs);
2636
+ }
2637
+ }
2638
+ const childEdges = findAllEdges(child);
2639
+ if (childEdges && childEdges.length > 0) allEdges.push.apply(allEdges, childEdges);
2640
+ });
2641
+ return allEdges;
2642
+ }
2643
+ function findOptionalSemicolons(node) {
2644
+ const statements = findAllStatements(node);
2645
+ const terminators = statements.map((p) => p.terminator);
2646
+ return terminators.filter((t) => !!t);
2647
+ }
2648
+ function isStatement(node) {
2649
+ return node.kind === 48 /* SubGraphStatement */ || node.kind === 44 /* EdgeStatement */ || node.kind === 43 /* NodeStatement */ || node.kind === 46 /* IdEqualsIdStatement */ || node.kind === 45 /* AttributeStatement */;
2650
+ }
2651
+ function findAllStatements(node, kind) {
2652
+ const allStatements = [];
2653
+ forEachChild(node, (child) => {
2654
+ if (kind === void 0 && isStatement(child) || child.kind === kind) {
2655
+ allStatements.push(child);
2656
+ }
2657
+ const childStatements = findAllStatements(child, kind);
2658
+ if (childStatements && childStatements.length > 0)
2659
+ allStatements.push.apply(allStatements, childStatements);
2660
+ });
2661
+ return allStatements;
2662
+ }
2663
+ function findEdgeErrors(expectedEdgeOp, node) {
2664
+ const edges = findAllEdges(node);
2665
+ const wrongEdges = edges && edges.length > 0 ? edges.filter((e) => e.operation.kind !== expectedEdgeOp) : void 0;
2666
+ if (wrongEdges && wrongEdges.length > 0) {
2667
+ for (const edge of wrongEdges) {
2668
+ edge.operation.flags |= 2 /* ContainsErrors */;
2669
+ }
2670
+ return wrongEdges;
2671
+ }
2672
+ return void 0;
2673
+ }
2674
+ function createEdgeViolationDiagnostics(file, expectedEdgeOp, violators) {
2675
+ const op = expectedEdgeOp === 40 /* UndirectedEdgeOp */ ? "--" : "->";
2676
+ const graphType = expectedEdgeOp === 40 /* UndirectedEdgeOp */ ? "undirected" : "directed";
2677
+ const message = `Invalid edge operation, use "${op}" in ${graphType} graph`;
2678
+ const code = createCheckerError(0 /* InvalidEdgeOperation */);
2679
+ const category = 1 /* Error */;
2680
+ for (const edge of violators) {
2681
+ edge.operation.flags |= 2 /* ContainsErrors */;
2682
+ }
2683
+ return violators.map((edge) => {
2684
+ const start = getStart(file, edge.operation);
2685
+ const end = edge.operation.end;
2686
+ return {
2687
+ message,
2688
+ code,
2689
+ category,
2690
+ start,
2691
+ end
2692
+ };
2693
+ });
2694
+ }
2695
+ function isAttrStatement(node) {
2696
+ return node.kind === 45 /* AttributeStatement */;
2697
+ }
2698
+ function isEdgeStatement(node) {
2699
+ return node.kind === 44 /* EdgeStatement */;
2700
+ }
2701
+ function isNodeId(node) {
2702
+ return node.kind === 54 /* NodeId */;
2703
+ }
2704
+ function edgeStatementHasAttributes(es) {
2705
+ return es.attributes && es.attributes.length > 0 && es.attributes.some((a) => a.assignments && a.assignments.length > 0);
2706
+ }
2707
+ function getIdentifierText(n) {
2708
+ switch (n.kind) {
2709
+ case 29 /* HtmlIdentifier */:
2710
+ return n.htmlContent;
2711
+ case 30 /* TextIdentifier */:
2712
+ return n.text;
2713
+ case 32 /* NumericIdentifier */:
2714
+ return n.text;
2715
+ case 31 /* QuotedTextIdentifier */:
2716
+ return n.concatenation;
2717
+ // Assertion because concatenation is filled in binding step
2718
+ default:
2719
+ return assertNever(n);
2720
+ }
2721
+ }
2722
+ function createCheckerError(sub) {
2723
+ return {
2724
+ source: 4 /* Check */,
2725
+ sub
2726
+ };
2727
+ }
2728
+ function nodeContainsErrors(node) {
2729
+ return (node.flags & 2 /* ContainsErrors */) === 2 /* ContainsErrors */;
2730
+ }
2731
+
2732
+ // src/binder.ts
2733
+ var binder = createBinder();
2734
+ function bindSourceFile(file) {
2735
+ binder.bind(file);
2736
+ }
2737
+ function createBinder() {
2738
+ let parent;
2739
+ let symbolTable;
2740
+ let colorTable;
2741
+ let graphContext = 0 /* None */;
2742
+ function bind(node) {
2743
+ if (!node) return;
2744
+ const saveParent = parent;
2745
+ const saveContext = graphContext;
2746
+ node.parent = saveParent;
2747
+ node.graphContext = saveContext;
2748
+ parent = node;
2749
+ innerBind(node);
2750
+ parent = saveParent;
2751
+ graphContext = saveContext;
2752
+ }
2753
+ function innerBind(node) {
2754
+ switch (node.kind) {
2755
+ case 41 /* DirectedGraph */:
2756
+ case 42 /* UndirectedGraph */:
2757
+ return bindGraph(node);
2758
+ case 45 /* AttributeStatement */:
2759
+ return bindAttributeStatement(node);
2760
+ case 44 /* EdgeStatement */:
2761
+ return bindEdgeStatement(node);
2762
+ case 43 /* NodeStatement */:
2763
+ return bindNodeStatement(node);
2764
+ case 47 /* SubGraph */:
2765
+ return bindSubGraph(node);
2766
+ case 48 /* SubGraphStatement */:
2767
+ return bindSubGraphStatement(node);
2768
+ case 46 /* IdEqualsIdStatement */:
2769
+ return bindIdEqualsIdStatement(node);
2770
+ case 31 /* QuotedTextIdentifier */:
2771
+ return bindQuotedTextIdentifier(node);
2772
+ case 49 /* EdgeRhs */:
2773
+ return bindEdgeRhs(node);
2774
+ case 50 /* AttributeContainer */:
2775
+ return bindAttributeContainer(node);
2776
+ case 51 /* Assignment */:
2777
+ return bindAssignment(node);
2778
+ case 52 /* NormalPortDeclaration */:
2779
+ return bindNormalPortDeclaration(node);
2780
+ case 53 /* CompassPortDeclaration */:
2781
+ return bindCompassPortDeclaration(node);
2782
+ case 54 /* NodeId */:
2783
+ return bindNodeId(node);
2784
+ default:
2785
+ if (node.kind >= 41 /* FirstNode */) throw "TODO";
2786
+ }
2787
+ }
2788
+ function bindGraph(node) {
2789
+ if (node.strict) {
2790
+ graphContext |= 2 /* Strict */;
2791
+ }
2792
+ switch (node.kind) {
2793
+ case 41 /* DirectedGraph */:
2794
+ graphContext |= 4 /* Directed */;
2795
+ break;
2796
+ case 42 /* UndirectedGraph */:
2797
+ graphContext |= 8 /* Undirected */;
2798
+ break;
2799
+ }
2800
+ if (node.id) {
2801
+ ensureGlobalSymbol(node.id);
2802
+ bind(node.id);
2803
+ }
2804
+ if (node.strict) bind(node.strict);
2805
+ bindChildren(node.statements);
2806
+ }
2807
+ function bindAttributeStatement(node) {
2808
+ bind(node.subject);
2809
+ bindChildren(node.attributes);
2810
+ if (node.terminator) bind(node.terminator);
2811
+ }
2812
+ function bindEdgeStatement(node) {
2813
+ bindChildren(node.attributes);
2814
+ bindChildren(node.rhs);
2815
+ bind(node.source);
2816
+ if (node.terminator) bind(node.terminator);
2817
+ }
2818
+ function bindNodeStatement(node) {
2819
+ bind(node.id);
2820
+ bindChildren(node.attributes);
2821
+ if (node.terminator) bind(node.terminator);
2822
+ }
2823
+ function bindSubGraph(node) {
2824
+ if (node.id) {
2825
+ bind(node.id);
2826
+ }
2827
+ bindChildren(node.statements);
2828
+ }
2829
+ function bindSubGraphStatement(node) {
2830
+ bind(node.subgraph);
2831
+ if (node.terminator) bind(node.terminator);
2832
+ }
2833
+ function bindIdEqualsIdStatement(node) {
2834
+ bind(node.leftId);
2835
+ bind(node.rightId);
2836
+ if (node.rightId && !nodeContainsErrors(node.rightId)) {
2837
+ if (isAttributeName("color", node.leftId)) {
2838
+ ensureGlobalColor(node.rightId);
2839
+ } else if (isAttributeName("fillcolor", node.leftId)) {
2840
+ ensureGlobalColor(node.rightId);
2841
+ } else if (isAttributeName("bgcolor", node.leftId)) {
2842
+ ensureGlobalColor(node.rightId);
2843
+ } else if (isAttributeName("fontcolor", node.leftId)) {
2844
+ ensureGlobalColor(node.rightId);
2845
+ }
2846
+ }
2847
+ if (node.terminator) bind(node.terminator);
2848
+ }
2849
+ function bindQuotedTextIdentifier(node) {
2850
+ bindChildren(node.values);
2851
+ node.concatenation = node.values.map((v) => v.text).join("");
2852
+ }
2853
+ function bindEdgeRhs(node) {
2854
+ bind(node.operation);
2855
+ bind(node.target);
2856
+ }
2857
+ function bindAttributeContainer(node) {
2858
+ bind(node.openBracket);
2859
+ bindChildren(node.assignments);
2860
+ bind(node.closeBracket);
2861
+ }
2862
+ function bindAssignment(node) {
2863
+ const attrContainer = node.parent;
2864
+ console.assert(!!attrContainer);
2865
+ const superParentStatement = attrContainer.parent;
2866
+ console.assert(!!superParentStatement);
2867
+ bind(node.leftId);
2868
+ let carrierIdentifier;
2869
+ switch (superParentStatement.kind) {
2870
+ case 43 /* NodeStatement */:
2871
+ carrierIdentifier = superParentStatement.id.id;
2872
+ break;
2873
+ case 44 /* EdgeStatement */:
2874
+ break;
2875
+ case 48 /* SubGraphStatement */:
2876
+ break;
2877
+ case 45 /* AttributeStatement */:
2878
+ break;
2879
+ }
2880
+ if (carrierIdentifier) ensureMemberSymbol(node.leftId, carrierIdentifier);
2881
+ bind(node.rightId);
2882
+ if (node.rightId && !nodeContainsErrors(node.rightId)) {
2883
+ if (isAttributeName("color", node.leftId)) {
2884
+ ensureGlobalColor(node.rightId);
2885
+ }
2886
+ }
2887
+ if (node.terminator) bind(node.terminator);
2888
+ }
2889
+ function bindNormalPortDeclaration(node) {
2890
+ bind(node.colon);
2891
+ ensureGlobalSymbol(node.id);
2892
+ bind(node.id);
2893
+ if (node.compassPt) bind(node.compassPt);
2894
+ }
2895
+ function bindCompassPortDeclaration(node) {
2896
+ bind(node.colon);
2897
+ if (node.compassPt) bind(node.compassPt);
2898
+ }
2899
+ function bindNodeId(node) {
2900
+ ensureGlobalSymbol(node.id);
2901
+ bind(node.id);
2902
+ if (node.port) bind(node.port);
2903
+ }
2904
+ function bindChildren(nodes) {
2905
+ for (const n of nodes) bind(n);
2906
+ }
2907
+ function createSymbolTable() {
2908
+ return /* @__PURE__ */ new Map();
2909
+ }
2910
+ function createColorTable() {
2911
+ return /* @__PURE__ */ new Map();
2912
+ }
2913
+ function ensureMemberSymbol(node, carrier) {
2914
+ if (node && carrier && isIdentifierNode(node)) {
2915
+ const name = getIdentifierText(node);
2916
+ if (name === void 0) return;
2917
+ const carrierSymbol = carrier.symbol;
2918
+ if (carrierSymbol === void 0) throw "carrierSymbol is undefined";
2919
+ let symbols = carrierSymbol.members;
2920
+ if (symbols === void 0) carrierSymbol.members = symbols = createSymbolTable();
2921
+ ensureSymbolOnTable(name, node, symbols);
2922
+ return;
2923
+ }
2924
+ console.warn("ensureSymbol called on non-identifier node");
2925
+ debugger;
2926
+ }
2927
+ function ensureGlobalSymbol(node) {
2928
+ if (node && isIdentifierNode(node)) {
2929
+ const symbols = symbolTable;
2930
+ const name = getIdentifierText(node);
2931
+ if (name === void 0) return;
2932
+ if (symbols === void 0) throw "symbolTable is undefined";
2933
+ ensureSymbolOnTable(name, node, symbols);
2934
+ return;
2935
+ }
2936
+ console.warn("ensureSymbol called on non-identifier node");
2937
+ debugger;
2938
+ }
2939
+ function ensureSymbolOnTable(name, node, symbols) {
2940
+ if (!name) return;
2941
+ let sym = symbols.get(name);
2942
+ if (sym === void 0) {
2943
+ sym = createSymbol(name, node);
2944
+ symbols.set(name, sym);
2945
+ } else {
2946
+ if (!sym.references) sym.references = [node];
2947
+ else sym.references.push(node);
2948
+ }
2949
+ node.symbol = sym;
2950
+ }
2951
+ function ensureGlobalColor(node) {
2952
+ if (node && isIdentifierNode(node)) {
2953
+ const colors2 = colorTable;
2954
+ const name = getIdentifierText(node);
2955
+ if (name === void 0) return;
2956
+ if (colors2 === void 0) throw "symbolTable is undefined";
2957
+ const color = createColor(node);
2958
+ colors2.set(name, color);
2959
+ return;
2960
+ }
2961
+ console.warn("ensureSymbol called on non-identifier node");
2962
+ debugger;
2963
+ }
2964
+ function createSymbol(name, node) {
2965
+ if (!name) throw "name is falsy";
2966
+ if (!node) throw "node is undefined or null";
2967
+ return {
2968
+ name,
2969
+ firstMention: node,
2970
+ references: void 0
2971
+ };
2972
+ }
2973
+ function createColor(node) {
2974
+ return {
2975
+ node
2976
+ };
2977
+ }
2978
+ function isAttributeName(name, id) {
2979
+ return id ? getIdentifierText(id).trim().toLowerCase() === name : false;
2980
+ }
2981
+ return {
2982
+ bind: (file) => {
2983
+ symbolTable = createSymbolTable();
2984
+ colorTable = createColorTable();
2985
+ const { graph } = file;
2986
+ if (graph) bind(graph);
2987
+ file.symbols = symbolTable;
2988
+ file.colors = colorTable;
2989
+ }
2990
+ };
2991
+ }
2992
+
2993
+ // src/service/command/common.ts
2994
+ import { Range, TextEdit } from "vscode-languageserver-types";
2995
+ function createChangeToEdit(start, end, changeTo) {
2996
+ return TextEdit.replace(Range.create(start, end), changeTo);
2997
+ }
2998
+ function getEdgeStr(op) {
2999
+ return op === 39 /* DirectedEdgeOp */ ? "->" : "--";
3000
+ }
3001
+ function getGraphKeywordStr(g) {
3002
+ return g === 34 /* DigraphKeyword */ ? "digraph" : "graph";
3003
+ }
3004
+ function getOppositeKind(g) {
3005
+ return g === 34 /* DigraphKeyword */ ? 33 /* GraphKeyword */ : 34 /* DigraphKeyword */;
3006
+ }
3007
+ function getOppositeEdgeOp(g) {
3008
+ return g === 39 /* DirectedEdgeOp */ ? 40 /* UndirectedEdgeOp */ : 39 /* DirectedEdgeOp */;
3009
+ }
3010
+ function getAllowedOp(g) {
3011
+ return g === 34 /* DigraphKeyword */ ? 39 /* DirectedEdgeOp */ : 40 /* UndirectedEdgeOp */;
3012
+ }
3013
+
3014
+ // src/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.ts
3015
+ function create(edgeOffsets, changeEdgesTo, graphOffset, changeFromGraph, changeGraphTo) {
3016
+ const toGraph = getGraphKeywordStr(changeGraphTo);
3017
+ const title = changeGraphTo === changeFromGraph ? `Fix all edges to match ${toGraph}` : `Convert ${getGraphKeywordStr(changeFromGraph)} to ${toGraph}`;
3018
+ const edgeStr = getEdgeStr(changeEdgesTo);
3019
+ return {
3020
+ title,
3021
+ command: "DOT.convertGraphType" /* ConvertGraphType */,
3022
+ arguments: [edgeOffsets, edgeStr, graphOffset, toGraph]
3023
+ };
3024
+ }
3025
+ function execute(doc, _sourceFile, cmd) {
3026
+ if (!isChangeAllOtherEdgeOpsAndFixGraphCommand(cmd)) return void 0;
3027
+ const [edgeOffsets, changeEdgeTo, graphOffset, changeGraphTo] = cmd.arguments;
3028
+ const edits = edgeOffsets.map((o) => {
3029
+ const startPos = doc.positionAt(o.start);
3030
+ const endPos = doc.positionAt(o.end);
3031
+ return createChangeToEdit(startPos, endPos, changeEdgeTo);
3032
+ });
3033
+ const graphStart = doc.positionAt(graphOffset.start);
3034
+ const graphEnd = doc.positionAt(graphOffset.end);
3035
+ edits.push(createChangeToEdit(graphStart, graphEnd, changeGraphTo));
3036
+ return {
3037
+ label: `Convert graph to "${changeGraphTo}"`,
3038
+ edit: {
3039
+ changes: {
3040
+ [doc.uri]: edits
3041
+ }
3042
+ }
3043
+ };
3044
+ }
3045
+ function isChangeAllOtherEdgeOpsAndFixGraphCommand(cmd) {
3046
+ return cmd.command === "DOT.convertGraphType" /* ConvertGraphType */ && !!cmd.arguments && cmd.arguments.length === 4;
3047
+ }
3048
+
3049
+ // src/service/command/ChangeEdgeOpCommand.ts
3050
+ import * as lst from "vscode-languageserver-types";
3051
+ function create2(startOffset, endOffset, changeTo, changeFrom) {
3052
+ const from = getEdgeStr(changeFrom);
3053
+ const to = getEdgeStr(changeTo);
3054
+ return {
3055
+ title: `Change "${from}" to "${to}".`,
3056
+ command: "DOT.changeEdgeOp" /* ChangeEdgeOp */,
3057
+ arguments: [startOffset, endOffset, to]
3058
+ };
3059
+ }
3060
+ function execute2(doc, _sourceFile, cmd) {
3061
+ if (!isChangeEdgeOpCommand(cmd)) return void 0;
3062
+ const [startOffset, endOffset, changeTo] = cmd.arguments;
3063
+ const startPos = doc.positionAt(startOffset);
3064
+ const endPos = doc.positionAt(endOffset);
3065
+ return {
3066
+ label: `Change of invalid edge to "${changeTo}"'"`,
3067
+ edit: {
3068
+ changes: {
3069
+ [doc.uri]: [lst.TextEdit.replace(lst.Range.create(startPos, endPos), changeTo)]
3070
+ }
3071
+ }
3072
+ };
3073
+ }
3074
+ function isChangeEdgeOpCommand(cmd) {
3075
+ return cmd.command === "DOT.changeEdgeOp" /* ChangeEdgeOp */ && !!cmd.arguments && cmd.arguments.length === 3;
3076
+ }
3077
+
3078
+ // src/service/command/ConsolidateDescendantsCommand.ts
3079
+ function create3(statements, below) {
3080
+ const first = statements[0];
3081
+ const from = getIdentifierText(first.source.id);
3082
+ const title = below ? `Convert edges below from "${from}" to subgraph` : `Convert edges from "${from}" to subgraph`;
3083
+ return {
3084
+ title,
3085
+ command: "DOT.consolidateDescendants" /* ConsolidateDescendants */,
3086
+ arguments: statements.map((s) => s.pos)
3087
+ };
3088
+ }
3089
+ function execute3(doc, sourceFile, cmd) {
3090
+ if (!isConsolidateDescendantsCommand(cmd)) return void 0;
3091
+ const g = sourceFile.graph;
3092
+ if (!g) return void 0;
3093
+ const candidateIndexes = cmd.arguments;
3094
+ const candidates = candidateIndexes.map(
3095
+ (i) => findNodeAtOffset(g, i).parent.parent
3096
+ );
3097
+ const first = candidates.shift();
3098
+ const from = getIdentifierText(first.source.id);
3099
+ const edits = [];
3100
+ const firstRight = first.rhs[0];
3101
+ const firstRightTargetStart = getStart(sourceFile, firstRight.target);
3102
+ const firstRightTargetEnd = firstRight.target.end;
3103
+ const contents = [sourceFile.content.substring(firstRightTargetStart, firstRightTargetEnd)];
3104
+ for (const descendant of candidates) {
3105
+ const rightItem = descendant.rhs[0];
3106
+ const rightItemTarget = rightItem.target;
3107
+ const rightItemTargetStart = rightItemTarget.pos;
3108
+ const rightItemTargetEnd = rightItem.target.end;
3109
+ const rightItemContent = sourceFile.content.substring(
3110
+ rightItemTargetStart,
3111
+ rightItemTargetEnd
3112
+ );
3113
+ edits.push({
3114
+ newText: "",
3115
+ range: {
3116
+ start: doc.positionAt(descendant.pos),
3117
+ end: doc.positionAt(rightItemTargetStart)
3118
+ }
3119
+ });
3120
+ edits.push({
3121
+ newText: "",
3122
+ range: {
3123
+ start: doc.positionAt(rightItemTargetStart),
3124
+ end: doc.positionAt(rightItemTargetEnd)
3125
+ }
3126
+ });
3127
+ if (descendant.terminator !== void 0) {
3128
+ edits.push({
3129
+ newText: "",
3130
+ range: {
3131
+ start: doc.positionAt(getStart(sourceFile, descendant.terminator)),
3132
+ end: doc.positionAt(descendant.terminator.end)
3133
+ }
3134
+ });
3135
+ }
3136
+ contents.push(rightItemContent);
3137
+ }
3138
+ const toInsert = `{ ${contents.map((s) => s.trim()).join(" ")} }`;
3139
+ edits.push({
3140
+ newText: toInsert,
3141
+ range: {
3142
+ start: doc.positionAt(firstRightTargetStart),
3143
+ end: doc.positionAt(firstRightTargetEnd)
3144
+ }
3145
+ });
3146
+ return {
3147
+ label: `Convert edges from "${from}" to subgraph.`,
3148
+ edit: {
3149
+ changes: {
3150
+ [doc.uri]: edits
3151
+ }
3152
+ }
3153
+ };
3154
+ }
3155
+ function isConsolidateDescendantsCommand(cmd) {
3156
+ return cmd.command === "DOT.consolidateDescendants" /* ConsolidateDescendants */ && !!cmd.arguments && cmd.arguments.length > 1;
3157
+ }
3158
+
3159
+ // src/service/command/RemoveSemicolons.ts
3160
+ function create4() {
3161
+ return {
3162
+ title: "Remove optional semicolons",
3163
+ command: "DOT.removeSemicolons" /* RemoveSemicolons */,
3164
+ arguments: void 0
3165
+ };
3166
+ }
3167
+ function execute4(doc, sourceFile, cmd) {
3168
+ if (!isRemoveSemicolonsCommand(cmd)) return void 0;
3169
+ const g = sourceFile.graph;
3170
+ if (!g) return void 0;
3171
+ const semicolons = findOptionalSemicolons(g);
3172
+ const edits = semicolons.map((s) => {
3173
+ const end = s.end;
3174
+ const start = end - 1;
3175
+ return createChangeToEdit(doc.positionAt(start), doc.positionAt(end), "");
3176
+ });
3177
+ return {
3178
+ label: "Remove optional semicolons",
3179
+ edit: {
3180
+ changes: {
3181
+ [doc.uri]: edits
3182
+ }
3183
+ }
3184
+ };
3185
+ }
3186
+ function isRemoveSemicolonsCommand(cmd) {
3187
+ return cmd.command === "DOT.removeSemicolons" /* RemoveSemicolons */ && (!cmd.arguments || cmd.arguments.length === 0 || cmd.arguments.every((e) => e === void 0));
3188
+ }
3189
+
3190
+ // src/service/codeAction.ts
3191
+ function getCodeActions(doc, sourceFile, range, _context) {
3192
+ let actions = getActionsFromDiagnostics(doc, sourceFile, range);
3193
+ const general = getGeneralRefactorings(doc, sourceFile, range);
3194
+ if (general) {
3195
+ if (!actions) actions = general;
3196
+ else actions.push.apply(actions, general);
3197
+ }
3198
+ return actions;
3199
+ }
3200
+ function getActionsFromDiagnostics(doc, file, range) {
3201
+ const ds = file.diagnostics;
3202
+ if (!ds || ds.length === 0) return void 0;
3203
+ const rangeStartOffset = doc.offsetAt(range.start);
3204
+ const rangeEndOffset = doc.offsetAt(range.end);
3205
+ const res = [];
3206
+ for (const d of ds) {
3207
+ if (isInRange(rangeStartOffset, rangeEndOffset, d.start, d.end)) {
3208
+ const commands = getCommandsForDiagnostic(doc, file, d);
3209
+ if (commands && commands.length > 0) res.push.apply(res, commands);
3210
+ }
3211
+ }
3212
+ return res.length === 0 ? void 0 : res;
3213
+ }
3214
+ function getGeneralRefactorings(doc, file, range) {
3215
+ if (!file.graph) return void 0;
3216
+ const g = file.graph;
3217
+ const kw = g.keyword;
3218
+ const rangeStartOffset = doc.offsetAt(range.start);
3219
+ const rangeEndOffset = doc.offsetAt(range.end);
3220
+ const keywordStart = getStart(file, kw);
3221
+ const res = [];
3222
+ if (isInRange(rangeStartOffset, rangeEndOffset, keywordStart, kw.end)) {
3223
+ if (!subtreeContainsErrors(g)) {
3224
+ const oppositeGraphType = getOppositeKind(kw.kind);
3225
+ const convertGraph = convertGraphTypeCommand(file, g, oppositeGraphType);
3226
+ res.push(convertGraph);
3227
+ }
3228
+ }
3229
+ if (rangeStartOffset === rangeEndOffset) {
3230
+ const candidates = [];
3231
+ let clickedNode = findNodeAtOffset(g, rangeStartOffset);
3232
+ if (clickedNode && !!clickedNode.parent) {
3233
+ if (clickedNode.kind === 8 /* SemicolonToken */) {
3234
+ res.push(create4());
3235
+ }
3236
+ if (isIdentifierNode(clickedNode)) {
3237
+ clickedNode = clickedNode.parent;
3238
+ }
3239
+ const clickedEdgeStatement = clickedNode.parent;
3240
+ if (clickedEdgeStatement && !subtreeContainsErrors(clickedEdgeStatement)) {
3241
+ if (isEdgeStatement(clickedEdgeStatement) && clickedEdgeStatement.rhs.length === 1 && isNodeId(clickedEdgeStatement.source) && !edgeStatementHasAttributes(
3242
+ clickedEdgeStatement
3243
+ )) {
3244
+ candidates.push(clickedEdgeStatement);
3245
+ const source = clickedEdgeStatement.source;
3246
+ const sourceText = getIdentifierText(source.id);
3247
+ const graphParent = clickedEdgeStatement.parent;
3248
+ if (graphParent) {
3249
+ let hasVisitedStatement = false;
3250
+ let hasVisitedNodeModifier = false;
3251
+ forEachChild(graphParent, (statement) => {
3252
+ if (statement === clickedEdgeStatement) {
3253
+ hasVisitedStatement = true;
3254
+ return void 0;
3255
+ }
3256
+ if (hasVisitedNodeModifier) {
3257
+ return;
3258
+ }
3259
+ if (hasVisitedStatement) {
3260
+ if (isAttrStatement(statement) || // we have encountered a semantic-changing AttrStatement
3261
+ subtreeContainsErrors(statement)) {
3262
+ hasVisitedNodeModifier = true;
3263
+ return true;
3264
+ }
3265
+ }
3266
+ if (hasVisitedStatement) {
3267
+ if (isEdgeStatement(statement) && statement.rhs.length === 1 && !edgeStatementHasAttributes(
3268
+ statement
3269
+ )) {
3270
+ const statementSource = statement.source;
3271
+ if (isNodeId(statementSource)) {
3272
+ const lowerSourceText = getIdentifierText(
3273
+ statementSource.id
3274
+ );
3275
+ if (sourceText === lowerSourceText) {
3276
+ candidates.push(statement);
3277
+ }
3278
+ }
3279
+ }
3280
+ }
3281
+ return void 0;
3282
+ });
3283
+ }
3284
+ }
3285
+ if (candidates.length > 1) {
3286
+ const action = create3(candidates, true);
3287
+ res.push(action);
3288
+ }
3289
+ }
3290
+ }
3291
+ }
3292
+ return res.length === 0 ? void 0 : res;
3293
+ }
3294
+ function getCommandsForDiagnostic(doc, file, d) {
3295
+ switch (d.code.source) {
3296
+ case 1 /* Scan */:
3297
+ return getScannerErrorCommand(doc, file, d, d.code);
3298
+ case 2 /* Parse */:
3299
+ return getParserErrorCommand(doc, file, d, d.code);
3300
+ case 4 /* Check */:
3301
+ return getCheckerErrorCommand(doc, file, d, d.code);
3302
+ default:
3303
+ return assertNever(d.code);
3304
+ }
3305
+ }
3306
+ function getScannerErrorCommand(_doc, _file, d, code) {
3307
+ console.assert(d.code.source === 1 /* Scan */);
3308
+ console.assert(code.source === 1 /* Scan */);
3309
+ return void 0;
3310
+ }
3311
+ function getParserErrorCommand(_doc, _file, d, code) {
3312
+ console.assert(d.code.source === 2 /* Parse */);
3313
+ console.assert(code.source === 2 /* Parse */);
3314
+ return void 0;
3315
+ }
3316
+ function getCheckerErrorCommand(_doc, file, d, code) {
3317
+ console.assert(d.code.source === 4 /* Check */);
3318
+ console.assert(code.source === 4 /* Check */);
3319
+ switch (code.sub) {
3320
+ case 0 /* InvalidEdgeOperation */: {
3321
+ const graph = file.graph;
3322
+ if (!graph) return void 0;
3323
+ const allowedOp = getAllowedEdgeOperation(graph);
3324
+ const wrongOp = getOppositeEdgeOp(allowedOp);
3325
+ const kwk = graph.keyword.kind;
3326
+ const fixSingleEdge = create2(d.start, d.end, allowedOp, wrongOp);
3327
+ const fixAll = convertGraphTypeCommand(file, graph, kwk);
3328
+ const convertToThisWrongType = convertGraphTypeCommand(
3329
+ file,
3330
+ graph,
3331
+ getOppositeKind(kwk)
3332
+ );
3333
+ return [fixSingleEdge, fixAll, convertToThisWrongType];
3334
+ }
3335
+ case 1 /* InvalidShapeName */:
3336
+ return void 0;
3337
+ }
3338
+ }
3339
+ function convertGraphTypeCommand(file, graph, changeToGraphType) {
3340
+ const changeToEdgeOp = getAllowedOp(changeToGraphType);
3341
+ const allEdges = findAllEdges(graph);
3342
+ const edgeOffsets = allEdges.filter((e) => e.operation.kind !== changeToEdgeOp).map((e) => ({
3343
+ start: getStart(file, e.operation),
3344
+ end: e.operation.end
3345
+ }));
3346
+ const graphTypeOffset = {
3347
+ start: getStart(file, graph.keyword),
3348
+ end: graph.keyword.end
3349
+ };
3350
+ return create(
3351
+ edgeOffsets,
3352
+ changeToEdgeOp,
3353
+ graphTypeOffset,
3354
+ graph.keyword.kind,
3355
+ changeToGraphType
3356
+ );
3357
+ }
3358
+ function isInRange(rangeStartOffset, rangeEndOffset, startOffset, endOffset) {
3359
+ if (rangeStartOffset === rangeEndOffset)
3360
+ return startOffset <= rangeStartOffset && rangeEndOffset <= endOffset;
3361
+ if (rangeStartOffset === startOffset && rangeEndOffset === endOffset) return true;
3362
+ return false;
3363
+ }
3364
+ var commandHandlers = {
3365
+ ["DOT.changeEdgeOp" /* ChangeEdgeOp */]: execute2,
3366
+ ["DOT.convertGraphType" /* ConvertGraphType */]: execute,
3367
+ ["DOT.consolidateDescendants" /* ConsolidateDescendants */]: execute3,
3368
+ ["DOT.removeSemicolons" /* RemoveSemicolons */]: execute4
3369
+ };
3370
+ function getAvailableCommands() {
3371
+ return Object.keys(commandHandlers);
3372
+ }
3373
+ function executeCommand(doc, sourceFile, cmd) {
3374
+ const handler = commandHandlers[cmd.command];
3375
+ return handler === void 0 ? void 0 : handler(doc, sourceFile, cmd);
3376
+ }
3377
+ function subtreeContainsErrors(node) {
3378
+ if (nodeContainsErrors(node)) return true;
3379
+ let hasError = false;
3380
+ forEachChild(node, (child) => {
3381
+ if (nodeContainsErrors(child)) {
3382
+ hasError = true;
3383
+ }
3384
+ if (!hasError) {
3385
+ hasError = subtreeContainsErrors(child);
3386
+ }
3387
+ });
3388
+ return hasError;
3389
+ }
3390
+
3391
+ // src/service/colorProvider.ts
3392
+ var colorMap = colors;
3393
+ function getDocumentColors(doc, sourceFile) {
3394
+ const cs = sourceFile.colors;
3395
+ return cs ? colorTableToColorInformation(doc, sourceFile, cs) : void 0;
3396
+ }
3397
+ function getColorRepresentations(_doc, _sourceFile, color, range) {
3398
+ return !color || !range ? void 0 : [{ label: `"${getColorStringFromColor(color)}"` }];
3399
+ }
3400
+ function colorTableToColorInformation(doc, sf, colors2) {
3401
+ if (!colors2 || colors2.size === 0) return [];
3402
+ const res = [];
3403
+ for (const [name, value] of colors2) {
3404
+ if (!name || !value) continue;
3405
+ const color = getColorFromName(name);
3406
+ if (color) {
3407
+ res.push({
3408
+ range: syntaxNodeToRange(doc, sf, value.node),
3409
+ color
3410
+ });
3411
+ }
3412
+ }
3413
+ return res;
3414
+ }
3415
+ function getColorFromName(name) {
3416
+ if (name.charAt(0) === "#") return getHexCodeColor(name);
3417
+ const colorAlias = colorMap[name.toLowerCase()];
3418
+ return colorAlias ? getHexCodeColor(colorAlias) : void 0;
3419
+ }
3420
+ function getHexCodeColor(colorCode) {
3421
+ const hexCode = colorCode.charAt(0) === "#" ? colorCode.substring(1) : colorCode;
3422
+ const colorInt = Number.parseInt(hexCode, 16);
3423
+ return {
3424
+ red: (colorInt >> 16 & 255) / 255,
3425
+ green: (colorInt >> 8 & 255) / 255,
3426
+ blue: (colorInt & 255) / 255,
3427
+ alpha: hexCode.length === 8 ? (colorInt >> 24 & 255) / 255 : 1
3428
+ };
3429
+ }
3430
+ function getColorStringFromColor(c) {
3431
+ const red = c.red * 255 | 0;
3432
+ const green = c.green * 255 | 0;
3433
+ const blue = c.blue * 255 | 0;
3434
+ return `#${numberToPaddedString(red)}${numberToPaddedString(green)}${numberToPaddedString(
3435
+ blue
3436
+ )}`;
3437
+ }
3438
+ function numberToPaddedString(n) {
3439
+ const s = n.toString(16);
3440
+ return (s.length === 1 ? `0${s}` : s).toLowerCase();
3441
+ }
3442
+
3443
+ // src/service/completion.ts
3444
+ import * as lst2 from "vscode-languageserver-types";
3445
+ function getCompletions(doc, sourceFile, position) {
3446
+ const symbols = sourceFile.symbols;
3447
+ if (!symbols) throw "sourceFile is not bound";
3448
+ const g = sourceFile.graph;
3449
+ if (!g) return [];
3450
+ const offset = doc.offsetAt(position);
3451
+ const node = findNodeAtOffset(g, offset, true);
3452
+ if (!node) return [];
3453
+ const prevOffsetNode = findNodeAtOffset(g, offset - 1, true);
3454
+ const parent = node.parent;
3455
+ const prevOffsetNodeParent = prevOffsetNode?.parent;
3456
+ if (parent?.parent && isEdgeStatement(parent.parent) || prevOffsetNodeParent?.parent && isEdgeStatement(prevOffsetNodeParent.parent)) {
3457
+ return getNodeCompletions(symbols);
3458
+ }
3459
+ if (node.kind === 50 /* AttributeContainer */) {
3460
+ const openingBracket = node.openBracket;
3461
+ if (openingBracket.end - 1 > offset - 1) {
3462
+ const exclusions = prevOffsetNode?.kind === 30 /* TextIdentifier */ && prevOffsetNode.symbol ? [prevOffsetNode.symbol.name] : void 0;
3463
+ return getNodeCompletions(symbols, exclusions);
3464
+ }
3465
+ }
3466
+ if (node.kind === 30 /* TextIdentifier */ && parent?.kind === 54 /* NodeId */) {
3467
+ const exclusions = node.symbol ? [node.symbol.name] : void 0;
3468
+ return getNodeCompletions(symbols, exclusions);
3469
+ }
3470
+ if (node.kind === 50 /* AttributeContainer */ || node.kind === 7 /* CommaToken */ && parent?.kind === 51 /* Assignment */) {
3471
+ return getAttributeCompletions(position);
3472
+ }
3473
+ const prevNode = findNodeAtOffset(g, node.pos - 1, true);
3474
+ if (!prevNode) return [];
3475
+ if (isIdentifierNode(prevNode)) {
3476
+ const p = prevNode.parent;
3477
+ if (p) {
3478
+ switch (p.kind) {
3479
+ case 54 /* NodeId */: {
3480
+ return getNodeCompletions(symbols);
3481
+ }
3482
+ case 51 /* Assignment */: {
3483
+ return getAssignmentCompletion(p);
3484
+ }
3485
+ }
3486
+ }
3487
+ }
3488
+ if (node.flags & 2 /* ContainsErrors */ || node.end === node.pos) {
3489
+ const attribute = prevNode;
3490
+ if (!attribute) return [];
3491
+ if (!attribute.parent) throw "sourceFile is not bound";
3492
+ const parent2 = attribute.parent;
3493
+ if (parent2.kind === 51 /* Assignment */) {
3494
+ return getAssignmentCompletion(parent2);
3495
+ }
3496
+ }
3497
+ return [];
3498
+ }
3499
+ function getAssignmentCompletion(assignment) {
3500
+ const property = getIdentifierText(assignment.leftId);
3501
+ if (!property) return [];
3502
+ switch (property.toLowerCase()) {
3503
+ case "shape":
3504
+ return getShapeCompletions();
3505
+ case "color":
3506
+ return getColorCompletions();
3507
+ default:
3508
+ return [];
3509
+ }
3510
+ }
3511
+ function getShapeCompletions() {
3512
+ const kind = lst2.CompletionItemKind.EnumMember;
3513
+ return shapes.map((s) => ({
3514
+ kind,
3515
+ label: escapeIdentifierText(s)
3516
+ }));
3517
+ }
3518
+ function getColorCompletions() {
3519
+ const kind = lst2.CompletionItemKind.Color;
3520
+ const colors2 = colors;
3521
+ return Object.keys(colors2).map((label) => ({
3522
+ kind,
3523
+ label,
3524
+ // If the completion kind is "color", the documentation can hold the color code
3525
+ // The color name is then displayed along with a preview of the color
3526
+ documentation: colors2[label]
3527
+ }));
3528
+ }
3529
+ function getAttributeCompletions(posistion) {
3530
+ const kind = lst2.CompletionItemKind.Property;
3531
+ const range = {
3532
+ start: posistion,
3533
+ end: posistion
3534
+ };
3535
+ return attributes.map((label) => ({
3536
+ kind,
3537
+ label,
3538
+ textEdit: {
3539
+ range,
3540
+ newText: `${escapeIdentifierText(label)}=`
3541
+ }
3542
+ }));
3543
+ }
3544
+ function getNodeCompletions(symbols, exlucdedSymbols) {
3545
+ const res = [];
3546
+ for (const [key, value] of symbols) {
3547
+ if (exlucdedSymbols?.includes(key)) continue;
3548
+ let kind = lst2.CompletionItemKind.Variable;
3549
+ const a = value.firstMention.parent;
3550
+ if (a) {
3551
+ switch (a.kind) {
3552
+ case 41 /* DirectedGraph */:
3553
+ case 42 /* UndirectedGraph */:
3554
+ kind = lst2.CompletionItemKind.Class;
3555
+ break;
3556
+ }
3557
+ }
3558
+ res.push({
3559
+ label: escapeIdentifierText(key),
3560
+ kind
3561
+ });
3562
+ }
3563
+ return res;
3564
+ }
3565
+
3566
+ // src/service/hover.ts
3567
+ function hover(doc, sourceFile, position) {
3568
+ const offset = doc.offsetAt(position);
3569
+ const g = sourceFile.graph;
3570
+ if (!g) return void 0;
3571
+ const node = findNodeAtOffset(g, offset);
3572
+ if (node === void 0) return void 0;
3573
+ return getNodeHover(doc, sourceFile, node);
3574
+ }
3575
+ function getNodeHover(doc, sf, n) {
3576
+ const contents = getHoverContents(n);
3577
+ if (contents) {
3578
+ return {
3579
+ contents,
3580
+ range: syntaxNodeToRange(doc, sf, n)
3581
+ };
3582
+ }
3583
+ return void 0;
3584
+ }
3585
+ function getAssignedLabel(statement) {
3586
+ const assignments = statement.attributes.flatMap((a) => a.assignments);
3587
+ const assignedLabel = assignments?.find((a) => getIdentifierText(a.leftId) === "label");
3588
+ return assignedLabel?.rightId ? getIdentifierText(assignedLabel.rightId) : void 0;
3589
+ }
3590
+ function getHoverContents(n) {
3591
+ if (isIdentifierNode(n)) {
3592
+ const parent = n.parent;
3593
+ if (parent) {
3594
+ switch (parent.kind) {
3595
+ case 54 /* NodeId */: {
3596
+ if (n.symbol?.references) {
3597
+ const nodeIdentifierRefs = n.symbol?.references;
3598
+ const labelMentions = nodeIdentifierRefs.map(
3599
+ (e) => e.symbol?.members?.get("label")?.firstMention.parent
3600
+ );
3601
+ for (let i = labelMentions.length; i >= 0; i--) {
3602
+ const s = labelMentions[i];
3603
+ if (s?.rightId) {
3604
+ return `(node) ${getIdentifierText(n)}: ${getIdentifierText(
3605
+ s.rightId
3606
+ )}`;
3607
+ }
3608
+ }
3609
+ } else if (parent.parent?.kind === 43 /* NodeStatement */) {
3610
+ const label = getAssignedLabel(parent.parent);
3611
+ if (label) {
3612
+ return `(node) ${getIdentifierText(n)}: ${label}`;
3613
+ }
3614
+ }
3615
+ return `(node) ${getIdentifierText(n)}`;
3616
+ }
3617
+ case 51 /* Assignment */: {
3618
+ const assignment = parent;
3619
+ const left = getIdentifierText(assignment.leftId);
3620
+ const right = getIdentifierText(assignment.rightId);
3621
+ return `(assignment) \`${left}\` = \`${right}\``;
3622
+ }
3623
+ case 41 /* DirectedGraph */:
3624
+ return getGraphHover(parent);
3625
+ case 42 /* UndirectedGraph */:
3626
+ return getGraphHover(parent);
3627
+ case 48 /* SubGraphStatement */: {
3628
+ const sgs = parent;
3629
+ const sg = sgs.subgraph;
3630
+ return sg.id ? `(sub graph) ${getIdentifierText(sg.id)}` : "(sub graph)";
3631
+ }
3632
+ case 47 /* SubGraph */: {
3633
+ const sg = parent;
3634
+ return sg.id ? `(sub graph) ${getIdentifierText(sg.id)}` : "(sub graph)";
3635
+ }
3636
+ case 46 /* IdEqualsIdStatement */: {
3637
+ const idEqId = parent;
3638
+ const left = getIdentifierText(idEqId.leftId);
3639
+ const right = getIdentifierText(idEqId.rightId);
3640
+ return `(graph property) \`${left}\` = \`${right}\``;
3641
+ }
3642
+ case 49 /* EdgeRhs */:
3643
+ return getEdgeHover(parent);
3644
+ }
3645
+ return SyntaxKind[parent.kind];
3646
+ }
3647
+ const fallback = SyntaxKind[n.kind];
3648
+ return fallback ? `(${fallback.toLowerCase()})` : void 0;
3649
+ }
3650
+ switch (n.kind) {
3651
+ case 33 /* GraphKeyword */:
3652
+ case 34 /* DigraphKeyword */:
3653
+ case 38 /* StrictKeyword */:
3654
+ return getGraphHover(n.parent);
3655
+ // TODO: Why does findNodeAtOffset() return a non-leaf node
3656
+ // Did not expect to need to have this here.
3657
+ case 41 /* DirectedGraph */:
3658
+ case 42 /* UndirectedGraph */:
3659
+ return getGraphHover(n);
3660
+ case 39 /* DirectedEdgeOp */:
3661
+ case 40 /* UndirectedEdgeOp */:
3662
+ return getEdgeHover(n.parent);
3663
+ default:
3664
+ return void 0;
3665
+ }
3666
+ }
3667
+ function getGraphHover(g) {
3668
+ const direction = g.kind === 41 /* DirectedGraph */ ? "directed" : "undirected";
3669
+ const graphId = g.id;
3670
+ const strict = g.strict ? "strict " : "";
3671
+ return graphId ? `(${strict}${direction} graph) ${getIdentifierText(graphId)}` : `(${strict}${direction} graph)`;
3672
+ }
3673
+ function getEdgeHover(n) {
3674
+ const p = n.parent;
3675
+ if (!p || p.rhs.length === 0) return void 0;
3676
+ let source;
3677
+ for (const curr of p.rhs) {
3678
+ if (curr === n) break;
3679
+ source = curr.target;
3680
+ }
3681
+ if (source === void 0) source = p.source;
3682
+ const edgeOpStr = getEdgeStr(n.operation.kind);
3683
+ return source === void 0 ? void 0 : `(edge) ${getEdgeSourceOrTargetText(source)} ${edgeOpStr} ${getEdgeSourceOrTargetText(
3684
+ n.target
3685
+ )}`;
3686
+ }
3687
+ function getEdgeSourceOrTargetText(n) {
3688
+ return n.kind === 54 /* NodeId */ ? getIdentifierText(n.id) : n.id !== void 0 ? `${getIdentifierText(n.id)}` : "sub graph";
3689
+ }
3690
+
3691
+ // src/service/reference.ts
3692
+ function findReferences(doc, sourceFile, position, context) {
3693
+ if (!sourceFile.symbols) throw "sourceFile is not bound";
3694
+ const g = sourceFile.graph;
3695
+ if (!g) return [];
3696
+ const offset = doc.offsetAt(position);
3697
+ const node = findNodeAtOffset(g, offset);
3698
+ if (!node) return [];
3699
+ if (isIdentifierNode(node)) {
3700
+ const nodeSymbol = node.symbol;
3701
+ if (!nodeSymbol) throw "node.symbol is not bound";
3702
+ const refs = nodeSymbol.references || [];
3703
+ let symbolRefs;
3704
+ if (context.includeDeclaration) {
3705
+ symbolRefs = [nodeSymbol.firstMention, ...refs];
3706
+ } else {
3707
+ if (nodeSymbol.firstMention === node) {
3708
+ symbolRefs = refs;
3709
+ } else {
3710
+ symbolRefs = [nodeSymbol.firstMention, ...refs.filter((r) => r !== node)];
3711
+ }
3712
+ }
3713
+ const ranges = syntaxNodesToRanges(doc, sourceFile, symbolRefs);
3714
+ const uri = doc.uri;
3715
+ return ranges.map((range) => {
3716
+ return { uri, range };
3717
+ });
3718
+ }
3719
+ debugger;
3720
+ return [];
3721
+ }
3722
+ function findDefinition(doc, sourceFile, position) {
3723
+ if (!sourceFile.symbols) throw "sourceFile is not bound";
3724
+ const g = sourceFile.graph;
3725
+ if (!g) return void 0;
3726
+ const offset = doc.offsetAt(position);
3727
+ const node = findNodeAtOffset(g, offset);
3728
+ if (!node) return void 0;
3729
+ if (isIdentifierNode(node)) {
3730
+ const nodeSymbol = node.symbol;
3731
+ if (!nodeSymbol) throw "node.symbol is not bound";
3732
+ const firstMention = nodeSymbol.firstMention;
3733
+ if (!firstMention) return void 0;
3734
+ const range = syntaxNodeToRange(doc, sourceFile, firstMention);
3735
+ return { uri: doc.uri, range };
3736
+ }
3737
+ debugger;
3738
+ return void 0;
3739
+ }
3740
+
3741
+ // src/service/rename.ts
3742
+ import { TextEdit as TextEdit3 } from "vscode-languageserver-types";
3743
+ function renameSymbol(doc, sourceFile, position, newName) {
3744
+ if (!sourceFile.symbols) throw "sourceFile is not bound";
3745
+ if (!newName) return void 0;
3746
+ const g = sourceFile.graph;
3747
+ if (!g) return void 0;
3748
+ const offset = doc.offsetAt(position);
3749
+ const node = findNodeAtOffset(g, offset);
3750
+ if (!node) return void 0;
3751
+ const parent = node.parent;
3752
+ if (isIdentifierNode(node) && isRenamableIdentifier(node) && !!parent && isRenameableNode(parent)) {
3753
+ const nodeSymbol = node.symbol;
3754
+ if (!nodeSymbol) throw "node.symbol is not bound";
3755
+ const r = nodeSymbol.references;
3756
+ const refs = r ? [nodeSymbol.firstMention, ...r] : [nodeSymbol.firstMention];
3757
+ const ranges = syntaxNodesToRanges(doc, sourceFile, refs);
3758
+ const uri = doc.uri;
3759
+ const res = {
3760
+ changes: {
3761
+ [uri]: ranges.map((r2) => TextEdit3.replace(r2, newName))
3762
+ }
3763
+ };
3764
+ return res;
3765
+ }
3766
+ debugger;
3767
+ return void 0;
3768
+ }
3769
+ function isRenameableNode(node) {
3770
+ return node.kind === 54 /* NodeId */ || node.kind === 41 /* DirectedGraph */ || node.kind === 42 /* UndirectedGraph */;
3771
+ }
3772
+ function isRenamableIdentifier(node) {
3773
+ return node.kind !== 31 /* QuotedTextIdentifier */;
3774
+ }
3775
+
3776
+ // src/error.ts
3777
+ var diagnosicSource = "DOT";
3778
+ var errorCodeLength = 4;
3779
+ var subErrorCodeLength = errorCodeLength - 1;
3780
+ function formatError(error) {
3781
+ const subCode = (error.sub | 0).toString().padStart(subErrorCodeLength, "0");
3782
+ return diagnosicSource + error.source + subCode;
3783
+ }
3784
+
3785
+ // src/service/validation.ts
3786
+ function convertDiagnostic(document, source) {
3787
+ return {
3788
+ range: {
3789
+ start: document.positionAt(source.start),
3790
+ end: document.positionAt(source.end)
3791
+ },
3792
+ severity: source.category,
3793
+ code: formatError(source.code),
3794
+ source: diagnosicSource,
3795
+ message: source.message
3796
+ };
3797
+ }
3798
+ function validateDocument(doc, sourceFile) {
3799
+ const diagnostics = sourceFile.diagnostics;
3800
+ if (!diagnostics || diagnostics.length <= 0) return [];
3801
+ return diagnostics.map((d) => convertDiagnostic(doc, d));
3802
+ }
3803
+
3804
+ // src/service/service.ts
3805
+ function parseDocument(doc) {
3806
+ const parser = new Parser();
3807
+ const content = typeof doc === "string" ? doc : doc.getText();
3808
+ const sourceFile = parser.parse(content);
3809
+ bindSourceFile(sourceFile);
3810
+ checkSourceFile(sourceFile);
3811
+ return sourceFile;
3812
+ }
3813
+ function createService() {
3814
+ return {
3815
+ parseDocument,
3816
+ validateDocument,
3817
+ hover,
3818
+ findReferences,
3819
+ findDefinition,
3820
+ renameSymbol,
3821
+ getCompletions,
3822
+ getDocumentColors,
3823
+ getColorRepresentations,
3824
+ getCodeActions,
3825
+ executeCommand,
3826
+ getAvailableCommands
3827
+ // formatDocument,
3828
+ };
3829
+ }
3830
+ export {
3831
+ CharacterCodes,
3832
+ CheckError,
3833
+ DefaultScanner,
3834
+ DiagnosticCategory,
3835
+ ErrorSource,
3836
+ GraphContext,
3837
+ ParseError,
3838
+ Parser,
3839
+ ParsingContext,
3840
+ ScanError,
3841
+ SyntaxKind,
3842
+ SyntaxNodeFlags,
3843
+ TokenFlags,
3844
+ createService,
3845
+ forEachChild,
3846
+ getTextAsToken,
3847
+ getTokenAsText,
3848
+ isIdentifier,
3849
+ isIdentifierNode,
3850
+ isIdentifierStart,
3851
+ isLineBreak,
3852
+ skipTrivia
3853
+ };