@ts-graphviz/ast 2.0.7 → 3.0.1

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.
package/lib/ast.cjs DELETED
@@ -1,3705 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const common = require("@ts-graphviz/common");
4
- class Builder {
5
- /**
6
- * Constructor of Builder
7
- * @param options - Options to initialize Builder
8
- */
9
- constructor(options) {
10
- this.options = options;
11
- }
12
- /**
13
- * Get the current file range or null
14
- * @internal
15
- */
16
- getLocation() {
17
- return this.options?.locationFunction?.() ?? null;
18
- }
19
- /**
20
- * Create an {@link ASTNode} of the specified type
21
- *
22
- * @param type - Type of the {@link ASTNode}
23
- * @param props - Properties of the {@link ASTNode}
24
- * @param children - Children of the {@link ASTNode}
25
- * @returns An {@link ASTNode}
26
- */
27
- createElement(type, props, children = []) {
28
- return {
29
- location: this.getLocation(),
30
- ...props,
31
- type,
32
- children
33
- };
34
- }
35
- }
36
- const createElement = Builder.prototype.createElement.bind(new Builder());
37
- const AttributeListPrintPlugin = {
38
- match(ast) {
39
- return ast.type === "AttributeList";
40
- },
41
- *print(context, ast) {
42
- if (ast.children.length === 0) {
43
- yield `${ast.kind.toLocaleLowerCase()} [];`;
44
- } else {
45
- yield `${ast.kind.toLocaleLowerCase()} [`;
46
- yield* context.printChildren(ast.children);
47
- yield "];";
48
- }
49
- }
50
- };
51
- const AttributePrintPlugin = {
52
- match(ast) {
53
- return ast.type === "Attribute";
54
- },
55
- *print(context, ast) {
56
- yield* context.print(ast.key);
57
- yield " = ";
58
- yield* context.print(ast.value);
59
- yield ";";
60
- }
61
- };
62
- const EOL_PATTERN = /\r?\n/;
63
- const paddingMap = {
64
- Block: " * ",
65
- Macro: "# ",
66
- Slash: "// "
67
- };
68
- const CommentPrintPlugin = {
69
- match(ast) {
70
- return ast.type === "Comment";
71
- },
72
- *print(context, ast) {
73
- const padding = paddingMap[ast.kind];
74
- if (ast.kind === "Block") {
75
- yield* ["/**", context.EOL];
76
- }
77
- const lines = ast.value.split(EOL_PATTERN);
78
- const lineLength = lines.length;
79
- for (let i = 0; i < lineLength; i++) {
80
- yield padding;
81
- yield lines[i];
82
- if (i < lineLength - 1) {
83
- yield context.EOL;
84
- }
85
- }
86
- if (ast.kind === "Block") {
87
- yield* [context.EOL, " */"];
88
- }
89
- }
90
- };
91
- const DotPrintPlugin = {
92
- match(ast) {
93
- return ast.type === "Dot";
94
- },
95
- *print(context, ast) {
96
- yield* context.join(ast.children, context.EOL);
97
- }
98
- };
99
- const EdgePrintPlugin = {
100
- match(ast) {
101
- return ast.type === "Edge";
102
- },
103
- *print(context, ast) {
104
- yield* context.join(ast.targets, context.directed ? " -> " : " -- ");
105
- if (ast.children.length === 0) {
106
- yield ";";
107
- } else {
108
- yield " [";
109
- yield* context.printChildren(ast.children);
110
- yield "];";
111
- }
112
- }
113
- };
114
- const GraphPrintPlugin = {
115
- match(ast) {
116
- return ast.type === "Graph";
117
- },
118
- *print(context, ast) {
119
- context.directed = ast.directed;
120
- if (ast.strict) {
121
- yield "strict ";
122
- }
123
- yield ast.directed ? "digraph " : "graph ";
124
- if (ast.id) {
125
- yield* context.print(ast.id);
126
- yield " ";
127
- }
128
- yield "{";
129
- if (ast.children.length >= 1) {
130
- yield* context.printChildren(ast.children);
131
- }
132
- yield "}";
133
- }
134
- };
135
- const escape = (value) => value.replace(/(?<!\\)"|[\r\n]/g, escapeReplacer);
136
- const escapeMap = {
137
- "\r": String.raw`\r`,
138
- "\n": String.raw`\n`,
139
- '"': String.raw`\"`
140
- };
141
- function escapeReplacer(match) {
142
- return escapeMap[match];
143
- }
144
- const LiteralPrintPlugin = {
145
- match(ast) {
146
- return ast.type === "Literal";
147
- },
148
- *print(context, ast) {
149
- switch (ast.quoted) {
150
- case "html":
151
- yield "<";
152
- yield ast.value;
153
- yield ">";
154
- return;
155
- case true:
156
- yield '"';
157
- yield escape(ast.value);
158
- yield '"';
159
- return;
160
- default:
161
- yield ast.value;
162
- return;
163
- }
164
- }
165
- };
166
- const NodePrintPlugin = {
167
- match(ast) {
168
- return ast.type === "Node";
169
- },
170
- *print(context, ast) {
171
- yield* context.print(ast.id);
172
- if (ast.children.length >= 1) {
173
- yield " [";
174
- yield* context.printChildren(ast.children);
175
- yield "]";
176
- }
177
- yield ";";
178
- }
179
- };
180
- const NodeRefGroupPrintPlugin = {
181
- match(ast) {
182
- return ast.type === "NodeRefGroup";
183
- },
184
- *print(context, ast) {
185
- yield "{";
186
- yield* context.join(ast.children, " ");
187
- yield "}";
188
- }
189
- };
190
- const NodeRefPrintPlugin = {
191
- match(ast) {
192
- return ast.type === "NodeRef";
193
- },
194
- *print(context, ast) {
195
- yield* context.print(ast.id);
196
- if (ast.port) {
197
- yield ":";
198
- yield* context.print(ast.port);
199
- }
200
- if (ast.compass) {
201
- yield ":";
202
- yield* context.print(ast.compass);
203
- }
204
- }
205
- };
206
- const SubgraphPrintPlugin = {
207
- match(ast) {
208
- return ast.type === "Subgraph";
209
- },
210
- *print(context, ast) {
211
- yield "subgraph";
212
- if (ast.id) {
213
- yield " ";
214
- yield* context.print(ast.id);
215
- }
216
- yield " {";
217
- if (ast.children.length >= 1) {
218
- yield* context.printChildren(ast.children);
219
- }
220
- yield "}";
221
- }
222
- };
223
- const defaultPlugins$2 = [
224
- AttributeListPrintPlugin,
225
- AttributePrintPlugin,
226
- CommentPrintPlugin,
227
- DotPrintPlugin,
228
- EdgePrintPlugin,
229
- GraphPrintPlugin,
230
- LiteralPrintPlugin,
231
- NodePrintPlugin,
232
- NodeRefGroupPrintPlugin,
233
- NodeRefPrintPlugin,
234
- SubgraphPrintPlugin
235
- ];
236
- class Printer {
237
- /**
238
- * @param options Options to be used when generating the DOT string.
239
- */
240
- constructor(options = {}) {
241
- this.options = options;
242
- }
243
- /** @internal */
244
- #plugins = [...defaultPlugins$2];
245
- /**
246
- * Generates a DOT string from an ASTNode.
247
- * @param ast The ASTNode to be converted into a DOT string.
248
- * @returns The DOT string generated from the ASTNode.
249
- */
250
- print(ast) {
251
- return Array.from(this.toChunks(ast)).join("");
252
- }
253
- toChunks(ast) {
254
- const plugins = [...this.#plugins];
255
- const {
256
- indentSize = 2,
257
- indentStyle = "space",
258
- endOfLine = "lf"
259
- } = this.options;
260
- const EOL = endOfLine === "crlf" ? "\r\n" : "\n";
261
- const PADDING = indentStyle === "space" ? " ".repeat(indentSize) : " ";
262
- const context = {
263
- directed: true,
264
- EOL,
265
- *printChildren(children) {
266
- yield* indent(function* () {
267
- yield EOL;
268
- yield* context.join(children, EOL);
269
- });
270
- yield EOL;
271
- },
272
- *print(a) {
273
- for (const plugin of plugins) {
274
- if (plugin.match(a)) {
275
- yield* plugin.print(this, a);
276
- return;
277
- }
278
- }
279
- throw new Error(
280
- `No matching plugin found for AST node: ${JSON.stringify(a)}`
281
- );
282
- },
283
- *join(array, separator) {
284
- const childrenLength = array.length;
285
- for (let i = 0; i < childrenLength; i++) {
286
- yield* context.print(array[i]);
287
- if (i < childrenLength - 1) {
288
- yield separator;
289
- }
290
- }
291
- }
292
- };
293
- return {
294
- [Symbol.iterator]: function* () {
295
- yield* context.print(ast);
296
- }
297
- };
298
- function* indent(tokens) {
299
- for (const token of tokens()) {
300
- yield token;
301
- if (token === EOL) {
302
- yield PADDING;
303
- }
304
- }
305
- }
306
- }
307
- }
308
- function stringify(ast, options) {
309
- const result = new Printer(options).print(ast);
310
- if (!result) {
311
- throw new Error();
312
- }
313
- return result;
314
- }
315
- const peggyParser = (
316
- // @generated by Peggy 4.0.3.
317
- //
318
- // https://peggyjs.org/
319
- // @ts-ignore
320
- function() {
321
- function peg$subclass(child, parent) {
322
- function C() {
323
- this.constructor = child;
324
- }
325
- C.prototype = parent.prototype;
326
- child.prototype = new C();
327
- }
328
- function peg$SyntaxError(message, expected, found, location) {
329
- var self = Error.call(this, message);
330
- if (Object.setPrototypeOf) {
331
- Object.setPrototypeOf(self, peg$SyntaxError.prototype);
332
- }
333
- self.expected = expected;
334
- self.found = found;
335
- self.location = location;
336
- self.name = "SyntaxError";
337
- return self;
338
- }
339
- peg$subclass(peg$SyntaxError, Error);
340
- function peg$padEnd(str, targetLength, padString) {
341
- padString = padString || " ";
342
- if (str.length > targetLength) {
343
- return str;
344
- }
345
- targetLength -= str.length;
346
- padString += padString.repeat(targetLength);
347
- return str + padString.slice(0, targetLength);
348
- }
349
- peg$SyntaxError.prototype.format = function(sources) {
350
- var str = "Error: " + this.message;
351
- if (this.location) {
352
- var src = null;
353
- var k;
354
- for (k = 0; k < sources.length; k++) {
355
- if (sources[k].source === this.location.source) {
356
- src = sources[k].text.split(/\r\n|\n|\r/g);
357
- break;
358
- }
359
- }
360
- var s = this.location.start;
361
- var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
362
- var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
363
- if (src) {
364
- var e = this.location.end;
365
- var filler = peg$padEnd("", offset_s.line.toString().length, " ");
366
- var line = src[s.line - 1];
367
- var last = s.line === e.line ? e.column : line.length + 1;
368
- var hatLen = last - s.column || 1;
369
- str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
370
- } else {
371
- str += "\n at " + loc;
372
- }
373
- }
374
- return str;
375
- };
376
- peg$SyntaxError.buildMessage = function(expected, found) {
377
- var DESCRIBE_EXPECTATION_FNS = {
378
- // @ts-ignore
379
- literal: function(expectation) {
380
- return '"' + literalEscape(expectation.text) + '"';
381
- },
382
- // @ts-ignore
383
- class: function(expectation) {
384
- var escapedParts = expectation.parts.map(function(part) {
385
- return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
386
- });
387
- return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
388
- },
389
- // @ts-ignore
390
- any: function() {
391
- return "any character";
392
- },
393
- // @ts-ignore
394
- end: function() {
395
- return "end of input";
396
- },
397
- // @ts-ignore
398
- other: function(expectation) {
399
- return expectation.description;
400
- }
401
- };
402
- function hex(ch) {
403
- return ch.charCodeAt(0).toString(16).toUpperCase();
404
- }
405
- function literalEscape(s) {
406
- return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
407
- return "\\x0" + hex(ch);
408
- }).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
409
- return "\\x" + hex(ch);
410
- });
411
- }
412
- function classEscape(s) {
413
- return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
414
- return "\\x0" + hex(ch);
415
- }).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
416
- return "\\x" + hex(ch);
417
- });
418
- }
419
- function describeExpectation(expectation) {
420
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
421
- }
422
- function describeExpected(expected2) {
423
- var descriptions = expected2.map(describeExpectation);
424
- var i, j;
425
- descriptions.sort();
426
- if (descriptions.length > 0) {
427
- for (i = 1, j = 1; i < descriptions.length; i++) {
428
- if (descriptions[i - 1] !== descriptions[i]) {
429
- descriptions[j] = descriptions[i];
430
- j++;
431
- }
432
- }
433
- descriptions.length = j;
434
- }
435
- switch (descriptions.length) {
436
- case 1:
437
- return descriptions[0];
438
- case 2:
439
- return descriptions[0] + " or " + descriptions[1];
440
- default:
441
- return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
442
- }
443
- }
444
- function describeFound(found2) {
445
- return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
446
- }
447
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
448
- };
449
- function peg$parse(input, options) {
450
- options = options !== void 0 ? options : {};
451
- var peg$FAILED = {};
452
- var peg$source = options.grammarSource;
453
- var peg$startRuleFunctions = { Dot: peg$parseDot, Graph: peg$parseGraph, Subgraph: peg$parseSubgraph, Node: peg$parseNode, Edge: peg$parseEdge, AttributeList: peg$parseAttributeList, Attribute: peg$parseAttribute, ClusterStatements: peg$parseClusterStatements };
454
- var peg$startRuleFunction = peg$parseDot;
455
- var peg$c0 = "strict";
456
- var peg$c1 = "graph";
457
- var peg$c2 = "digraph";
458
- var peg$c3 = "{";
459
- var peg$c4 = "}";
460
- var peg$c6 = "node";
461
- var peg$c7 = "edge";
462
- var peg$c8 = "=";
463
- var peg$c9 = "[";
464
- var peg$c10 = "]";
465
- var peg$c11 = "->";
466
- var peg$c12 = "--";
467
- var peg$c13 = ":";
468
- var peg$c14 = "subgraph";
469
- var peg$c15 = "n";
470
- var peg$c16 = "ne";
471
- var peg$c17 = "e";
472
- var peg$c18 = "se";
473
- var peg$c19 = "s";
474
- var peg$c20 = "sw";
475
- var peg$c21 = "w";
476
- var peg$c22 = "nw";
477
- var peg$c23 = '"';
478
- var peg$c24 = "/*";
479
- var peg$c25 = "*/";
480
- var peg$c26 = "//";
481
- var peg$c27 = "#";
482
- var peg$c28 = "-";
483
- var peg$c29 = ".";
484
- var peg$c30 = "<";
485
- var peg$c31 = ">";
486
- var peg$c32 = "\\";
487
- var peg$c33 = "\n";
488
- var peg$c34 = "\r\n";
489
- var peg$r0 = /^[,;]/;
490
- var peg$r1 = /^[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4-\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE-\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A-\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
491
- var peg$r2 = /^[$0-9A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u0660-\u0669\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4-\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09E6-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0AE6-\u0AEF\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BEF\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C66-\u0C6F\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D66-\u0D6F\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F29\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u1810-\u1819\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u19D0-\u19D9\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5-\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40-\uFB41\uFB43-\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/;
492
- var peg$r3 = /^[0-9]/;
493
- var peg$r4 = /^[<>]/;
494
- var peg$r5 = /^[\n\r"\u2028-\u2029]/;
495
- var peg$r7 = /^[\r\u2028-\u2029]/;
496
- var peg$r9 = /^[\t-\n\r ]/;
497
- var peg$r10 = /^[\n\r]/;
498
- var peg$r11 = /^[ \t]/;
499
- var peg$e0 = peg$literalExpectation("strict", true);
500
- var peg$e1 = peg$literalExpectation("graph", true);
501
- var peg$e2 = peg$literalExpectation("digraph", true);
502
- var peg$e3 = peg$literalExpectation("{", false);
503
- var peg$e4 = peg$literalExpectation("}", false);
504
- var peg$e5 = peg$literalExpectation(";", false);
505
- var peg$e6 = peg$literalExpectation("node", true);
506
- var peg$e7 = peg$literalExpectation("edge", true);
507
- var peg$e8 = peg$literalExpectation("=", false);
508
- var peg$e9 = peg$classExpectation([",", ";"], false, false);
509
- var peg$e10 = peg$literalExpectation("[", false);
510
- var peg$e11 = peg$literalExpectation("]", false);
511
- var peg$e12 = peg$literalExpectation("->", false);
512
- var peg$e13 = peg$literalExpectation("--", false);
513
- var peg$e14 = peg$otherExpectation("port");
514
- var peg$e15 = peg$literalExpectation(":", false);
515
- var peg$e16 = peg$literalExpectation("subgraph", true);
516
- var peg$e17 = peg$literalExpectation("n", false);
517
- var peg$e18 = peg$literalExpectation("ne", false);
518
- var peg$e19 = peg$literalExpectation("e", false);
519
- var peg$e20 = peg$literalExpectation("se", false);
520
- var peg$e21 = peg$literalExpectation("s", false);
521
- var peg$e22 = peg$literalExpectation("sw", false);
522
- var peg$e23 = peg$literalExpectation("w", false);
523
- var peg$e24 = peg$literalExpectation("nw", false);
524
- var peg$e25 = peg$literalExpectation('"', false);
525
- var peg$e26 = peg$literalExpectation("/*", false);
526
- var peg$e27 = peg$literalExpectation("*/", false);
527
- var peg$e28 = peg$anyExpectation();
528
- var peg$e29 = peg$literalExpectation("//", false);
529
- var peg$e30 = peg$literalExpectation("#", false);
530
- var peg$e31 = peg$otherExpectation("UNICODE_STRING");
531
- var peg$e32 = peg$classExpectation(["$", ["A", "Z"], "_", ["a", "z"], "ª", "µ", "º", ["À", "Ö"], ["Ø", "ö"], ["ø", "ˁ"], ["ˆ", "ˑ"], ["ˠ", "ˤ"], "ˬ", "ˮ", ["Ͱ", "ʹ"], ["Ͷ", "ͷ"], ["ͺ", "ͽ"], "Ά", ["Έ", "Ί"], "Ό", ["Ύ", "Ρ"], ["Σ", "ϵ"], ["Ϸ", "ҁ"], ["Ҋ", "ԧ"], ["Ա", "Ֆ"], "ՙ", ["ա", "և"], ["א", "ת"], ["װ", "ײ"], ["ؠ", "ي"], ["ٮ", "ٯ"], ["ٱ", "ۓ"], "ە", ["ۥ", "ۦ"], ["ۮ", "ۯ"], ["ۺ", "ۼ"], "ۿ", "ܐ", ["ܒ", "ܯ"], ["ݍ", "ޥ"], "ޱ", ["ߊ", "ߪ"], ["ߴ", "ߵ"], "ߺ", ["ࠀ", "ࠕ"], "ࠚ", "ࠤ", "ࠨ", ["ࡀ", "ࡘ"], "ࢠ", ["ࢢ", "ࢬ"], ["ऄ", "ह"], "ऽ", "ॐ", ["क़", "ॡ"], ["ॱ", "ॷ"], ["ॹ", "ॿ"], ["অ", "ঌ"], ["এ", "ঐ"], ["ও", "ন"], ["প", "র"], "ল", ["শ", "হ"], "ঽ", "ৎ", ["ড়", "ঢ়"], ["য়", "ৡ"], ["ৰ", "ৱ"], ["ਅ", "ਊ"], ["ਏ", "ਐ"], ["ਓ", "ਨ"], ["ਪ", "ਰ"], ["ਲ", "ਲ਼"], ["ਵ", "ਸ਼"], ["ਸ", "ਹ"], ["ਖ਼", "ੜ"], "ਫ਼", ["ੲ", "ੴ"], ["અ", "ઍ"], ["એ", "ઑ"], ["ઓ", "ન"], ["પ", "ર"], ["લ", "ળ"], ["વ", "હ"], "ઽ", "ૐ", ["ૠ", "ૡ"], ["ଅ", "ଌ"], ["ଏ", "ଐ"], ["ଓ", "ନ"], ["ପ", "ର"], ["ଲ", "ଳ"], ["ଵ", "ହ"], "ଽ", ["ଡ଼", "ଢ଼"], ["ୟ", "ୡ"], "ୱ", "ஃ", ["அ", "ஊ"], ["எ", "ஐ"], ["ஒ", "க"], ["ங", "ச"], "ஜ", ["ஞ", "ட"], ["ண", "த"], ["ந", "ப"], ["ம", "ஹ"], "ௐ", ["అ", "ఌ"], ["ఎ", "ఐ"], ["ఒ", "న"], ["ప", "ళ"], ["వ", "హ"], "ఽ", ["ౘ", "ౙ"], ["ౠ", "ౡ"], ["ಅ", "ಌ"], ["ಎ", "ಐ"], ["ಒ", "ನ"], ["ಪ", "ಳ"], ["ವ", "ಹ"], "ಽ", "ೞ", ["ೠ", "ೡ"], ["ೱ", "ೲ"], ["അ", "ഌ"], ["എ", "ഐ"], ["ഒ", "ഺ"], "ഽ", "ൎ", ["ൠ", "ൡ"], ["ൺ", "ൿ"], ["අ", "ඖ"], ["ක", "න"], ["ඳ", "ර"], "ල", ["ව", "ෆ"], ["ก", "ะ"], ["า", "ำ"], ["เ", "ๆ"], ["ກ", "ຂ"], "ຄ", ["ງ", "ຈ"], "ຊ", "ຍ", ["ດ", "ທ"], ["ນ", "ຟ"], ["ມ", "ຣ"], "ລ", "ວ", ["ສ", "ຫ"], ["ອ", "ະ"], ["າ", "ຳ"], "ຽ", ["ເ", "ໄ"], "ໆ", ["ໜ", "ໟ"], "ༀ", ["ཀ", "ཇ"], ["ཉ", "ཬ"], ["ྈ", "ྌ"], ["က", "ဪ"], "ဿ", ["ၐ", "ၕ"], ["ၚ", "ၝ"], "ၡ", ["ၥ", "ၦ"], ["ၮ", "ၰ"], ["ၵ", "ႁ"], "ႎ", ["Ⴀ", "Ⴥ"], "Ⴧ", "Ⴭ", ["ა", "ჺ"], ["ჼ", "ቈ"], ["ቊ", "ቍ"], ["ቐ", "ቖ"], "ቘ", ["ቚ", "ቝ"], ["በ", "ኈ"], ["ኊ", "ኍ"], ["ነ", "ኰ"], ["ኲ", "ኵ"], ["ኸ", "ኾ"], "ዀ", ["ዂ", "ዅ"], ["ወ", "ዖ"], ["ዘ", "ጐ"], ["ጒ", "ጕ"], ["ጘ", "ፚ"], ["ᎀ", "ᎏ"], ["Ꭰ", "Ᏼ"], ["ᐁ", "ᙬ"], ["ᙯ", "ᙿ"], ["ᚁ", "ᚚ"], ["ᚠ", "ᛪ"], ["ᛮ", "ᛰ"], ["ᜀ", "ᜌ"], ["ᜎ", "ᜑ"], ["ᜠ", "ᜱ"], ["ᝀ", "ᝑ"], ["ᝠ", "ᝬ"], ["ᝮ", "ᝰ"], ["ក", "ឳ"], "ៗ", "ៜ", ["ᠠ", "ᡷ"], ["ᢀ", "ᢨ"], "ᢪ", ["ᢰ", "ᣵ"], ["ᤀ", "ᤜ"], ["ᥐ", "ᥭ"], ["ᥰ", "ᥴ"], ["ᦀ", "ᦫ"], ["ᧁ", "ᧇ"], ["ᨀ", "ᨖ"], ["ᨠ", "ᩔ"], "ᪧ", ["ᬅ", "ᬳ"], ["ᭅ", "ᭋ"], ["ᮃ", "ᮠ"], ["ᮮ", "ᮯ"], ["ᮺ", "ᯥ"], ["ᰀ", "ᰣ"], ["ᱍ", "ᱏ"], ["ᱚ", "ᱽ"], ["ᳩ", "ᳬ"], ["ᳮ", "ᳱ"], ["ᳵ", "ᳶ"], ["ᴀ", "ᶿ"], ["Ḁ", "ἕ"], ["Ἐ", "Ἕ"], ["ἠ", "ὅ"], ["Ὀ", "Ὅ"], ["ὐ", "ὗ"], "Ὑ", "Ὓ", "Ὕ", ["Ὗ", "ώ"], ["ᾀ", "ᾴ"], ["ᾶ", "ᾼ"], "ι", ["ῂ", "ῄ"], ["ῆ", "ῌ"], ["ῐ", "ΐ"], ["ῖ", "Ί"], ["ῠ", "Ῥ"], ["ῲ", "ῴ"], ["ῶ", "ῼ"], "ⁱ", "ⁿ", ["ₐ", "ₜ"], "ℂ", "ℇ", ["ℊ", "ℓ"], "ℕ", ["ℙ", "ℝ"], "ℤ", "Ω", "ℨ", ["K", "ℭ"], ["ℯ", "ℹ"], ["ℼ", "ℿ"], ["ⅅ", "ⅉ"], "ⅎ", ["Ⅰ", "ↈ"], ["Ⰰ", "Ⱞ"], ["ⰰ", "ⱞ"], ["Ⱡ", "ⳤ"], ["Ⳬ", "ⳮ"], ["Ⳳ", "ⳳ"], ["ⴀ", "ⴥ"], "ⴧ", "ⴭ", ["ⴰ", "ⵧ"], "ⵯ", ["ⶀ", "ⶖ"], ["ⶠ", "ⶦ"], ["ⶨ", "ⶮ"], ["ⶰ", "ⶶ"], ["ⶸ", "ⶾ"], ["ⷀ", "ⷆ"], ["ⷈ", "ⷎ"], ["ⷐ", "ⷖ"], ["ⷘ", "ⷞ"], "ⸯ", ["々", "〇"], ["〡", "〩"], ["〱", "〵"], ["〸", "〼"], ["ぁ", "ゖ"], ["ゝ", "ゟ"], ["ァ", "ヺ"], ["ー", "ヿ"], ["ㄅ", "ㄭ"], ["ㄱ", "ㆎ"], ["ㆠ", "ㆺ"], ["ㇰ", "ㇿ"], ["㐀", "䶵"], ["一", "鿌"], ["ꀀ", "ꒌ"], ["ꓐ", "ꓽ"], ["ꔀ", "ꘌ"], ["ꘐ", "ꘟ"], ["ꘪ", "ꘫ"], ["Ꙁ", "ꙮ"], ["ꙿ", "ꚗ"], ["ꚠ", "ꛯ"], ["ꜗ", "ꜟ"], ["Ꜣ", "ꞈ"], ["Ꞌ", "ꞎ"], ["Ꞑ", "ꞓ"], ["Ꞡ", "Ɦ"], ["ꟸ", "ꠁ"], ["ꠃ", "ꠅ"], ["ꠇ", "ꠊ"], ["ꠌ", "ꠢ"], ["ꡀ", "ꡳ"], ["ꢂ", "ꢳ"], ["ꣲ", "ꣷ"], "ꣻ", ["ꤊ", "ꤥ"], ["ꤰ", "ꥆ"], ["ꥠ", "ꥼ"], ["ꦄ", "ꦲ"], "ꧏ", ["ꨀ", "ꨨ"], ["ꩀ", "ꩂ"], ["ꩄ", "ꩋ"], ["ꩠ", "ꩶ"], "ꩺ", ["ꪀ", "ꪯ"], "ꪱ", ["ꪵ", "ꪶ"], ["ꪹ", "ꪽ"], "ꫀ", "ꫂ", ["ꫛ", "ꫝ"], ["ꫠ", "ꫪ"], ["ꫲ", "ꫴ"], ["ꬁ", "ꬆ"], ["ꬉ", "ꬎ"], ["ꬑ", "ꬖ"], ["ꬠ", "ꬦ"], ["ꬨ", "ꬮ"], ["ꯀ", "ꯢ"], ["가", "힣"], ["ힰ", "ퟆ"], ["ퟋ", "ퟻ"], ["豈", "舘"], ["並", "龎"], ["ff", "st"], ["ﬓ", "ﬗ"], "יִ", ["ײַ", "ﬨ"], ["שׁ", "זּ"], ["טּ", "לּ"], "מּ", ["נּ", "סּ"], ["ףּ", "פּ"], ["צּ", "ﮱ"], ["ﯓ", "ﴽ"], ["ﵐ", "ﶏ"], ["ﶒ", "ﷇ"], ["ﷰ", "ﷻ"], ["ﹰ", "ﹴ"], ["ﹶ", "ﻼ"], ["A", "Z"], ["a", "z"], ["ヲ", "ᄒ"], ["ᅡ", "ᅦ"], ["ᅧ", "ᅬ"], ["ᅭ", "ᅲ"], ["ᅳ", "ᅵ"]], false, false);
532
- var peg$e33 = peg$classExpectation(["$", ["0", "9"], ["A", "Z"], "_", ["a", "z"], "ª", "µ", "º", ["À", "Ö"], ["Ø", "ö"], ["ø", "ˁ"], ["ˆ", "ˑ"], ["ˠ", "ˤ"], "ˬ", "ˮ", ["Ͱ", "ʹ"], ["Ͷ", "ͷ"], ["ͺ", "ͽ"], "Ά", ["Έ", "Ί"], "Ό", ["Ύ", "Ρ"], ["Σ", "ϵ"], ["Ϸ", "ҁ"], ["Ҋ", "ԧ"], ["Ա", "Ֆ"], "ՙ", ["ա", "և"], ["א", "ת"], ["װ", "ײ"], ["ؠ", "ي"], ["٠", "٩"], ["ٮ", "ٯ"], ["ٱ", "ۓ"], "ە", ["ۥ", "ۦ"], ["ۮ", "ۼ"], "ۿ", "ܐ", ["ܒ", "ܯ"], ["ݍ", "ޥ"], "ޱ", ["߀", "ߪ"], ["ߴ", "ߵ"], "ߺ", ["ࠀ", "ࠕ"], "ࠚ", "ࠤ", "ࠨ", ["ࡀ", "ࡘ"], "ࢠ", ["ࢢ", "ࢬ"], ["ऄ", "ह"], "ऽ", "ॐ", ["क़", "ॡ"], ["०", "९"], ["ॱ", "ॷ"], ["ॹ", "ॿ"], ["অ", "ঌ"], ["এ", "ঐ"], ["ও", "ন"], ["প", "র"], "ল", ["শ", "হ"], "ঽ", "ৎ", ["ড়", "ঢ়"], ["য়", "ৡ"], ["০", "ৱ"], ["ਅ", "ਊ"], ["ਏ", "ਐ"], ["ਓ", "ਨ"], ["ਪ", "ਰ"], ["ਲ", "ਲ਼"], ["ਵ", "ਸ਼"], ["ਸ", "ਹ"], ["ਖ਼", "ੜ"], "ਫ਼", ["੦", "੯"], ["ੲ", "ੴ"], ["અ", "ઍ"], ["એ", "ઑ"], ["ઓ", "ન"], ["પ", "ર"], ["લ", "ળ"], ["વ", "હ"], "ઽ", "ૐ", ["ૠ", "ૡ"], ["૦", "૯"], ["ଅ", "ଌ"], ["ଏ", "ଐ"], ["ଓ", "ନ"], ["ପ", "ର"], ["ଲ", "ଳ"], ["ଵ", "ହ"], "ଽ", ["ଡ଼", "ଢ଼"], ["ୟ", "ୡ"], ["୦", "୯"], "ୱ", "ஃ", ["அ", "ஊ"], ["எ", "ஐ"], ["ஒ", "க"], ["ங", "ச"], "ஜ", ["ஞ", "ட"], ["ண", "த"], ["ந", "ப"], ["ம", "ஹ"], "ௐ", ["௦", "௯"], ["అ", "ఌ"], ["ఎ", "ఐ"], ["ఒ", "న"], ["ప", "ళ"], ["వ", "హ"], "ఽ", ["ౘ", "ౙ"], ["ౠ", "ౡ"], ["౦", "౯"], ["ಅ", "ಌ"], ["ಎ", "ಐ"], ["ಒ", "ನ"], ["ಪ", "ಳ"], ["ವ", "ಹ"], "ಽ", "ೞ", ["ೠ", "ೡ"], ["೦", "೯"], ["ೱ", "ೲ"], ["അ", "ഌ"], ["എ", "ഐ"], ["ഒ", "ഺ"], "ഽ", "ൎ", ["ൠ", "ൡ"], ["൦", "൯"], ["ൺ", "ൿ"], ["අ", "ඖ"], ["ක", "න"], ["ඳ", "ර"], "ල", ["ව", "ෆ"], ["ก", "ะ"], ["า", "ำ"], ["เ", "ๆ"], ["๐", "๙"], ["ກ", "ຂ"], "ຄ", ["ງ", "ຈ"], "ຊ", "ຍ", ["ດ", "ທ"], ["ນ", "ຟ"], ["ມ", "ຣ"], "ລ", "ວ", ["ສ", "ຫ"], ["ອ", "ະ"], ["າ", "ຳ"], "ຽ", ["ເ", "ໄ"], "ໆ", ["໐", "໙"], ["ໜ", "ໟ"], "ༀ", ["༠", "༩"], ["ཀ", "ཇ"], ["ཉ", "ཬ"], ["ྈ", "ྌ"], ["က", "ဪ"], ["ဿ", "၉"], ["ၐ", "ၕ"], ["ၚ", "ၝ"], "ၡ", ["ၥ", "ၦ"], ["ၮ", "ၰ"], ["ၵ", "ႁ"], "ႎ", ["႐", "႙"], ["Ⴀ", "Ⴥ"], "Ⴧ", "Ⴭ", ["ა", "ჺ"], ["ჼ", "ቈ"], ["ቊ", "ቍ"], ["ቐ", "ቖ"], "ቘ", ["ቚ", "ቝ"], ["በ", "ኈ"], ["ኊ", "ኍ"], ["ነ", "ኰ"], ["ኲ", "ኵ"], ["ኸ", "ኾ"], "ዀ", ["ዂ", "ዅ"], ["ወ", "ዖ"], ["ዘ", "ጐ"], ["ጒ", "ጕ"], ["ጘ", "ፚ"], ["ᎀ", "ᎏ"], ["Ꭰ", "Ᏼ"], ["ᐁ", "ᙬ"], ["ᙯ", "ᙿ"], ["ᚁ", "ᚚ"], ["ᚠ", "ᛪ"], ["ᛮ", "ᛰ"], ["ᜀ", "ᜌ"], ["ᜎ", "ᜑ"], ["ᜠ", "ᜱ"], ["ᝀ", "ᝑ"], ["ᝠ", "ᝬ"], ["ᝮ", "ᝰ"], ["ក", "ឳ"], "ៗ", "ៜ", ["០", "៩"], ["᠐", "᠙"], ["ᠠ", "ᡷ"], ["ᢀ", "ᢨ"], "ᢪ", ["ᢰ", "ᣵ"], ["ᤀ", "ᤜ"], ["᥆", "ᥭ"], ["ᥰ", "ᥴ"], ["ᦀ", "ᦫ"], ["ᧁ", "ᧇ"], ["᧐", "᧙"], ["ᨀ", "ᨖ"], ["ᨠ", "ᩔ"], ["᪀", "᪉"], ["᪐", "᪙"], "ᪧ", ["ᬅ", "ᬳ"], ["ᭅ", "ᭋ"], ["᭐", "᭙"], ["ᮃ", "ᮠ"], ["ᮮ", "ᯥ"], ["ᰀ", "ᰣ"], ["᱀", "᱉"], ["ᱍ", "ᱽ"], ["ᳩ", "ᳬ"], ["ᳮ", "ᳱ"], ["ᳵ", "ᳶ"], ["ᴀ", "ᶿ"], ["Ḁ", "ἕ"], ["Ἐ", "Ἕ"], ["ἠ", "ὅ"], ["Ὀ", "Ὅ"], ["ὐ", "ὗ"], "Ὑ", "Ὓ", "Ὕ", ["Ὗ", "ώ"], ["ᾀ", "ᾴ"], ["ᾶ", "ᾼ"], "ι", ["ῂ", "ῄ"], ["ῆ", "ῌ"], ["ῐ", "ΐ"], ["ῖ", "Ί"], ["ῠ", "Ῥ"], ["ῲ", "ῴ"], ["ῶ", "ῼ"], "ⁱ", "ⁿ", ["ₐ", "ₜ"], "ℂ", "ℇ", ["ℊ", "ℓ"], "ℕ", ["ℙ", "ℝ"], "ℤ", "Ω", "ℨ", ["K", "ℭ"], ["ℯ", "ℹ"], ["ℼ", "ℿ"], ["ⅅ", "ⅉ"], "ⅎ", ["Ⅰ", "ↈ"], ["Ⰰ", "Ⱞ"], ["ⰰ", "ⱞ"], ["Ⱡ", "ⳤ"], ["Ⳬ", "ⳮ"], ["Ⳳ", "ⳳ"], ["ⴀ", "ⴥ"], "ⴧ", "ⴭ", ["ⴰ", "ⵧ"], "ⵯ", ["ⶀ", "ⶖ"], ["ⶠ", "ⶦ"], ["ⶨ", "ⶮ"], ["ⶰ", "ⶶ"], ["ⶸ", "ⶾ"], ["ⷀ", "ⷆ"], ["ⷈ", "ⷎ"], ["ⷐ", "ⷖ"], ["ⷘ", "ⷞ"], "ⸯ", ["々", "〇"], ["〡", "〩"], ["〱", "〵"], ["〸", "〼"], ["ぁ", "ゖ"], ["ゝ", "ゟ"], ["ァ", "ヺ"], ["ー", "ヿ"], ["ㄅ", "ㄭ"], ["ㄱ", "ㆎ"], ["ㆠ", "ㆺ"], ["ㇰ", "ㇿ"], ["㐀", "䶵"], ["一", "鿌"], ["ꀀ", "ꒌ"], ["ꓐ", "ꓽ"], ["ꔀ", "ꘌ"], ["ꘐ", "ꘫ"], ["Ꙁ", "ꙮ"], ["ꙿ", "ꚗ"], ["ꚠ", "ꛯ"], ["ꜗ", "ꜟ"], ["Ꜣ", "ꞈ"], ["Ꞌ", "ꞎ"], ["Ꞑ", "ꞓ"], ["Ꞡ", "Ɦ"], ["ꟸ", "ꠁ"], ["ꠃ", "ꠅ"], ["ꠇ", "ꠊ"], ["ꠌ", "ꠢ"], ["ꡀ", "ꡳ"], ["ꢂ", "ꢳ"], ["꣐", "꣙"], ["ꣲ", "ꣷ"], "ꣻ", ["꤀", "ꤥ"], ["ꤰ", "ꥆ"], ["ꥠ", "ꥼ"], ["ꦄ", "ꦲ"], ["ꧏ", "꧙"], ["ꨀ", "ꨨ"], ["ꩀ", "ꩂ"], ["ꩄ", "ꩋ"], ["꩐", "꩙"], ["ꩠ", "ꩶ"], "ꩺ", ["ꪀ", "ꪯ"], "ꪱ", ["ꪵ", "ꪶ"], ["ꪹ", "ꪽ"], "ꫀ", "ꫂ", ["ꫛ", "ꫝ"], ["ꫠ", "ꫪ"], ["ꫲ", "ꫴ"], ["ꬁ", "ꬆ"], ["ꬉ", "ꬎ"], ["ꬑ", "ꬖ"], ["ꬠ", "ꬦ"], ["ꬨ", "ꬮ"], ["ꯀ", "ꯢ"], ["꯰", "꯹"], ["가", "힣"], ["ힰ", "ퟆ"], ["ퟋ", "ퟻ"], ["豈", "舘"], ["並", "龎"], ["ff", "st"], ["ﬓ", "ﬗ"], "יִ", ["ײַ", "ﬨ"], ["שׁ", "זּ"], ["טּ", "לּ"], "מּ", ["נּ", "סּ"], ["ףּ", "פּ"], ["צּ", "ﮱ"], ["ﯓ", "ﴽ"], ["ﵐ", "ﶏ"], ["ﶒ", "ﷇ"], ["ﷰ", "ﷻ"], ["ﹰ", "ﹴ"], ["ﹶ", "ﻼ"], ["0", "9"], ["A", "Z"], ["a", "z"], ["ヲ", "ᄒ"], ["ᅡ", "ᅦ"], ["ᅧ", "ᅬ"], ["ᅭ", "ᅲ"], ["ᅳ", "ᅵ"]], false, false);
533
- var peg$e34 = peg$otherExpectation("NUMBER");
534
- var peg$e35 = peg$literalExpectation("-", false);
535
- var peg$e36 = peg$literalExpectation(".", false);
536
- var peg$e37 = peg$classExpectation([["0", "9"]], false, false);
537
- var peg$e38 = peg$literalExpectation("<", false);
538
- var peg$e39 = peg$literalExpectation(">", false);
539
- var peg$e40 = peg$classExpectation(["<", ">"], false, false);
540
- var peg$e41 = peg$classExpectation(["\n", "\r", '"', ["\u2028", "\u2029"]], false, false);
541
- var peg$e42 = peg$literalExpectation("\\", false);
542
- var peg$e44 = peg$otherExpectation("end of line");
543
- var peg$e45 = peg$literalExpectation("\n", false);
544
- var peg$e46 = peg$literalExpectation("\r\n", false);
545
- var peg$e47 = peg$classExpectation(["\r", ["\u2028", "\u2029"]], false, false);
546
- var peg$e50 = peg$otherExpectation("whitespace");
547
- var peg$e51 = peg$otherExpectation("WHITESPACE");
548
- var peg$e52 = peg$classExpectation([[" ", "\n"], "\r", " "], false, false);
549
- var peg$e53 = peg$classExpectation(["\n", "\r"], false, false);
550
- var peg$e54 = peg$classExpectation([" ", " "], false, false);
551
- var peg$f0 = function(v) {
552
- return v;
553
- };
554
- var peg$f1 = function(v) {
555
- return v;
556
- };
557
- var peg$f2 = function(v) {
558
- return v;
559
- };
560
- var peg$f3 = function(v) {
561
- return v;
562
- };
563
- var peg$f4 = function(v) {
564
- return v;
565
- };
566
- var peg$f5 = function(v) {
567
- return v;
568
- };
569
- var peg$f6 = function(v) {
570
- return v;
571
- };
572
- var peg$f7 = function(v) {
573
- return v;
574
- };
575
- var peg$f8 = function(v) {
576
- return v;
577
- };
578
- var peg$f9 = function(v) {
579
- return v;
580
- };
581
- var peg$f10 = function(c1, graph, c2) {
582
- return b.createElement("Dot", {}, [...c1, graph, ...c2]);
583
- };
584
- var peg$f11 = function(_strict, _kind, id, children) {
585
- const strict = !!_strict;
586
- const kind = _kind.toLowerCase();
587
- const directed = kind === "digraph";
588
- for (const edgeop of edgeops) {
589
- if (directed) {
590
- if (edgeop.operator !== "->") {
591
- error(`In digraph, it's necessary to describe with "->" operator to create edge.`, edgeop.location);
592
- }
593
- } else {
594
- if (edgeop.operator !== "--") {
595
- error(`In graph, it's necessary to describe with "--" operator to create edge.`, edgeop.location);
596
- }
597
- }
598
- }
599
- return b.createElement(
600
- // @ts-ignore
601
- "Graph",
602
- // @ts-ignore
603
- id !== null ? {
604
- // @ts-ignore
605
- id,
606
- // @ts-ignore
607
- directed,
608
- // @ts-ignore
609
- strict
610
- } : {
611
- // @ts-ignore
612
- directed,
613
- // @ts-ignore
614
- strict
615
- },
616
- // @ts-ignore
617
- children
618
- );
619
- };
620
- var peg$f12 = function(keyValue) {
621
- return b.createElement(
622
- // @ts-ignore
623
- "Attribute",
624
- {
625
- // @ts-ignore
626
- ...keyValue
627
- },
628
- []
629
- );
630
- };
631
- var peg$f13 = function(_kind, children) {
632
- return b.createElement(
633
- // @ts-ignore
634
- "AttributeList",
635
- {
636
- // @ts-ignore
637
- kind: `${_kind.slice(0, 1).toUpperCase()}${_kind.slice(1).toLowerCase()}`
638
- },
639
- // @ts-ignore
640
- children
641
- );
642
- };
643
- var peg$f14 = function(id, rhs, _children) {
644
- return b.createElement(
645
- // @ts-ignore
646
- // @ts-ignore
647
- "Edge",
648
- {
649
- // @ts-ignore
650
- targets: [id, ...rhs]
651
- },
652
- // @ts-ignore
653
- _children ?? []
654
- );
655
- };
656
- var peg$f15 = function(id, _children) {
657
- return b.createElement(
658
- // @ts-ignore
659
- "Node",
660
- {
661
- // @ts-ignore
662
- id
663
- },
664
- // @ts-ignore
665
- _children ?? []
666
- );
667
- };
668
- var peg$f16 = function(key, value) {
669
- return { key, value };
670
- };
671
- var peg$f17 = function(kv) {
672
- return b.createElement(
673
- // @ts-ignore
674
- "Attribute",
675
- {
676
- // @ts-ignore
677
- ...kv,
678
- // @ts-ignore
679
- location: location()
680
- },
681
- []
682
- );
683
- };
684
- var peg$f18 = function(list) {
685
- return list;
686
- };
687
- var peg$f19 = function(id, v) {
688
- return v;
689
- };
690
- var peg$f20 = function(id, rest) {
691
- return b.createElement("NodeRefGroup", {}, [id, ...rest]);
692
- };
693
- var peg$f21 = function(operator) {
694
- return { operator, location: location() };
695
- };
696
- var peg$f22 = function(edgeop, id, rest) {
697
- edgeops.push(edgeop);
698
- return [id].concat(rest || []);
699
- };
700
- var peg$f23 = function(id, port) {
701
- return b.createElement(
702
- // @ts-ignore
703
- "NodeRef",
704
- {
705
- // @ts-ignore
706
- id,
707
- // @ts-ignore
708
- ...port
709
- },
710
- []
711
- );
712
- };
713
- var peg$f24 = function(port, compass) {
714
- return compass;
715
- };
716
- var peg$f25 = function(port, compass) {
717
- if (["n", "ne", "e", "se", "s", "sw", "w", "nw"].includes(port)) {
718
- return { compass: port };
719
- } else if (compass) {
720
- return { port, compass };
721
- }
722
- return { port };
723
- };
724
- var peg$f26 = function(id) {
725
- return id;
726
- };
727
- var peg$f27 = function(id, _children) {
728
- const children = _children ?? [];
729
- return b.createElement("Subgraph", id ? { id } : {}, children);
730
- };
731
- var peg$f28 = function(value) {
732
- return { value, quoted: false };
733
- };
734
- var peg$f29 = function(value) {
735
- return { value, quoted: true };
736
- };
737
- var peg$f30 = function(v) {
738
- return b.createElement(
739
- // @ts-ignore
740
- "Literal",
741
- {
742
- // @ts-ignore
743
- ...v
744
- },
745
- []
746
- );
747
- };
748
- var peg$f31 = function(value) {
749
- return b.createElement(
750
- // @ts-ignore
751
- "Literal",
752
- {
753
- // @ts-ignore
754
- value,
755
- // @ts-ignore
756
- quoted: false
757
- },
758
- []
759
- );
760
- };
761
- var peg$f32 = function(v) {
762
- return v;
763
- };
764
- var peg$f33 = function(v) {
765
- return b.createElement(
766
- // @ts-ignore
767
- "Comment",
768
- {
769
- // @ts-ignore
770
- kind: "Block",
771
- // @ts-ignore
772
- value: dedent(v.join("").replace(/[ \t]*\*/g, ""))
773
- },
774
- []
775
- );
776
- };
777
- var peg$f34 = function(lines) {
778
- return b.createElement(
779
- // @ts-ignore
780
- "Comment",
781
- {
782
- // @ts-ignore
783
- kind: "Slash",
784
- // @ts-ignore
785
- value: dedent(lines.join("\n"))
786
- },
787
- []
788
- );
789
- };
790
- var peg$f35 = function(v) {
791
- return v;
792
- };
793
- var peg$f36 = function(v) {
794
- return v.join("");
795
- };
796
- var peg$f37 = function(lines) {
797
- return b.createElement(
798
- // @ts-ignore
799
- "Comment",
800
- {
801
- // @ts-ignore
802
- kind: "Macro",
803
- // @ts-ignore
804
- value: dedent(lines.join("\n"))
805
- },
806
- []
807
- );
808
- };
809
- var peg$f38 = function(v) {
810
- return v;
811
- };
812
- var peg$f39 = function(v) {
813
- return v.join("");
814
- };
815
- var peg$f40 = function(first, rest) {
816
- return first + rest.join("");
817
- };
818
- var peg$f41 = function(first, rest) {
819
- return first + rest;
820
- };
821
- var peg$f42 = function(n) {
822
- return text();
823
- };
824
- var peg$f43 = function(v) {
825
- return b.createElement(
826
- // @ts-ignore
827
- "Literal",
828
- {
829
- // @ts-ignore
830
- value: v.slice(1, v.length - 1),
831
- // @ts-ignore
832
- quoted: "html"
833
- },
834
- []
835
- );
836
- };
837
- var peg$f44 = function(v) {
838
- return "<" + v.join("") + ">";
839
- };
840
- var peg$f45 = function(v) {
841
- return v;
842
- };
843
- var peg$f46 = function(v) {
844
- return v.join("");
845
- };
846
- var peg$f47 = function(chars) {
847
- return b.createElement(
848
- // @ts-ignore
849
- "Literal",
850
- {
851
- // @ts-ignore
852
- value: chars.join(""),
853
- // @ts-ignore
854
- quoted: true
855
- },
856
- []
857
- );
858
- };
859
- var peg$f48 = function() {
860
- return text();
861
- };
862
- var peg$f49 = function(v) {
863
- return v[1] === '"' ? '"' : v[0] + v[1];
864
- };
865
- var peg$f50 = function() {
866
- return "";
867
- };
868
- var peg$currPos = options.peg$currPos | 0;
869
- var peg$savedPos = peg$currPos;
870
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
871
- var peg$maxFailPos = peg$currPos;
872
- var peg$maxFailExpected = options.peg$maxFailExpected || [];
873
- var peg$silentFails = options.peg$silentFails | 0;
874
- var peg$result;
875
- if (options.startRule) {
876
- if (!(options.startRule in peg$startRuleFunctions)) {
877
- throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
878
- }
879
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
880
- }
881
- function text() {
882
- return input.substring(peg$savedPos, peg$currPos);
883
- }
884
- function location() {
885
- return peg$computeLocation(peg$savedPos, peg$currPos);
886
- }
887
- function error(message, location2) {
888
- location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
889
- throw peg$buildSimpleError(message, location2);
890
- }
891
- function peg$literalExpectation(text2, ignoreCase) {
892
- return { type: "literal", text: text2, ignoreCase };
893
- }
894
- function peg$classExpectation(parts, inverted, ignoreCase) {
895
- return { type: "class", parts, inverted, ignoreCase };
896
- }
897
- function peg$anyExpectation() {
898
- return { type: "any" };
899
- }
900
- function peg$endExpectation() {
901
- return { type: "end" };
902
- }
903
- function peg$otherExpectation(description) {
904
- return { type: "other", description };
905
- }
906
- function peg$computePosDetails(pos) {
907
- var details = peg$posDetailsCache[pos];
908
- var p;
909
- if (details) {
910
- return details;
911
- } else {
912
- if (pos >= peg$posDetailsCache.length) {
913
- p = peg$posDetailsCache.length - 1;
914
- } else {
915
- p = pos;
916
- while (!peg$posDetailsCache[--p]) {
917
- }
918
- }
919
- details = peg$posDetailsCache[p];
920
- details = {
921
- // @ts-ignore
922
- line: details.line,
923
- // @ts-ignore
924
- column: details.column
925
- };
926
- while (p < pos) {
927
- if (input.charCodeAt(p) === 10) {
928
- details.line++;
929
- details.column = 1;
930
- } else {
931
- details.column++;
932
- }
933
- p++;
934
- }
935
- peg$posDetailsCache[pos] = details;
936
- return details;
937
- }
938
- }
939
- function peg$computeLocation(startPos, endPos, offset2) {
940
- var startPosDetails = peg$computePosDetails(startPos);
941
- var endPosDetails = peg$computePosDetails(endPos);
942
- var res = {
943
- // @ts-ignore
944
- source: peg$source,
945
- // @ts-ignore
946
- start: {
947
- // @ts-ignore
948
- offset: startPos,
949
- // @ts-ignore
950
- line: startPosDetails.line,
951
- // @ts-ignore
952
- column: startPosDetails.column
953
- },
954
- // @ts-ignore
955
- end: {
956
- // @ts-ignore
957
- offset: endPos,
958
- // @ts-ignore
959
- line: endPosDetails.line,
960
- // @ts-ignore
961
- column: endPosDetails.column
962
- }
963
- };
964
- return res;
965
- }
966
- function peg$fail(expected2) {
967
- if (peg$currPos < peg$maxFailPos) {
968
- return;
969
- }
970
- if (peg$currPos > peg$maxFailPos) {
971
- peg$maxFailPos = peg$currPos;
972
- peg$maxFailExpected = [];
973
- }
974
- peg$maxFailExpected.push(expected2);
975
- }
976
- function peg$buildSimpleError(message, location2) {
977
- return new peg$SyntaxError(message, null, null, location2);
978
- }
979
- function peg$buildStructuredError(expected2, found, location2) {
980
- return new peg$SyntaxError(
981
- // @ts-ignore
982
- peg$SyntaxError.buildMessage(expected2, found),
983
- // @ts-ignore
984
- expected2,
985
- // @ts-ignore
986
- found,
987
- // @ts-ignore
988
- location2
989
- );
990
- }
991
- function peg$parseDot() {
992
- var s0, s2;
993
- s0 = peg$currPos;
994
- peg$parse__();
995
- s2 = peg$parse_dot();
996
- if (s2 !== peg$FAILED) {
997
- peg$parse__();
998
- peg$savedPos = s0;
999
- s0 = peg$f0(s2);
1000
- } else {
1001
- peg$currPos = s0;
1002
- s0 = peg$FAILED;
1003
- }
1004
- return s0;
1005
- }
1006
- function peg$parseGraph() {
1007
- var s0, s2;
1008
- s0 = peg$currPos;
1009
- peg$parse__();
1010
- s2 = peg$parse_graph();
1011
- if (s2 !== peg$FAILED) {
1012
- peg$parse__();
1013
- peg$savedPos = s0;
1014
- s0 = peg$f1(s2);
1015
- } else {
1016
- peg$currPos = s0;
1017
- s0 = peg$FAILED;
1018
- }
1019
- return s0;
1020
- }
1021
- function peg$parseNode() {
1022
- var s0, s2;
1023
- s0 = peg$currPos;
1024
- peg$parse__();
1025
- s2 = peg$parse_node();
1026
- if (s2 !== peg$FAILED) {
1027
- peg$parse__();
1028
- peg$savedPos = s0;
1029
- s0 = peg$f2(s2);
1030
- } else {
1031
- peg$currPos = s0;
1032
- s0 = peg$FAILED;
1033
- }
1034
- return s0;
1035
- }
1036
- function peg$parseAttributeList() {
1037
- var s0, s2;
1038
- s0 = peg$currPos;
1039
- peg$parse__();
1040
- s2 = peg$parse_attributes();
1041
- if (s2 !== peg$FAILED) {
1042
- peg$parse__();
1043
- peg$savedPos = s0;
1044
- s0 = peg$f3(s2);
1045
- } else {
1046
- peg$currPos = s0;
1047
- s0 = peg$FAILED;
1048
- }
1049
- return s0;
1050
- }
1051
- function peg$parseAttribute() {
1052
- var s0, s2;
1053
- s0 = peg$currPos;
1054
- peg$parse__();
1055
- s2 = peg$parse_attribute();
1056
- if (s2 !== peg$FAILED) {
1057
- peg$parse__();
1058
- peg$savedPos = s0;
1059
- s0 = peg$f4(s2);
1060
- } else {
1061
- peg$currPos = s0;
1062
- s0 = peg$FAILED;
1063
- }
1064
- return s0;
1065
- }
1066
- function peg$parseEdge() {
1067
- var s0, s2;
1068
- s0 = peg$currPos;
1069
- peg$parse__();
1070
- s2 = peg$parse_edge();
1071
- if (s2 !== peg$FAILED) {
1072
- peg$parse__();
1073
- peg$savedPos = s0;
1074
- s0 = peg$f5(s2);
1075
- } else {
1076
- peg$currPos = s0;
1077
- s0 = peg$FAILED;
1078
- }
1079
- return s0;
1080
- }
1081
- function peg$parseSubgraph() {
1082
- var s0, s2;
1083
- s0 = peg$currPos;
1084
- peg$parse__();
1085
- s2 = peg$parse_subgraph();
1086
- if (s2 !== peg$FAILED) {
1087
- peg$parse__();
1088
- peg$savedPos = s0;
1089
- s0 = peg$f6(s2);
1090
- } else {
1091
- peg$currPos = s0;
1092
- s0 = peg$FAILED;
1093
- }
1094
- return s0;
1095
- }
1096
- function peg$parseNodeRef() {
1097
- var s0, s2;
1098
- s0 = peg$currPos;
1099
- peg$parse__();
1100
- s2 = peg$parse_node_ref();
1101
- if (s2 !== peg$FAILED) {
1102
- peg$parse__();
1103
- peg$savedPos = s0;
1104
- s0 = peg$f7(s2);
1105
- } else {
1106
- peg$currPos = s0;
1107
- s0 = peg$FAILED;
1108
- }
1109
- return s0;
1110
- }
1111
- function peg$parseAttibutesItem() {
1112
- var s0, s2;
1113
- s0 = peg$currPos;
1114
- peg$parse__();
1115
- s2 = peg$parse_attibutes_item();
1116
- if (s2 !== peg$FAILED) {
1117
- peg$parse__();
1118
- peg$savedPos = s0;
1119
- s0 = peg$f8(s2);
1120
- } else {
1121
- peg$currPos = s0;
1122
- s0 = peg$FAILED;
1123
- }
1124
- return s0;
1125
- }
1126
- function peg$parseComment() {
1127
- var s0, s2;
1128
- s0 = peg$currPos;
1129
- peg$parse__();
1130
- s2 = peg$parse_comment();
1131
- if (s2 !== peg$FAILED) {
1132
- peg$parse__();
1133
- peg$savedPos = s0;
1134
- s0 = peg$f9(s2);
1135
- } else {
1136
- peg$currPos = s0;
1137
- s0 = peg$FAILED;
1138
- }
1139
- return s0;
1140
- }
1141
- function peg$parseClusterStatements() {
1142
- var s0, s1;
1143
- s0 = [];
1144
- s1 = peg$parseAttribute();
1145
- if (s1 === peg$FAILED) {
1146
- s1 = peg$parseAttributeList();
1147
- if (s1 === peg$FAILED) {
1148
- s1 = peg$parseEdge();
1149
- if (s1 === peg$FAILED) {
1150
- s1 = peg$parseSubgraph();
1151
- if (s1 === peg$FAILED) {
1152
- s1 = peg$parseNode();
1153
- if (s1 === peg$FAILED) {
1154
- s1 = peg$parseComment();
1155
- }
1156
- }
1157
- }
1158
- }
1159
- }
1160
- while (s1 !== peg$FAILED) {
1161
- s0.push(s1);
1162
- s1 = peg$parseAttribute();
1163
- if (s1 === peg$FAILED) {
1164
- s1 = peg$parseAttributeList();
1165
- if (s1 === peg$FAILED) {
1166
- s1 = peg$parseEdge();
1167
- if (s1 === peg$FAILED) {
1168
- s1 = peg$parseSubgraph();
1169
- if (s1 === peg$FAILED) {
1170
- s1 = peg$parseNode();
1171
- if (s1 === peg$FAILED) {
1172
- s1 = peg$parseComment();
1173
- }
1174
- }
1175
- }
1176
- }
1177
- }
1178
- }
1179
- return s0;
1180
- }
1181
- function peg$parse_dot() {
1182
- var s0, s1, s2, s3, s4;
1183
- s0 = peg$currPos;
1184
- s1 = [];
1185
- s2 = peg$parseComment();
1186
- while (s2 !== peg$FAILED) {
1187
- s1.push(s2);
1188
- s2 = peg$parseComment();
1189
- }
1190
- s2 = peg$parseGraph();
1191
- if (s2 !== peg$FAILED) {
1192
- s3 = [];
1193
- s4 = peg$parseComment();
1194
- while (s4 !== peg$FAILED) {
1195
- s3.push(s4);
1196
- s4 = peg$parseComment();
1197
- }
1198
- peg$savedPos = s0;
1199
- s0 = peg$f10(s1, s2, s3);
1200
- } else {
1201
- peg$currPos = s0;
1202
- s0 = peg$FAILED;
1203
- }
1204
- return s0;
1205
- }
1206
- function peg$parse_graph() {
1207
- var s0, s1, s3, s5, s7, s8, s10;
1208
- s0 = peg$currPos;
1209
- s1 = input.substr(peg$currPos, 6);
1210
- if (s1.toLowerCase() === peg$c0) {
1211
- peg$currPos += 6;
1212
- } else {
1213
- s1 = peg$FAILED;
1214
- if (peg$silentFails === 0) {
1215
- peg$fail(peg$e0);
1216
- }
1217
- }
1218
- if (s1 === peg$FAILED) {
1219
- s1 = null;
1220
- }
1221
- peg$parse_();
1222
- s3 = input.substr(peg$currPos, 5);
1223
- if (s3.toLowerCase() === peg$c1) {
1224
- peg$currPos += 5;
1225
- } else {
1226
- s3 = peg$FAILED;
1227
- if (peg$silentFails === 0) {
1228
- peg$fail(peg$e1);
1229
- }
1230
- }
1231
- if (s3 === peg$FAILED) {
1232
- s3 = input.substr(peg$currPos, 7);
1233
- if (s3.toLowerCase() === peg$c2) {
1234
- peg$currPos += 7;
1235
- } else {
1236
- s3 = peg$FAILED;
1237
- if (peg$silentFails === 0) {
1238
- peg$fail(peg$e2);
1239
- }
1240
- }
1241
- }
1242
- if (s3 !== peg$FAILED) {
1243
- peg$parse_();
1244
- s5 = peg$parse_literal();
1245
- if (s5 === peg$FAILED) {
1246
- s5 = null;
1247
- }
1248
- peg$parse__();
1249
- if (input.charCodeAt(peg$currPos) === 123) {
1250
- s7 = peg$c3;
1251
- peg$currPos++;
1252
- } else {
1253
- s7 = peg$FAILED;
1254
- if (peg$silentFails === 0) {
1255
- peg$fail(peg$e3);
1256
- }
1257
- }
1258
- if (s7 !== peg$FAILED) {
1259
- s8 = peg$parseClusterStatements();
1260
- peg$parse__();
1261
- if (input.charCodeAt(peg$currPos) === 125) {
1262
- s10 = peg$c4;
1263
- peg$currPos++;
1264
- } else {
1265
- s10 = peg$FAILED;
1266
- if (peg$silentFails === 0) {
1267
- peg$fail(peg$e4);
1268
- }
1269
- }
1270
- if (s10 !== peg$FAILED) {
1271
- peg$savedPos = s0;
1272
- s0 = peg$f11(s1, s3, s5, s8);
1273
- } else {
1274
- peg$currPos = s0;
1275
- s0 = peg$FAILED;
1276
- }
1277
- } else {
1278
- peg$currPos = s0;
1279
- s0 = peg$FAILED;
1280
- }
1281
- } else {
1282
- peg$currPos = s0;
1283
- s0 = peg$FAILED;
1284
- }
1285
- return s0;
1286
- }
1287
- function peg$parse_attribute() {
1288
- var s0, s1;
1289
- s0 = peg$currPos;
1290
- s1 = peg$parse_key_value();
1291
- if (s1 !== peg$FAILED) {
1292
- peg$parse_();
1293
- if (input.charCodeAt(peg$currPos) === 59) {
1294
- peg$currPos++;
1295
- } else {
1296
- if (peg$silentFails === 0) {
1297
- peg$fail(peg$e5);
1298
- }
1299
- }
1300
- peg$savedPos = s0;
1301
- s0 = peg$f12(s1);
1302
- } else {
1303
- peg$currPos = s0;
1304
- s0 = peg$FAILED;
1305
- }
1306
- return s0;
1307
- }
1308
- function peg$parse_attributes() {
1309
- var s0, s1, s2;
1310
- s0 = peg$currPos;
1311
- s1 = input.substr(peg$currPos, 5);
1312
- if (s1.toLowerCase() === peg$c1) {
1313
- peg$currPos += 5;
1314
- } else {
1315
- s1 = peg$FAILED;
1316
- if (peg$silentFails === 0) {
1317
- peg$fail(peg$e1);
1318
- }
1319
- }
1320
- if (s1 === peg$FAILED) {
1321
- s1 = input.substr(peg$currPos, 4);
1322
- if (s1.toLowerCase() === peg$c6) {
1323
- peg$currPos += 4;
1324
- } else {
1325
- s1 = peg$FAILED;
1326
- if (peg$silentFails === 0) {
1327
- peg$fail(peg$e6);
1328
- }
1329
- }
1330
- if (s1 === peg$FAILED) {
1331
- s1 = input.substr(peg$currPos, 4);
1332
- if (s1.toLowerCase() === peg$c7) {
1333
- peg$currPos += 4;
1334
- } else {
1335
- s1 = peg$FAILED;
1336
- if (peg$silentFails === 0) {
1337
- peg$fail(peg$e7);
1338
- }
1339
- }
1340
- }
1341
- }
1342
- if (s1 !== peg$FAILED) {
1343
- s2 = peg$parse_attribute_list();
1344
- if (s2 !== peg$FAILED) {
1345
- peg$parse_();
1346
- if (input.charCodeAt(peg$currPos) === 59) {
1347
- peg$currPos++;
1348
- } else {
1349
- if (peg$silentFails === 0) {
1350
- peg$fail(peg$e5);
1351
- }
1352
- }
1353
- peg$savedPos = s0;
1354
- s0 = peg$f13(s1, s2);
1355
- } else {
1356
- peg$currPos = s0;
1357
- s0 = peg$FAILED;
1358
- }
1359
- } else {
1360
- peg$currPos = s0;
1361
- s0 = peg$FAILED;
1362
- }
1363
- return s0;
1364
- }
1365
- function peg$parse_edge() {
1366
- var s0, s1, s2, s3;
1367
- s0 = peg$currPos;
1368
- s1 = peg$parse_edge_target();
1369
- if (s1 !== peg$FAILED) {
1370
- s2 = peg$parse_edge_rhs();
1371
- if (s2 !== peg$FAILED) {
1372
- s3 = peg$parse_attribute_list();
1373
- if (s3 === peg$FAILED) {
1374
- s3 = null;
1375
- }
1376
- peg$parse_();
1377
- if (input.charCodeAt(peg$currPos) === 59) {
1378
- peg$currPos++;
1379
- } else {
1380
- if (peg$silentFails === 0) {
1381
- peg$fail(peg$e5);
1382
- }
1383
- }
1384
- peg$savedPos = s0;
1385
- s0 = peg$f14(s1, s2, s3);
1386
- } else {
1387
- peg$currPos = s0;
1388
- s0 = peg$FAILED;
1389
- }
1390
- } else {
1391
- peg$currPos = s0;
1392
- s0 = peg$FAILED;
1393
- }
1394
- return s0;
1395
- }
1396
- function peg$parse_node() {
1397
- var s0, s1, s3;
1398
- s0 = peg$currPos;
1399
- s1 = peg$parse_literal();
1400
- if (s1 !== peg$FAILED) {
1401
- peg$parse_();
1402
- s3 = peg$parse_attribute_list();
1403
- if (s3 === peg$FAILED) {
1404
- s3 = null;
1405
- }
1406
- peg$parse_();
1407
- if (input.charCodeAt(peg$currPos) === 59) {
1408
- peg$currPos++;
1409
- } else {
1410
- if (peg$silentFails === 0) {
1411
- peg$fail(peg$e5);
1412
- }
1413
- }
1414
- peg$savedPos = s0;
1415
- s0 = peg$f15(s1, s3);
1416
- } else {
1417
- peg$currPos = s0;
1418
- s0 = peg$FAILED;
1419
- }
1420
- return s0;
1421
- }
1422
- function peg$parse_key_value() {
1423
- var s0, s1, s3, s5;
1424
- s0 = peg$currPos;
1425
- s1 = peg$parse_literal();
1426
- if (s1 !== peg$FAILED) {
1427
- peg$parse_();
1428
- if (input.charCodeAt(peg$currPos) === 61) {
1429
- s3 = peg$c8;
1430
- peg$currPos++;
1431
- } else {
1432
- s3 = peg$FAILED;
1433
- if (peg$silentFails === 0) {
1434
- peg$fail(peg$e8);
1435
- }
1436
- }
1437
- if (s3 !== peg$FAILED) {
1438
- peg$parse_();
1439
- s5 = peg$parse_literal();
1440
- if (s5 !== peg$FAILED) {
1441
- peg$savedPos = s0;
1442
- s0 = peg$f16(s1, s5);
1443
- } else {
1444
- peg$currPos = s0;
1445
- s0 = peg$FAILED;
1446
- }
1447
- } else {
1448
- peg$currPos = s0;
1449
- s0 = peg$FAILED;
1450
- }
1451
- } else {
1452
- peg$currPos = s0;
1453
- s0 = peg$FAILED;
1454
- }
1455
- return s0;
1456
- }
1457
- function peg$parse_attibutes_item() {
1458
- var s0, s1, s3;
1459
- s0 = peg$currPos;
1460
- s1 = peg$parse_key_value();
1461
- if (s1 !== peg$FAILED) {
1462
- peg$parse_();
1463
- s3 = input.charAt(peg$currPos);
1464
- if (peg$r0.test(s3)) {
1465
- peg$currPos++;
1466
- } else {
1467
- s3 = peg$FAILED;
1468
- if (peg$silentFails === 0) {
1469
- peg$fail(peg$e9);
1470
- }
1471
- }
1472
- if (s3 === peg$FAILED) {
1473
- s3 = null;
1474
- }
1475
- peg$savedPos = s0;
1476
- s0 = peg$f17(s1);
1477
- } else {
1478
- peg$currPos = s0;
1479
- s0 = peg$FAILED;
1480
- }
1481
- return s0;
1482
- }
1483
- function peg$parse_attribute_list() {
1484
- var s0, s2, s3, s4, s5;
1485
- s0 = peg$currPos;
1486
- peg$parse_();
1487
- if (input.charCodeAt(peg$currPos) === 91) {
1488
- s2 = peg$c9;
1489
- peg$currPos++;
1490
- } else {
1491
- s2 = peg$FAILED;
1492
- if (peg$silentFails === 0) {
1493
- peg$fail(peg$e10);
1494
- }
1495
- }
1496
- if (s2 !== peg$FAILED) {
1497
- s3 = [];
1498
- s4 = peg$parseAttibutesItem();
1499
- if (s4 === peg$FAILED) {
1500
- s4 = peg$parseComment();
1501
- }
1502
- while (s4 !== peg$FAILED) {
1503
- s3.push(s4);
1504
- s4 = peg$parseAttibutesItem();
1505
- if (s4 === peg$FAILED) {
1506
- s4 = peg$parseComment();
1507
- }
1508
- }
1509
- s4 = peg$parse__();
1510
- if (input.charCodeAt(peg$currPos) === 93) {
1511
- s5 = peg$c10;
1512
- peg$currPos++;
1513
- } else {
1514
- s5 = peg$FAILED;
1515
- if (peg$silentFails === 0) {
1516
- peg$fail(peg$e11);
1517
- }
1518
- }
1519
- if (s5 !== peg$FAILED) {
1520
- peg$savedPos = s0;
1521
- s0 = peg$f18(s3);
1522
- } else {
1523
- peg$currPos = s0;
1524
- s0 = peg$FAILED;
1525
- }
1526
- } else {
1527
- peg$currPos = s0;
1528
- s0 = peg$FAILED;
1529
- }
1530
- return s0;
1531
- }
1532
- function peg$parse_edge_target_group() {
1533
- var s0, s1, s2, s3, s4, s5, s6;
1534
- s0 = peg$currPos;
1535
- if (input.charCodeAt(peg$currPos) === 123) {
1536
- s1 = peg$c3;
1537
- peg$currPos++;
1538
- } else {
1539
- s1 = peg$FAILED;
1540
- if (peg$silentFails === 0) {
1541
- peg$fail(peg$e3);
1542
- }
1543
- }
1544
- if (s1 !== peg$FAILED) {
1545
- s2 = peg$parseNodeRef();
1546
- if (s2 !== peg$FAILED) {
1547
- s3 = [];
1548
- s4 = peg$currPos;
1549
- s5 = input.charAt(peg$currPos);
1550
- if (peg$r0.test(s5)) {
1551
- peg$currPos++;
1552
- } else {
1553
- s5 = peg$FAILED;
1554
- if (peg$silentFails === 0) {
1555
- peg$fail(peg$e9);
1556
- }
1557
- }
1558
- if (s5 === peg$FAILED) {
1559
- s5 = null;
1560
- }
1561
- s6 = peg$parseNodeRef();
1562
- if (s6 !== peg$FAILED) {
1563
- peg$savedPos = s4;
1564
- s4 = peg$f19(s2, s6);
1565
- } else {
1566
- peg$currPos = s4;
1567
- s4 = peg$FAILED;
1568
- }
1569
- while (s4 !== peg$FAILED) {
1570
- s3.push(s4);
1571
- s4 = peg$currPos;
1572
- s5 = input.charAt(peg$currPos);
1573
- if (peg$r0.test(s5)) {
1574
- peg$currPos++;
1575
- } else {
1576
- s5 = peg$FAILED;
1577
- if (peg$silentFails === 0) {
1578
- peg$fail(peg$e9);
1579
- }
1580
- }
1581
- if (s5 === peg$FAILED) {
1582
- s5 = null;
1583
- }
1584
- s6 = peg$parseNodeRef();
1585
- if (s6 !== peg$FAILED) {
1586
- peg$savedPos = s4;
1587
- s4 = peg$f19(s2, s6);
1588
- } else {
1589
- peg$currPos = s4;
1590
- s4 = peg$FAILED;
1591
- }
1592
- }
1593
- s4 = input.charAt(peg$currPos);
1594
- if (peg$r0.test(s4)) {
1595
- peg$currPos++;
1596
- } else {
1597
- s4 = peg$FAILED;
1598
- if (peg$silentFails === 0) {
1599
- peg$fail(peg$e9);
1600
- }
1601
- }
1602
- if (s4 === peg$FAILED) {
1603
- s4 = null;
1604
- }
1605
- s5 = peg$parse__();
1606
- if (input.charCodeAt(peg$currPos) === 125) {
1607
- s6 = peg$c4;
1608
- peg$currPos++;
1609
- } else {
1610
- s6 = peg$FAILED;
1611
- if (peg$silentFails === 0) {
1612
- peg$fail(peg$e4);
1613
- }
1614
- }
1615
- if (s6 !== peg$FAILED) {
1616
- peg$savedPos = s0;
1617
- s0 = peg$f20(s2, s3);
1618
- } else {
1619
- peg$currPos = s0;
1620
- s0 = peg$FAILED;
1621
- }
1622
- } else {
1623
- peg$currPos = s0;
1624
- s0 = peg$FAILED;
1625
- }
1626
- } else {
1627
- peg$currPos = s0;
1628
- s0 = peg$FAILED;
1629
- }
1630
- return s0;
1631
- }
1632
- function peg$parse_edge_target() {
1633
- var s0;
1634
- s0 = peg$parse_edge_target_group();
1635
- if (s0 === peg$FAILED) {
1636
- s0 = peg$parseNodeRef();
1637
- }
1638
- return s0;
1639
- }
1640
- function peg$parse_edge_operator() {
1641
- var s0, s1;
1642
- s0 = peg$currPos;
1643
- if (input.substr(peg$currPos, 2) === peg$c11) {
1644
- s1 = peg$c11;
1645
- peg$currPos += 2;
1646
- } else {
1647
- s1 = peg$FAILED;
1648
- if (peg$silentFails === 0) {
1649
- peg$fail(peg$e12);
1650
- }
1651
- }
1652
- if (s1 === peg$FAILED) {
1653
- if (input.substr(peg$currPos, 2) === peg$c12) {
1654
- s1 = peg$c12;
1655
- peg$currPos += 2;
1656
- } else {
1657
- s1 = peg$FAILED;
1658
- if (peg$silentFails === 0) {
1659
- peg$fail(peg$e13);
1660
- }
1661
- }
1662
- }
1663
- if (s1 !== peg$FAILED) {
1664
- peg$savedPos = s0;
1665
- s1 = peg$f21(s1);
1666
- }
1667
- s0 = s1;
1668
- return s0;
1669
- }
1670
- function peg$parse_edge_rhs() {
1671
- var s0, s2, s4, s6;
1672
- s0 = peg$currPos;
1673
- peg$parse_();
1674
- s2 = peg$parse_edge_operator();
1675
- if (s2 !== peg$FAILED) {
1676
- peg$parse_();
1677
- s4 = peg$parse_edge_target();
1678
- if (s4 !== peg$FAILED) {
1679
- peg$parse_();
1680
- s6 = peg$parse_edge_rhs();
1681
- if (s6 === peg$FAILED) {
1682
- s6 = null;
1683
- }
1684
- peg$savedPos = s0;
1685
- s0 = peg$f22(s2, s4, s6);
1686
- } else {
1687
- peg$currPos = s0;
1688
- s0 = peg$FAILED;
1689
- }
1690
- } else {
1691
- peg$currPos = s0;
1692
- s0 = peg$FAILED;
1693
- }
1694
- return s0;
1695
- }
1696
- function peg$parse_node_ref() {
1697
- var s0, s1, s2;
1698
- s0 = peg$currPos;
1699
- s1 = peg$parse_literal();
1700
- if (s1 !== peg$FAILED) {
1701
- s2 = peg$parse_port();
1702
- if (s2 === peg$FAILED) {
1703
- s2 = null;
1704
- }
1705
- peg$savedPos = s0;
1706
- s0 = peg$f23(s1, s2);
1707
- } else {
1708
- peg$currPos = s0;
1709
- s0 = peg$FAILED;
1710
- }
1711
- return s0;
1712
- }
1713
- function peg$parse_port() {
1714
- var s0, s1, s2, s3, s4, s5;
1715
- peg$silentFails++;
1716
- s0 = peg$currPos;
1717
- if (input.charCodeAt(peg$currPos) === 58) {
1718
- s1 = peg$c13;
1719
- peg$currPos++;
1720
- } else {
1721
- s1 = peg$FAILED;
1722
- if (peg$silentFails === 0) {
1723
- peg$fail(peg$e15);
1724
- }
1725
- }
1726
- if (s1 !== peg$FAILED) {
1727
- s2 = peg$parse_literal();
1728
- if (s2 !== peg$FAILED) {
1729
- s3 = peg$currPos;
1730
- if (input.charCodeAt(peg$currPos) === 58) {
1731
- s4 = peg$c13;
1732
- peg$currPos++;
1733
- } else {
1734
- s4 = peg$FAILED;
1735
- if (peg$silentFails === 0) {
1736
- peg$fail(peg$e15);
1737
- }
1738
- }
1739
- if (s4 !== peg$FAILED) {
1740
- s5 = peg$parse_compass();
1741
- if (s5 !== peg$FAILED) {
1742
- peg$savedPos = s3;
1743
- s3 = peg$f24(s2, s5);
1744
- } else {
1745
- peg$currPos = s3;
1746
- s3 = peg$FAILED;
1747
- }
1748
- } else {
1749
- peg$currPos = s3;
1750
- s3 = peg$FAILED;
1751
- }
1752
- if (s3 === peg$FAILED) {
1753
- s3 = null;
1754
- }
1755
- peg$savedPos = s0;
1756
- s0 = peg$f25(s2, s3);
1757
- } else {
1758
- peg$currPos = s0;
1759
- s0 = peg$FAILED;
1760
- }
1761
- } else {
1762
- peg$currPos = s0;
1763
- s0 = peg$FAILED;
1764
- }
1765
- peg$silentFails--;
1766
- if (s0 === peg$FAILED) {
1767
- s1 = peg$FAILED;
1768
- if (peg$silentFails === 0) {
1769
- peg$fail(peg$e14);
1770
- }
1771
- }
1772
- return s0;
1773
- }
1774
- function peg$parse_subgraph_id() {
1775
- var s0, s1, s3;
1776
- s0 = peg$currPos;
1777
- s1 = input.substr(peg$currPos, 8);
1778
- if (s1.toLowerCase() === peg$c14) {
1779
- peg$currPos += 8;
1780
- } else {
1781
- s1 = peg$FAILED;
1782
- if (peg$silentFails === 0) {
1783
- peg$fail(peg$e16);
1784
- }
1785
- }
1786
- if (s1 !== peg$FAILED) {
1787
- peg$parse_();
1788
- s3 = peg$parse_literal();
1789
- if (s3 === peg$FAILED) {
1790
- s3 = null;
1791
- }
1792
- peg$parse_();
1793
- peg$savedPos = s0;
1794
- s0 = peg$f26(s3);
1795
- } else {
1796
- peg$currPos = s0;
1797
- s0 = peg$FAILED;
1798
- }
1799
- return s0;
1800
- }
1801
- function peg$parse_subgraph() {
1802
- var s0, s1, s2, s3, s5;
1803
- s0 = peg$currPos;
1804
- s1 = peg$parse_subgraph_id();
1805
- if (s1 === peg$FAILED) {
1806
- s1 = null;
1807
- }
1808
- if (input.charCodeAt(peg$currPos) === 123) {
1809
- s2 = peg$c3;
1810
- peg$currPos++;
1811
- } else {
1812
- s2 = peg$FAILED;
1813
- if (peg$silentFails === 0) {
1814
- peg$fail(peg$e3);
1815
- }
1816
- }
1817
- if (s2 !== peg$FAILED) {
1818
- s3 = peg$parseClusterStatements();
1819
- if (s3 === peg$FAILED) {
1820
- s3 = null;
1821
- }
1822
- peg$parse__();
1823
- if (input.charCodeAt(peg$currPos) === 125) {
1824
- s5 = peg$c4;
1825
- peg$currPos++;
1826
- } else {
1827
- s5 = peg$FAILED;
1828
- if (peg$silentFails === 0) {
1829
- peg$fail(peg$e4);
1830
- }
1831
- }
1832
- if (s5 !== peg$FAILED) {
1833
- peg$savedPos = s0;
1834
- s0 = peg$f27(s1, s3);
1835
- } else {
1836
- peg$currPos = s0;
1837
- s0 = peg$FAILED;
1838
- }
1839
- } else {
1840
- peg$currPos = s0;
1841
- s0 = peg$FAILED;
1842
- }
1843
- return s0;
1844
- }
1845
- function peg$parse_compass_keyword() {
1846
- var s0;
1847
- if (input.charCodeAt(peg$currPos) === 110) {
1848
- s0 = peg$c15;
1849
- peg$currPos++;
1850
- } else {
1851
- s0 = peg$FAILED;
1852
- if (peg$silentFails === 0) {
1853
- peg$fail(peg$e17);
1854
- }
1855
- }
1856
- if (s0 === peg$FAILED) {
1857
- if (input.substr(peg$currPos, 2) === peg$c16) {
1858
- s0 = peg$c16;
1859
- peg$currPos += 2;
1860
- } else {
1861
- s0 = peg$FAILED;
1862
- if (peg$silentFails === 0) {
1863
- peg$fail(peg$e18);
1864
- }
1865
- }
1866
- if (s0 === peg$FAILED) {
1867
- if (input.charCodeAt(peg$currPos) === 101) {
1868
- s0 = peg$c17;
1869
- peg$currPos++;
1870
- } else {
1871
- s0 = peg$FAILED;
1872
- if (peg$silentFails === 0) {
1873
- peg$fail(peg$e19);
1874
- }
1875
- }
1876
- if (s0 === peg$FAILED) {
1877
- if (input.substr(peg$currPos, 2) === peg$c18) {
1878
- s0 = peg$c18;
1879
- peg$currPos += 2;
1880
- } else {
1881
- s0 = peg$FAILED;
1882
- if (peg$silentFails === 0) {
1883
- peg$fail(peg$e20);
1884
- }
1885
- }
1886
- if (s0 === peg$FAILED) {
1887
- if (input.charCodeAt(peg$currPos) === 115) {
1888
- s0 = peg$c19;
1889
- peg$currPos++;
1890
- } else {
1891
- s0 = peg$FAILED;
1892
- if (peg$silentFails === 0) {
1893
- peg$fail(peg$e21);
1894
- }
1895
- }
1896
- if (s0 === peg$FAILED) {
1897
- if (input.substr(peg$currPos, 2) === peg$c20) {
1898
- s0 = peg$c20;
1899
- peg$currPos += 2;
1900
- } else {
1901
- s0 = peg$FAILED;
1902
- if (peg$silentFails === 0) {
1903
- peg$fail(peg$e22);
1904
- }
1905
- }
1906
- if (s0 === peg$FAILED) {
1907
- if (input.charCodeAt(peg$currPos) === 119) {
1908
- s0 = peg$c21;
1909
- peg$currPos++;
1910
- } else {
1911
- s0 = peg$FAILED;
1912
- if (peg$silentFails === 0) {
1913
- peg$fail(peg$e23);
1914
- }
1915
- }
1916
- if (s0 === peg$FAILED) {
1917
- if (input.substr(peg$currPos, 2) === peg$c22) {
1918
- s0 = peg$c22;
1919
- peg$currPos += 2;
1920
- } else {
1921
- s0 = peg$FAILED;
1922
- if (peg$silentFails === 0) {
1923
- peg$fail(peg$e24);
1924
- }
1925
- }
1926
- }
1927
- }
1928
- }
1929
- }
1930
- }
1931
- }
1932
- }
1933
- return s0;
1934
- }
1935
- function peg$parse_compass() {
1936
- var s0, s1, s2, s3, s4;
1937
- s0 = peg$currPos;
1938
- s1 = peg$currPos;
1939
- s2 = peg$parse_compass_keyword();
1940
- if (s2 !== peg$FAILED) {
1941
- peg$savedPos = s1;
1942
- s2 = peg$f28(s2);
1943
- }
1944
- s1 = s2;
1945
- if (s1 === peg$FAILED) {
1946
- s1 = peg$currPos;
1947
- if (input.charCodeAt(peg$currPos) === 34) {
1948
- s2 = peg$c23;
1949
- peg$currPos++;
1950
- } else {
1951
- s2 = peg$FAILED;
1952
- if (peg$silentFails === 0) {
1953
- peg$fail(peg$e25);
1954
- }
1955
- }
1956
- if (s2 !== peg$FAILED) {
1957
- s3 = peg$parse_compass_keyword();
1958
- if (s3 !== peg$FAILED) {
1959
- if (input.charCodeAt(peg$currPos) === 34) {
1960
- s4 = peg$c23;
1961
- peg$currPos++;
1962
- } else {
1963
- s4 = peg$FAILED;
1964
- if (peg$silentFails === 0) {
1965
- peg$fail(peg$e25);
1966
- }
1967
- }
1968
- if (s4 !== peg$FAILED) {
1969
- peg$savedPos = s1;
1970
- s1 = peg$f29(s3);
1971
- } else {
1972
- peg$currPos = s1;
1973
- s1 = peg$FAILED;
1974
- }
1975
- } else {
1976
- peg$currPos = s1;
1977
- s1 = peg$FAILED;
1978
- }
1979
- } else {
1980
- peg$currPos = s1;
1981
- s1 = peg$FAILED;
1982
- }
1983
- }
1984
- if (s1 !== peg$FAILED) {
1985
- peg$savedPos = s0;
1986
- s1 = peg$f30(s1);
1987
- }
1988
- s0 = s1;
1989
- return s0;
1990
- }
1991
- function peg$parse_literal() {
1992
- var s0, s1;
1993
- s0 = peg$parseQUOTED_STRING();
1994
- if (s0 === peg$FAILED) {
1995
- s0 = peg$parseHTML_STRING();
1996
- if (s0 === peg$FAILED) {
1997
- s0 = peg$currPos;
1998
- s1 = peg$parseSTRING();
1999
- if (s1 === peg$FAILED) {
2000
- s1 = peg$parseNUMBER_STRING();
2001
- if (s1 === peg$FAILED) {
2002
- s1 = peg$parseNUMBER();
2003
- }
2004
- }
2005
- if (s1 !== peg$FAILED) {
2006
- peg$savedPos = s0;
2007
- s1 = peg$f31(s1);
2008
- }
2009
- s0 = s1;
2010
- }
2011
- }
2012
- return s0;
2013
- }
2014
- function peg$parse_comment() {
2015
- var s0;
2016
- s0 = peg$parse_block_comment();
2017
- if (s0 === peg$FAILED) {
2018
- s0 = peg$parse_slash_comment();
2019
- if (s0 === peg$FAILED) {
2020
- s0 = peg$parse_macro_comment();
2021
- }
2022
- }
2023
- return s0;
2024
- }
2025
- function peg$parse_block_comment() {
2026
- var s0, s1, s2, s3, s4, s5;
2027
- s0 = peg$currPos;
2028
- if (input.substr(peg$currPos, 2) === peg$c24) {
2029
- s1 = peg$c24;
2030
- peg$currPos += 2;
2031
- } else {
2032
- s1 = peg$FAILED;
2033
- if (peg$silentFails === 0) {
2034
- peg$fail(peg$e26);
2035
- }
2036
- }
2037
- if (s1 !== peg$FAILED) {
2038
- s2 = [];
2039
- s3 = peg$currPos;
2040
- s4 = peg$currPos;
2041
- peg$silentFails++;
2042
- if (input.substr(peg$currPos, 2) === peg$c25) {
2043
- s5 = peg$c25;
2044
- peg$currPos += 2;
2045
- } else {
2046
- s5 = peg$FAILED;
2047
- if (peg$silentFails === 0) {
2048
- peg$fail(peg$e27);
2049
- }
2050
- }
2051
- peg$silentFails--;
2052
- if (s5 === peg$FAILED) {
2053
- s4 = void 0;
2054
- } else {
2055
- peg$currPos = s4;
2056
- s4 = peg$FAILED;
2057
- }
2058
- if (s4 !== peg$FAILED) {
2059
- if (input.length > peg$currPos) {
2060
- s5 = input.charAt(peg$currPos);
2061
- peg$currPos++;
2062
- } else {
2063
- s5 = peg$FAILED;
2064
- if (peg$silentFails === 0) {
2065
- peg$fail(peg$e28);
2066
- }
2067
- }
2068
- if (s5 !== peg$FAILED) {
2069
- peg$savedPos = s3;
2070
- s3 = peg$f32(s5);
2071
- } else {
2072
- peg$currPos = s3;
2073
- s3 = peg$FAILED;
2074
- }
2075
- } else {
2076
- peg$currPos = s3;
2077
- s3 = peg$FAILED;
2078
- }
2079
- while (s3 !== peg$FAILED) {
2080
- s2.push(s3);
2081
- s3 = peg$currPos;
2082
- s4 = peg$currPos;
2083
- peg$silentFails++;
2084
- if (input.substr(peg$currPos, 2) === peg$c25) {
2085
- s5 = peg$c25;
2086
- peg$currPos += 2;
2087
- } else {
2088
- s5 = peg$FAILED;
2089
- if (peg$silentFails === 0) {
2090
- peg$fail(peg$e27);
2091
- }
2092
- }
2093
- peg$silentFails--;
2094
- if (s5 === peg$FAILED) {
2095
- s4 = void 0;
2096
- } else {
2097
- peg$currPos = s4;
2098
- s4 = peg$FAILED;
2099
- }
2100
- if (s4 !== peg$FAILED) {
2101
- if (input.length > peg$currPos) {
2102
- s5 = input.charAt(peg$currPos);
2103
- peg$currPos++;
2104
- } else {
2105
- s5 = peg$FAILED;
2106
- if (peg$silentFails === 0) {
2107
- peg$fail(peg$e28);
2108
- }
2109
- }
2110
- if (s5 !== peg$FAILED) {
2111
- peg$savedPos = s3;
2112
- s3 = peg$f32(s5);
2113
- } else {
2114
- peg$currPos = s3;
2115
- s3 = peg$FAILED;
2116
- }
2117
- } else {
2118
- peg$currPos = s3;
2119
- s3 = peg$FAILED;
2120
- }
2121
- }
2122
- if (input.substr(peg$currPos, 2) === peg$c25) {
2123
- s3 = peg$c25;
2124
- peg$currPos += 2;
2125
- } else {
2126
- s3 = peg$FAILED;
2127
- if (peg$silentFails === 0) {
2128
- peg$fail(peg$e27);
2129
- }
2130
- }
2131
- if (s3 !== peg$FAILED) {
2132
- peg$savedPos = s0;
2133
- s0 = peg$f33(s2);
2134
- } else {
2135
- peg$currPos = s0;
2136
- s0 = peg$FAILED;
2137
- }
2138
- } else {
2139
- peg$currPos = s0;
2140
- s0 = peg$FAILED;
2141
- }
2142
- return s0;
2143
- }
2144
- function peg$parse_slash_comment() {
2145
- var s0, s1, s2;
2146
- s0 = peg$currPos;
2147
- s1 = [];
2148
- s2 = peg$parse_slash_comment_line();
2149
- if (s2 !== peg$FAILED) {
2150
- while (s2 !== peg$FAILED) {
2151
- s1.push(s2);
2152
- s2 = peg$parse_slash_comment_line();
2153
- }
2154
- } else {
2155
- s1 = peg$FAILED;
2156
- }
2157
- if (s1 !== peg$FAILED) {
2158
- peg$savedPos = s0;
2159
- s1 = peg$f34(s1);
2160
- }
2161
- s0 = s1;
2162
- return s0;
2163
- }
2164
- function peg$parse_slash_comment_line() {
2165
- var s0, s2, s3, s4, s5, s6;
2166
- s0 = peg$currPos;
2167
- peg$parse_();
2168
- if (input.substr(peg$currPos, 2) === peg$c26) {
2169
- s2 = peg$c26;
2170
- peg$currPos += 2;
2171
- } else {
2172
- s2 = peg$FAILED;
2173
- if (peg$silentFails === 0) {
2174
- peg$fail(peg$e29);
2175
- }
2176
- }
2177
- if (s2 !== peg$FAILED) {
2178
- s3 = [];
2179
- s4 = peg$currPos;
2180
- s5 = peg$currPos;
2181
- peg$silentFails++;
2182
- s6 = peg$parse_newline();
2183
- peg$silentFails--;
2184
- if (s6 === peg$FAILED) {
2185
- s5 = void 0;
2186
- } else {
2187
- peg$currPos = s5;
2188
- s5 = peg$FAILED;
2189
- }
2190
- if (s5 !== peg$FAILED) {
2191
- if (input.length > peg$currPos) {
2192
- s6 = input.charAt(peg$currPos);
2193
- peg$currPos++;
2194
- } else {
2195
- s6 = peg$FAILED;
2196
- if (peg$silentFails === 0) {
2197
- peg$fail(peg$e28);
2198
- }
2199
- }
2200
- if (s6 !== peg$FAILED) {
2201
- peg$savedPos = s4;
2202
- s4 = peg$f35(s6);
2203
- } else {
2204
- peg$currPos = s4;
2205
- s4 = peg$FAILED;
2206
- }
2207
- } else {
2208
- peg$currPos = s4;
2209
- s4 = peg$FAILED;
2210
- }
2211
- while (s4 !== peg$FAILED) {
2212
- s3.push(s4);
2213
- s4 = peg$currPos;
2214
- s5 = peg$currPos;
2215
- peg$silentFails++;
2216
- s6 = peg$parse_newline();
2217
- peg$silentFails--;
2218
- if (s6 === peg$FAILED) {
2219
- s5 = void 0;
2220
- } else {
2221
- peg$currPos = s5;
2222
- s5 = peg$FAILED;
2223
- }
2224
- if (s5 !== peg$FAILED) {
2225
- if (input.length > peg$currPos) {
2226
- s6 = input.charAt(peg$currPos);
2227
- peg$currPos++;
2228
- } else {
2229
- s6 = peg$FAILED;
2230
- if (peg$silentFails === 0) {
2231
- peg$fail(peg$e28);
2232
- }
2233
- }
2234
- if (s6 !== peg$FAILED) {
2235
- peg$savedPos = s4;
2236
- s4 = peg$f35(s6);
2237
- } else {
2238
- peg$currPos = s4;
2239
- s4 = peg$FAILED;
2240
- }
2241
- } else {
2242
- peg$currPos = s4;
2243
- s4 = peg$FAILED;
2244
- }
2245
- }
2246
- s4 = peg$parse_newline();
2247
- if (s4 === peg$FAILED) {
2248
- s4 = null;
2249
- }
2250
- peg$savedPos = s0;
2251
- s0 = peg$f36(s3);
2252
- } else {
2253
- peg$currPos = s0;
2254
- s0 = peg$FAILED;
2255
- }
2256
- return s0;
2257
- }
2258
- function peg$parse_macro_comment() {
2259
- var s0, s1, s2;
2260
- s0 = peg$currPos;
2261
- s1 = [];
2262
- s2 = peg$parse_macro_comment_line();
2263
- if (s2 !== peg$FAILED) {
2264
- while (s2 !== peg$FAILED) {
2265
- s1.push(s2);
2266
- s2 = peg$parse_macro_comment_line();
2267
- }
2268
- } else {
2269
- s1 = peg$FAILED;
2270
- }
2271
- if (s1 !== peg$FAILED) {
2272
- peg$savedPos = s0;
2273
- s1 = peg$f37(s1);
2274
- }
2275
- s0 = s1;
2276
- return s0;
2277
- }
2278
- function peg$parse_macro_comment_line() {
2279
- var s0, s2, s3, s4, s5, s6;
2280
- s0 = peg$currPos;
2281
- peg$parse_();
2282
- if (input.charCodeAt(peg$currPos) === 35) {
2283
- s2 = peg$c27;
2284
- peg$currPos++;
2285
- } else {
2286
- s2 = peg$FAILED;
2287
- if (peg$silentFails === 0) {
2288
- peg$fail(peg$e30);
2289
- }
2290
- }
2291
- if (s2 !== peg$FAILED) {
2292
- s3 = [];
2293
- s4 = peg$currPos;
2294
- s5 = peg$currPos;
2295
- peg$silentFails++;
2296
- s6 = peg$parse_newline();
2297
- peg$silentFails--;
2298
- if (s6 === peg$FAILED) {
2299
- s5 = void 0;
2300
- } else {
2301
- peg$currPos = s5;
2302
- s5 = peg$FAILED;
2303
- }
2304
- if (s5 !== peg$FAILED) {
2305
- if (input.length > peg$currPos) {
2306
- s6 = input.charAt(peg$currPos);
2307
- peg$currPos++;
2308
- } else {
2309
- s6 = peg$FAILED;
2310
- if (peg$silentFails === 0) {
2311
- peg$fail(peg$e28);
2312
- }
2313
- }
2314
- if (s6 !== peg$FAILED) {
2315
- peg$savedPos = s4;
2316
- s4 = peg$f38(s6);
2317
- } else {
2318
- peg$currPos = s4;
2319
- s4 = peg$FAILED;
2320
- }
2321
- } else {
2322
- peg$currPos = s4;
2323
- s4 = peg$FAILED;
2324
- }
2325
- while (s4 !== peg$FAILED) {
2326
- s3.push(s4);
2327
- s4 = peg$currPos;
2328
- s5 = peg$currPos;
2329
- peg$silentFails++;
2330
- s6 = peg$parse_newline();
2331
- peg$silentFails--;
2332
- if (s6 === peg$FAILED) {
2333
- s5 = void 0;
2334
- } else {
2335
- peg$currPos = s5;
2336
- s5 = peg$FAILED;
2337
- }
2338
- if (s5 !== peg$FAILED) {
2339
- if (input.length > peg$currPos) {
2340
- s6 = input.charAt(peg$currPos);
2341
- peg$currPos++;
2342
- } else {
2343
- s6 = peg$FAILED;
2344
- if (peg$silentFails === 0) {
2345
- peg$fail(peg$e28);
2346
- }
2347
- }
2348
- if (s6 !== peg$FAILED) {
2349
- peg$savedPos = s4;
2350
- s4 = peg$f38(s6);
2351
- } else {
2352
- peg$currPos = s4;
2353
- s4 = peg$FAILED;
2354
- }
2355
- } else {
2356
- peg$currPos = s4;
2357
- s4 = peg$FAILED;
2358
- }
2359
- }
2360
- s4 = peg$parse_newline();
2361
- if (s4 === peg$FAILED) {
2362
- s4 = null;
2363
- }
2364
- peg$savedPos = s0;
2365
- s0 = peg$f39(s3);
2366
- } else {
2367
- peg$currPos = s0;
2368
- s0 = peg$FAILED;
2369
- }
2370
- return s0;
2371
- }
2372
- function peg$parseSTRING() {
2373
- var s0, s1, s2, s3;
2374
- peg$silentFails++;
2375
- s0 = peg$currPos;
2376
- s1 = peg$parseStringStart();
2377
- if (s1 !== peg$FAILED) {
2378
- s2 = [];
2379
- s3 = peg$parseStringPart();
2380
- while (s3 !== peg$FAILED) {
2381
- s2.push(s3);
2382
- s3 = peg$parseStringPart();
2383
- }
2384
- peg$savedPos = s0;
2385
- s0 = peg$f40(s1, s2);
2386
- } else {
2387
- peg$currPos = s0;
2388
- s0 = peg$FAILED;
2389
- }
2390
- peg$silentFails--;
2391
- if (s0 === peg$FAILED) {
2392
- s1 = peg$FAILED;
2393
- if (peg$silentFails === 0) {
2394
- peg$fail(peg$e31);
2395
- }
2396
- }
2397
- return s0;
2398
- }
2399
- function peg$parseNUMBER_STRING() {
2400
- var s0, s1, s2;
2401
- s0 = peg$currPos;
2402
- s1 = peg$parseNUMBER();
2403
- if (s1 !== peg$FAILED) {
2404
- s2 = peg$parseSTRING();
2405
- if (s2 !== peg$FAILED) {
2406
- peg$savedPos = s0;
2407
- s0 = peg$f41(s1, s2);
2408
- } else {
2409
- peg$currPos = s0;
2410
- s0 = peg$FAILED;
2411
- }
2412
- } else {
2413
- peg$currPos = s0;
2414
- s0 = peg$FAILED;
2415
- }
2416
- return s0;
2417
- }
2418
- function peg$parseStringStart() {
2419
- var s0;
2420
- s0 = input.charAt(peg$currPos);
2421
- if (peg$r1.test(s0)) {
2422
- peg$currPos++;
2423
- } else {
2424
- s0 = peg$FAILED;
2425
- if (peg$silentFails === 0) {
2426
- peg$fail(peg$e32);
2427
- }
2428
- }
2429
- return s0;
2430
- }
2431
- function peg$parseStringPart() {
2432
- var s0;
2433
- s0 = input.charAt(peg$currPos);
2434
- if (peg$r2.test(s0)) {
2435
- peg$currPos++;
2436
- } else {
2437
- s0 = peg$FAILED;
2438
- if (peg$silentFails === 0) {
2439
- peg$fail(peg$e33);
2440
- }
2441
- }
2442
- return s0;
2443
- }
2444
- function peg$parseNUMBER() {
2445
- var s0, s1, s2, s3, s4, s5, s6, s7, s8;
2446
- peg$silentFails++;
2447
- s0 = peg$currPos;
2448
- s1 = peg$currPos;
2449
- if (input.charCodeAt(peg$currPos) === 45) {
2450
- s2 = peg$c28;
2451
- peg$currPos++;
2452
- } else {
2453
- s2 = peg$FAILED;
2454
- if (peg$silentFails === 0) {
2455
- peg$fail(peg$e35);
2456
- }
2457
- }
2458
- if (s2 === peg$FAILED) {
2459
- s2 = null;
2460
- }
2461
- s3 = peg$currPos;
2462
- if (input.charCodeAt(peg$currPos) === 46) {
2463
- s4 = peg$c29;
2464
- peg$currPos++;
2465
- } else {
2466
- s4 = peg$FAILED;
2467
- if (peg$silentFails === 0) {
2468
- peg$fail(peg$e36);
2469
- }
2470
- }
2471
- if (s4 !== peg$FAILED) {
2472
- s5 = [];
2473
- s6 = input.charAt(peg$currPos);
2474
- if (peg$r3.test(s6)) {
2475
- peg$currPos++;
2476
- } else {
2477
- s6 = peg$FAILED;
2478
- if (peg$silentFails === 0) {
2479
- peg$fail(peg$e37);
2480
- }
2481
- }
2482
- if (s6 !== peg$FAILED) {
2483
- while (s6 !== peg$FAILED) {
2484
- s5.push(s6);
2485
- s6 = input.charAt(peg$currPos);
2486
- if (peg$r3.test(s6)) {
2487
- peg$currPos++;
2488
- } else {
2489
- s6 = peg$FAILED;
2490
- if (peg$silentFails === 0) {
2491
- peg$fail(peg$e37);
2492
- }
2493
- }
2494
- }
2495
- } else {
2496
- s5 = peg$FAILED;
2497
- }
2498
- if (s5 !== peg$FAILED) {
2499
- s4 = [s4, s5];
2500
- s3 = s4;
2501
- } else {
2502
- peg$currPos = s3;
2503
- s3 = peg$FAILED;
2504
- }
2505
- } else {
2506
- peg$currPos = s3;
2507
- s3 = peg$FAILED;
2508
- }
2509
- if (s3 === peg$FAILED) {
2510
- s3 = peg$currPos;
2511
- s4 = [];
2512
- s5 = input.charAt(peg$currPos);
2513
- if (peg$r3.test(s5)) {
2514
- peg$currPos++;
2515
- } else {
2516
- s5 = peg$FAILED;
2517
- if (peg$silentFails === 0) {
2518
- peg$fail(peg$e37);
2519
- }
2520
- }
2521
- if (s5 !== peg$FAILED) {
2522
- while (s5 !== peg$FAILED) {
2523
- s4.push(s5);
2524
- s5 = input.charAt(peg$currPos);
2525
- if (peg$r3.test(s5)) {
2526
- peg$currPos++;
2527
- } else {
2528
- s5 = peg$FAILED;
2529
- if (peg$silentFails === 0) {
2530
- peg$fail(peg$e37);
2531
- }
2532
- }
2533
- }
2534
- } else {
2535
- s4 = peg$FAILED;
2536
- }
2537
- if (s4 !== peg$FAILED) {
2538
- s5 = peg$currPos;
2539
- if (input.charCodeAt(peg$currPos) === 46) {
2540
- s6 = peg$c29;
2541
- peg$currPos++;
2542
- } else {
2543
- s6 = peg$FAILED;
2544
- if (peg$silentFails === 0) {
2545
- peg$fail(peg$e36);
2546
- }
2547
- }
2548
- if (s6 !== peg$FAILED) {
2549
- s7 = [];
2550
- s8 = input.charAt(peg$currPos);
2551
- if (peg$r3.test(s8)) {
2552
- peg$currPos++;
2553
- } else {
2554
- s8 = peg$FAILED;
2555
- if (peg$silentFails === 0) {
2556
- peg$fail(peg$e37);
2557
- }
2558
- }
2559
- while (s8 !== peg$FAILED) {
2560
- s7.push(s8);
2561
- s8 = input.charAt(peg$currPos);
2562
- if (peg$r3.test(s8)) {
2563
- peg$currPos++;
2564
- } else {
2565
- s8 = peg$FAILED;
2566
- if (peg$silentFails === 0) {
2567
- peg$fail(peg$e37);
2568
- }
2569
- }
2570
- }
2571
- s6 = [s6, s7];
2572
- s5 = s6;
2573
- } else {
2574
- peg$currPos = s5;
2575
- s5 = peg$FAILED;
2576
- }
2577
- if (s5 === peg$FAILED) {
2578
- s5 = null;
2579
- }
2580
- s4 = [s4, s5];
2581
- s3 = s4;
2582
- } else {
2583
- peg$currPos = s3;
2584
- s3 = peg$FAILED;
2585
- }
2586
- }
2587
- if (s3 !== peg$FAILED) {
2588
- s2 = [s2, s3];
2589
- s1 = s2;
2590
- } else {
2591
- peg$currPos = s1;
2592
- s1 = peg$FAILED;
2593
- }
2594
- if (s1 !== peg$FAILED) {
2595
- peg$savedPos = s0;
2596
- s1 = peg$f42();
2597
- }
2598
- s0 = s1;
2599
- peg$silentFails--;
2600
- if (s0 === peg$FAILED) {
2601
- s1 = peg$FAILED;
2602
- if (peg$silentFails === 0) {
2603
- peg$fail(peg$e34);
2604
- }
2605
- }
2606
- return s0;
2607
- }
2608
- function peg$parseHTML_STRING() {
2609
- var s0, s1;
2610
- s0 = peg$currPos;
2611
- s1 = peg$parsehtml_raw_string();
2612
- if (s1 !== peg$FAILED) {
2613
- peg$savedPos = s0;
2614
- s1 = peg$f43(s1);
2615
- }
2616
- s0 = s1;
2617
- return s0;
2618
- }
2619
- function peg$parsehtml_raw_string() {
2620
- var s0, s1, s2, s3;
2621
- s0 = peg$currPos;
2622
- if (input.charCodeAt(peg$currPos) === 60) {
2623
- s1 = peg$c30;
2624
- peg$currPos++;
2625
- } else {
2626
- s1 = peg$FAILED;
2627
- if (peg$silentFails === 0) {
2628
- peg$fail(peg$e38);
2629
- }
2630
- }
2631
- if (s1 !== peg$FAILED) {
2632
- s2 = [];
2633
- s3 = peg$parsehtml_char();
2634
- if (s3 === peg$FAILED) {
2635
- s3 = peg$parsehtml_raw_string();
2636
- }
2637
- while (s3 !== peg$FAILED) {
2638
- s2.push(s3);
2639
- s3 = peg$parsehtml_char();
2640
- if (s3 === peg$FAILED) {
2641
- s3 = peg$parsehtml_raw_string();
2642
- }
2643
- }
2644
- if (input.charCodeAt(peg$currPos) === 62) {
2645
- s3 = peg$c31;
2646
- peg$currPos++;
2647
- } else {
2648
- s3 = peg$FAILED;
2649
- if (peg$silentFails === 0) {
2650
- peg$fail(peg$e39);
2651
- }
2652
- }
2653
- if (s3 !== peg$FAILED) {
2654
- peg$savedPos = s0;
2655
- s0 = peg$f44(s2);
2656
- } else {
2657
- peg$currPos = s0;
2658
- s0 = peg$FAILED;
2659
- }
2660
- } else {
2661
- peg$currPos = s0;
2662
- s0 = peg$FAILED;
2663
- }
2664
- return s0;
2665
- }
2666
- function peg$parsehtml_char() {
2667
- var s0, s1, s2, s3, s4;
2668
- s0 = peg$currPos;
2669
- s1 = [];
2670
- s2 = peg$currPos;
2671
- s3 = peg$currPos;
2672
- peg$silentFails++;
2673
- s4 = input.charAt(peg$currPos);
2674
- if (peg$r4.test(s4)) {
2675
- peg$currPos++;
2676
- } else {
2677
- s4 = peg$FAILED;
2678
- if (peg$silentFails === 0) {
2679
- peg$fail(peg$e40);
2680
- }
2681
- }
2682
- peg$silentFails--;
2683
- if (s4 === peg$FAILED) {
2684
- s3 = void 0;
2685
- } else {
2686
- peg$currPos = s3;
2687
- s3 = peg$FAILED;
2688
- }
2689
- if (s3 !== peg$FAILED) {
2690
- if (input.length > peg$currPos) {
2691
- s4 = input.charAt(peg$currPos);
2692
- peg$currPos++;
2693
- } else {
2694
- s4 = peg$FAILED;
2695
- if (peg$silentFails === 0) {
2696
- peg$fail(peg$e28);
2697
- }
2698
- }
2699
- if (s4 !== peg$FAILED) {
2700
- peg$savedPos = s2;
2701
- s2 = peg$f45(s4);
2702
- } else {
2703
- peg$currPos = s2;
2704
- s2 = peg$FAILED;
2705
- }
2706
- } else {
2707
- peg$currPos = s2;
2708
- s2 = peg$FAILED;
2709
- }
2710
- if (s2 !== peg$FAILED) {
2711
- while (s2 !== peg$FAILED) {
2712
- s1.push(s2);
2713
- s2 = peg$currPos;
2714
- s3 = peg$currPos;
2715
- peg$silentFails++;
2716
- s4 = input.charAt(peg$currPos);
2717
- if (peg$r4.test(s4)) {
2718
- peg$currPos++;
2719
- } else {
2720
- s4 = peg$FAILED;
2721
- if (peg$silentFails === 0) {
2722
- peg$fail(peg$e40);
2723
- }
2724
- }
2725
- peg$silentFails--;
2726
- if (s4 === peg$FAILED) {
2727
- s3 = void 0;
2728
- } else {
2729
- peg$currPos = s3;
2730
- s3 = peg$FAILED;
2731
- }
2732
- if (s3 !== peg$FAILED) {
2733
- if (input.length > peg$currPos) {
2734
- s4 = input.charAt(peg$currPos);
2735
- peg$currPos++;
2736
- } else {
2737
- s4 = peg$FAILED;
2738
- if (peg$silentFails === 0) {
2739
- peg$fail(peg$e28);
2740
- }
2741
- }
2742
- if (s4 !== peg$FAILED) {
2743
- peg$savedPos = s2;
2744
- s2 = peg$f45(s4);
2745
- } else {
2746
- peg$currPos = s2;
2747
- s2 = peg$FAILED;
2748
- }
2749
- } else {
2750
- peg$currPos = s2;
2751
- s2 = peg$FAILED;
2752
- }
2753
- }
2754
- } else {
2755
- s1 = peg$FAILED;
2756
- }
2757
- if (s1 !== peg$FAILED) {
2758
- peg$savedPos = s0;
2759
- s1 = peg$f46(s1);
2760
- }
2761
- s0 = s1;
2762
- return s0;
2763
- }
2764
- function peg$parseQUOTED_STRING() {
2765
- var s0, s1, s2, s3;
2766
- s0 = peg$currPos;
2767
- if (input.charCodeAt(peg$currPos) === 34) {
2768
- s1 = peg$c23;
2769
- peg$currPos++;
2770
- } else {
2771
- s1 = peg$FAILED;
2772
- if (peg$silentFails === 0) {
2773
- peg$fail(peg$e25);
2774
- }
2775
- }
2776
- if (s1 !== peg$FAILED) {
2777
- s2 = [];
2778
- s3 = peg$parseDoubleStringCharacter();
2779
- while (s3 !== peg$FAILED) {
2780
- s2.push(s3);
2781
- s3 = peg$parseDoubleStringCharacter();
2782
- }
2783
- if (input.charCodeAt(peg$currPos) === 34) {
2784
- s3 = peg$c23;
2785
- peg$currPos++;
2786
- } else {
2787
- s3 = peg$FAILED;
2788
- if (peg$silentFails === 0) {
2789
- peg$fail(peg$e25);
2790
- }
2791
- }
2792
- if (s3 !== peg$FAILED) {
2793
- peg$savedPos = s0;
2794
- s0 = peg$f47(s2);
2795
- } else {
2796
- peg$currPos = s0;
2797
- s0 = peg$FAILED;
2798
- }
2799
- } else {
2800
- peg$currPos = s0;
2801
- s0 = peg$FAILED;
2802
- }
2803
- return s0;
2804
- }
2805
- function peg$parseDoubleStringCharacter() {
2806
- var s0, s1, s2;
2807
- s0 = peg$parseQuoteEscape();
2808
- if (s0 === peg$FAILED) {
2809
- s0 = peg$currPos;
2810
- s1 = peg$currPos;
2811
- peg$silentFails++;
2812
- s2 = input.charAt(peg$currPos);
2813
- if (peg$r5.test(s2)) {
2814
- peg$currPos++;
2815
- } else {
2816
- s2 = peg$FAILED;
2817
- if (peg$silentFails === 0) {
2818
- peg$fail(peg$e41);
2819
- }
2820
- }
2821
- peg$silentFails--;
2822
- if (s2 === peg$FAILED) {
2823
- s1 = void 0;
2824
- } else {
2825
- peg$currPos = s1;
2826
- s1 = peg$FAILED;
2827
- }
2828
- if (s1 !== peg$FAILED) {
2829
- s2 = peg$parseSourceCharacter();
2830
- if (s2 !== peg$FAILED) {
2831
- peg$savedPos = s0;
2832
- s0 = peg$f48();
2833
- } else {
2834
- peg$currPos = s0;
2835
- s0 = peg$FAILED;
2836
- }
2837
- } else {
2838
- peg$currPos = s0;
2839
- s0 = peg$FAILED;
2840
- }
2841
- if (s0 === peg$FAILED) {
2842
- s0 = peg$parseLineContinuation();
2843
- }
2844
- }
2845
- return s0;
2846
- }
2847
- function peg$parseQuoteEscape() {
2848
- var s0, s1, s2, s3;
2849
- s0 = peg$currPos;
2850
- s1 = peg$currPos;
2851
- if (input.charCodeAt(peg$currPos) === 92) {
2852
- s2 = peg$c32;
2853
- peg$currPos++;
2854
- } else {
2855
- s2 = peg$FAILED;
2856
- if (peg$silentFails === 0) {
2857
- peg$fail(peg$e42);
2858
- }
2859
- }
2860
- if (s2 !== peg$FAILED) {
2861
- if (input.length > peg$currPos) {
2862
- s3 = input.charAt(peg$currPos);
2863
- peg$currPos++;
2864
- } else {
2865
- s3 = peg$FAILED;
2866
- if (peg$silentFails === 0) {
2867
- peg$fail(peg$e28);
2868
- }
2869
- }
2870
- if (s3 !== peg$FAILED) {
2871
- s2 = [s2, s3];
2872
- s1 = s2;
2873
- } else {
2874
- peg$currPos = s1;
2875
- s1 = peg$FAILED;
2876
- }
2877
- } else {
2878
- peg$currPos = s1;
2879
- s1 = peg$FAILED;
2880
- }
2881
- if (s1 !== peg$FAILED) {
2882
- peg$savedPos = s0;
2883
- s1 = peg$f49(s1);
2884
- }
2885
- s0 = s1;
2886
- return s0;
2887
- }
2888
- function peg$parseLineContinuation() {
2889
- var s0, s1, s2;
2890
- s0 = peg$currPos;
2891
- if (input.charCodeAt(peg$currPos) === 92) {
2892
- s1 = peg$c32;
2893
- peg$currPos++;
2894
- } else {
2895
- s1 = peg$FAILED;
2896
- if (peg$silentFails === 0) {
2897
- peg$fail(peg$e42);
2898
- }
2899
- }
2900
- if (s1 !== peg$FAILED) {
2901
- s2 = peg$parseLineTerminatorSequence();
2902
- if (s2 !== peg$FAILED) {
2903
- peg$savedPos = s0;
2904
- s0 = peg$f50();
2905
- } else {
2906
- peg$currPos = s0;
2907
- s0 = peg$FAILED;
2908
- }
2909
- } else {
2910
- peg$currPos = s0;
2911
- s0 = peg$FAILED;
2912
- }
2913
- return s0;
2914
- }
2915
- function peg$parseLineTerminatorSequence() {
2916
- var s0;
2917
- peg$silentFails++;
2918
- if (input.charCodeAt(peg$currPos) === 10) {
2919
- s0 = peg$c33;
2920
- peg$currPos++;
2921
- } else {
2922
- s0 = peg$FAILED;
2923
- if (peg$silentFails === 0) {
2924
- peg$fail(peg$e45);
2925
- }
2926
- }
2927
- if (s0 === peg$FAILED) {
2928
- if (input.substr(peg$currPos, 2) === peg$c34) {
2929
- s0 = peg$c34;
2930
- peg$currPos += 2;
2931
- } else {
2932
- s0 = peg$FAILED;
2933
- if (peg$silentFails === 0) {
2934
- peg$fail(peg$e46);
2935
- }
2936
- }
2937
- if (s0 === peg$FAILED) {
2938
- s0 = input.charAt(peg$currPos);
2939
- if (peg$r7.test(s0)) {
2940
- peg$currPos++;
2941
- } else {
2942
- s0 = peg$FAILED;
2943
- if (peg$silentFails === 0) {
2944
- peg$fail(peg$e47);
2945
- }
2946
- }
2947
- }
2948
- }
2949
- peg$silentFails--;
2950
- if (s0 === peg$FAILED) {
2951
- if (peg$silentFails === 0) {
2952
- peg$fail(peg$e44);
2953
- }
2954
- }
2955
- return s0;
2956
- }
2957
- function peg$parseSourceCharacter() {
2958
- var s0;
2959
- if (input.length > peg$currPos) {
2960
- s0 = input.charAt(peg$currPos);
2961
- peg$currPos++;
2962
- } else {
2963
- s0 = peg$FAILED;
2964
- if (peg$silentFails === 0) {
2965
- peg$fail(peg$e28);
2966
- }
2967
- }
2968
- return s0;
2969
- }
2970
- function peg$parse_() {
2971
- var s0, s1;
2972
- peg$silentFails++;
2973
- s0 = [];
2974
- s1 = peg$parse_whitespace();
2975
- while (s1 !== peg$FAILED) {
2976
- s0.push(s1);
2977
- s1 = peg$parse_whitespace();
2978
- }
2979
- peg$silentFails--;
2980
- s1 = peg$FAILED;
2981
- if (peg$silentFails === 0) {
2982
- peg$fail(peg$e50);
2983
- }
2984
- return s0;
2985
- }
2986
- function peg$parse__() {
2987
- var s0, s1;
2988
- peg$silentFails++;
2989
- s0 = [];
2990
- s1 = input.charAt(peg$currPos);
2991
- if (peg$r9.test(s1)) {
2992
- peg$currPos++;
2993
- } else {
2994
- s1 = peg$FAILED;
2995
- if (peg$silentFails === 0) {
2996
- peg$fail(peg$e52);
2997
- }
2998
- }
2999
- while (s1 !== peg$FAILED) {
3000
- s0.push(s1);
3001
- s1 = input.charAt(peg$currPos);
3002
- if (peg$r9.test(s1)) {
3003
- peg$currPos++;
3004
- } else {
3005
- s1 = peg$FAILED;
3006
- if (peg$silentFails === 0) {
3007
- peg$fail(peg$e52);
3008
- }
3009
- }
3010
- }
3011
- peg$silentFails--;
3012
- s1 = peg$FAILED;
3013
- if (peg$silentFails === 0) {
3014
- peg$fail(peg$e51);
3015
- }
3016
- return s0;
3017
- }
3018
- function peg$parse_newline() {
3019
- var s0;
3020
- s0 = input.charAt(peg$currPos);
3021
- if (peg$r10.test(s0)) {
3022
- peg$currPos++;
3023
- } else {
3024
- s0 = peg$FAILED;
3025
- if (peg$silentFails === 0) {
3026
- peg$fail(peg$e53);
3027
- }
3028
- }
3029
- return s0;
3030
- }
3031
- function peg$parse_whitespace() {
3032
- var s0;
3033
- s0 = input.charAt(peg$currPos);
3034
- if (peg$r11.test(s0)) {
3035
- peg$currPos++;
3036
- } else {
3037
- s0 = peg$FAILED;
3038
- if (peg$silentFails === 0) {
3039
- peg$fail(peg$e54);
3040
- }
3041
- }
3042
- return s0;
3043
- }
3044
- function dedent(value) {
3045
- const str = value.trim();
3046
- const matches = str.match(/\n([\t ]+|(?!\s).)/g);
3047
- if (matches) {
3048
- const indentLengths = matches.map((match) => match.match(/[\t ]/g)?.length ?? 0);
3049
- const pattern = new RegExp(`
3050
- [ ]{${Math.min(...indentLengths)}}`, "g");
3051
- return str.replace(pattern, "\n");
3052
- }
3053
- return str;
3054
- }
3055
- const edgeops = [];
3056
- const b = new Builder({
3057
- // @ts-ignore
3058
- locationFunction: location
3059
- });
3060
- peg$result = peg$startRuleFunction();
3061
- if (options.peg$library) {
3062
- return (
3063
- /** @type {any} */
3064
- {
3065
- // @ts-ignore
3066
- peg$result,
3067
- // @ts-ignore
3068
- peg$currPos,
3069
- // @ts-ignore
3070
- peg$FAILED,
3071
- // @ts-ignore
3072
- peg$maxFailExpected,
3073
- // @ts-ignore
3074
- peg$maxFailPos
3075
- }
3076
- );
3077
- }
3078
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
3079
- return peg$result;
3080
- } else {
3081
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
3082
- peg$fail(peg$endExpectation());
3083
- }
3084
- throw peg$buildStructuredError(
3085
- // @ts-ignore
3086
- peg$maxFailExpected,
3087
- // @ts-ignore
3088
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
3089
- // @ts-ignore
3090
- peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
3091
- );
3092
- }
3093
- }
3094
- return {
3095
- StartRules: ["Dot", "Graph", "Subgraph", "Node", "Edge", "AttributeList", "Attribute", "ClusterStatements"],
3096
- SyntaxError: peg$SyntaxError,
3097
- parse: peg$parse
3098
- };
3099
- }()
3100
- );
3101
- peggyParser.SyntaxError.prototype.name = "PeggySyntaxError";
3102
- const parse$1 = peggyParser.parse;
3103
- const PeggySyntaxError = peggyParser.SyntaxError;
3104
- function parse(input, options) {
3105
- try {
3106
- return parse$1(input, options);
3107
- } catch (e) {
3108
- if (e instanceof PeggySyntaxError) {
3109
- throw new DotSyntaxError(e.message, {
3110
- cause: e
3111
- });
3112
- }
3113
- throw new Error("Unexpected parse error", {
3114
- cause: e
3115
- });
3116
- }
3117
- }
3118
- class DotSyntaxError extends SyntaxError {
3119
- constructor(...args) {
3120
- super(...args);
3121
- this.name = "DotSyntaxError";
3122
- }
3123
- }
3124
- function convertAttribute(key, value) {
3125
- if (typeof value === "string") {
3126
- const trimmed = value.trim();
3127
- const isHTMLLike = /^<.+>$/ms.test(trimmed);
3128
- if (isHTMLLike) {
3129
- return createElement(
3130
- "Attribute",
3131
- {
3132
- key: createElement("Literal", { value: key, quoted: false }, []),
3133
- value: createElement(
3134
- "Literal",
3135
- { value: trimmed.slice(1, trimmed.length - 1), quoted: "html" },
3136
- []
3137
- )
3138
- },
3139
- []
3140
- );
3141
- }
3142
- return createElement(
3143
- "Attribute",
3144
- {
3145
- key: createElement("Literal", { value: key, quoted: false }, []),
3146
- value: createElement("Literal", { value, quoted: true }, [])
3147
- },
3148
- []
3149
- );
3150
- }
3151
- return createElement(
3152
- "Attribute",
3153
- {
3154
- key: createElement("Literal", { value: key, quoted: false }, []),
3155
- value: createElement(
3156
- "Literal",
3157
- { value: String(value), quoted: false },
3158
- []
3159
- )
3160
- },
3161
- []
3162
- );
3163
- }
3164
- function convertComment(value, kind) {
3165
- return createElement(
3166
- "Comment",
3167
- {
3168
- kind,
3169
- value
3170
- },
3171
- []
3172
- );
3173
- }
3174
- function convertClusterChildren(context, model) {
3175
- return Array.from(
3176
- function* () {
3177
- for (const [key, value] of model.values) {
3178
- yield convertAttribute(key, value);
3179
- }
3180
- for (const attrs of Object.values(model.attributes)) {
3181
- if (attrs.size > 0) {
3182
- if (attrs.comment) {
3183
- yield convertComment(attrs.comment, context.commentKind);
3184
- }
3185
- yield context.convert(attrs);
3186
- }
3187
- }
3188
- for (const node of model.nodes) {
3189
- if (node.comment) {
3190
- yield convertComment(node.comment, context.commentKind);
3191
- }
3192
- yield context.convert(node);
3193
- }
3194
- for (const subgraph of model.subgraphs) {
3195
- if (subgraph.comment) {
3196
- yield convertComment(subgraph.comment, context.commentKind);
3197
- }
3198
- yield context.convert(subgraph);
3199
- }
3200
- for (const edge of model.edges) {
3201
- if (edge.comment) {
3202
- yield convertComment(edge.comment, context.commentKind);
3203
- }
3204
- yield context.convert(edge);
3205
- }
3206
- }()
3207
- );
3208
- }
3209
- const AttributeListPlugin = {
3210
- match(model) {
3211
- return model.$$type === "AttributeList";
3212
- },
3213
- convert(context, model) {
3214
- return createElement(
3215
- "AttributeList",
3216
- {
3217
- kind: model.$$kind
3218
- },
3219
- model.values.map(([key, value]) => convertAttribute(key, value))
3220
- );
3221
- }
3222
- };
3223
- const EdgePlugin$1 = {
3224
- match(model) {
3225
- return model.$$type === "Edge";
3226
- },
3227
- convert(context, model) {
3228
- return createElement(
3229
- "Edge",
3230
- {
3231
- targets: model.targets.map((target) => {
3232
- if (common.isNodeModel(target)) {
3233
- return createElement(
3234
- "NodeRef",
3235
- {
3236
- id: createElement(
3237
- "Literal",
3238
- {
3239
- value: target.id,
3240
- quoted: true
3241
- },
3242
- []
3243
- )
3244
- },
3245
- []
3246
- );
3247
- }
3248
- if (common.isForwardRefNode(target)) {
3249
- return createElement(
3250
- "NodeRef",
3251
- {
3252
- id: createElement(
3253
- "Literal",
3254
- {
3255
- value: target.id,
3256
- quoted: true
3257
- },
3258
- []
3259
- ),
3260
- port: target.port ? createElement(
3261
- "Literal",
3262
- {
3263
- value: target.port,
3264
- quoted: true
3265
- },
3266
- []
3267
- ) : void 0,
3268
- compass: target.compass ? createElement(
3269
- "Literal",
3270
- {
3271
- value: target.compass,
3272
- quoted: true
3273
- },
3274
- []
3275
- ) : void 0
3276
- },
3277
- []
3278
- );
3279
- }
3280
- return createElement(
3281
- "NodeRefGroup",
3282
- {},
3283
- target.map((n) => {
3284
- if (common.isNodeModel(n)) {
3285
- return createElement(
3286
- "NodeRef",
3287
- {
3288
- id: createElement(
3289
- "Literal",
3290
- {
3291
- value: n.id,
3292
- quoted: true
3293
- },
3294
- []
3295
- )
3296
- },
3297
- []
3298
- );
3299
- }
3300
- return createElement(
3301
- "NodeRef",
3302
- {
3303
- id: createElement(
3304
- "Literal",
3305
- {
3306
- value: n.id,
3307
- quoted: true
3308
- },
3309
- []
3310
- ),
3311
- port: n.port ? createElement(
3312
- "Literal",
3313
- {
3314
- value: n.port,
3315
- quoted: true
3316
- },
3317
- []
3318
- ) : void 0,
3319
- compass: n.compass ? createElement(
3320
- "Literal",
3321
- {
3322
- value: n.compass,
3323
- quoted: true
3324
- },
3325
- []
3326
- ) : void 0
3327
- },
3328
- []
3329
- );
3330
- })
3331
- );
3332
- })
3333
- },
3334
- [
3335
- ...model.attributes.comment ? [convertComment(model.attributes.comment, context.commentKind)] : [],
3336
- ...model.attributes.values.map(
3337
- ([key, value]) => convertAttribute(key, value)
3338
- )
3339
- ]
3340
- );
3341
- }
3342
- };
3343
- const GraphPlugin$1 = {
3344
- match(model) {
3345
- return model.$$type === "Graph";
3346
- },
3347
- convert(context, model) {
3348
- return createElement("Dot", {}, [
3349
- ...model.comment ? [convertComment(model.comment, context.commentKind)] : [],
3350
- createElement(
3351
- "Graph",
3352
- {
3353
- directed: model.directed,
3354
- strict: model.strict,
3355
- id: model.id ? createElement(
3356
- "Literal",
3357
- {
3358
- value: model.id,
3359
- quoted: true
3360
- },
3361
- []
3362
- ) : void 0
3363
- },
3364
- convertClusterChildren(context, model)
3365
- )
3366
- ]);
3367
- }
3368
- };
3369
- const NodePlugin$1 = {
3370
- match(model) {
3371
- return model.$$type === "Node";
3372
- },
3373
- convert(context, model) {
3374
- return createElement(
3375
- "Node",
3376
- {
3377
- id: createElement(
3378
- "Literal",
3379
- {
3380
- value: model.id,
3381
- quoted: true
3382
- },
3383
- []
3384
- )
3385
- },
3386
- [
3387
- ...model.attributes.comment ? [convertComment(model.attributes.comment, context.commentKind)] : [],
3388
- ...model.attributes.values.map(
3389
- ([key, value]) => convertAttribute(key, value)
3390
- )
3391
- ]
3392
- );
3393
- }
3394
- };
3395
- const SubgraphPlugin$1 = {
3396
- match(model) {
3397
- return model.$$type === "Subgraph";
3398
- },
3399
- convert(context, model) {
3400
- return createElement(
3401
- "Subgraph",
3402
- {
3403
- id: model.id ? createElement(
3404
- "Literal",
3405
- {
3406
- value: model.id,
3407
- quoted: true
3408
- },
3409
- []
3410
- ) : void 0
3411
- },
3412
- convertClusterChildren(context, model)
3413
- );
3414
- }
3415
- };
3416
- const defaultPlugins$1 = [
3417
- AttributeListPlugin,
3418
- EdgePlugin$1,
3419
- NodePlugin$1,
3420
- GraphPlugin$1,
3421
- SubgraphPlugin$1
3422
- ];
3423
- class FromModelConverter {
3424
- constructor(options = {}) {
3425
- this.options = options;
3426
- }
3427
- /** @hidden */
3428
- #plugins = [...defaultPlugins$1];
3429
- /**
3430
- * Converts a DotObjectModel into an AST.
3431
- *
3432
- * @param model The {@link DotObjectModel} to be converted.
3433
- * @returns The AST generated from the model.
3434
- */
3435
- convert(model) {
3436
- const plugins = [...this.#plugins];
3437
- const { commentKind = "Slash" } = this.options;
3438
- const context = {
3439
- commentKind,
3440
- convert(m) {
3441
- for (const plugin of plugins) {
3442
- if (plugin.match(m)) {
3443
- return plugin.convert(context, m);
3444
- }
3445
- }
3446
- throw Error();
3447
- }
3448
- };
3449
- return context.convert(model);
3450
- }
3451
- }
3452
- function fromModel(model, options) {
3453
- return new FromModelConverter(options).convert(model);
3454
- }
3455
- class CommentHolder {
3456
- comment = null;
3457
- set(comment) {
3458
- this.comment = comment;
3459
- }
3460
- reset() {
3461
- this.comment = null;
3462
- }
3463
- apply(model, location) {
3464
- if (location && this.comment?.location) {
3465
- if (this.comment?.kind === "Block") {
3466
- if (this.comment.location.end.line === location.start.line - 1) {
3467
- model.comment = this.comment.value;
3468
- }
3469
- } else {
3470
- if (this.comment.location.end.line === location.start.line) {
3471
- model.comment = this.comment.value;
3472
- }
3473
- }
3474
- } else {
3475
- model.comment = this.comment?.value;
3476
- }
3477
- this.reset();
3478
- }
3479
- }
3480
- const DotPlugin = {
3481
- match(ast) {
3482
- return ast.type === "Dot";
3483
- },
3484
- convert(context, ast) {
3485
- const commentHolder = new CommentHolder();
3486
- for (const stmt of ast.children) {
3487
- switch (stmt.type) {
3488
- case "Comment":
3489
- commentHolder.set(stmt);
3490
- break;
3491
- case "Graph": {
3492
- const graph = context.convert(stmt);
3493
- commentHolder.apply(graph, stmt.location);
3494
- return graph;
3495
- }
3496
- }
3497
- }
3498
- throw Error();
3499
- }
3500
- };
3501
- function convertToEdgeTargetTuple(edge) {
3502
- return edge.targets.map((t) => {
3503
- switch (t.type) {
3504
- case "NodeRef":
3505
- return {
3506
- id: t.id.value,
3507
- port: t.port?.value,
3508
- compass: t.compass?.value
3509
- };
3510
- case "NodeRefGroup":
3511
- return t.children.map((t2) => ({
3512
- id: t2.id.value,
3513
- port: t2.port?.value,
3514
- compass: t2.compass?.value
3515
- }));
3516
- }
3517
- });
3518
- }
3519
- const EdgePlugin = {
3520
- match(ast) {
3521
- return ast.type === "Edge";
3522
- },
3523
- convert(context, ast) {
3524
- const edge = new context.models.Edge(
3525
- convertToEdgeTargetTuple(ast),
3526
- ast.children.filter(
3527
- (v) => v.type === "Attribute"
3528
- ).reduce(
3529
- (acc, curr) => {
3530
- acc[curr.key.value] = curr.value.value;
3531
- return acc;
3532
- },
3533
- {}
3534
- )
3535
- );
3536
- return edge;
3537
- }
3538
- };
3539
- function applyStatements(graph, statements) {
3540
- const commentHolder = new CommentHolder();
3541
- for (const stmt of statements) {
3542
- switch (stmt.type) {
3543
- case "Subgraph": {
3544
- const subgraph = stmt.id ? graph.subgraph(stmt.id.value) : graph.subgraph();
3545
- applyStatements(subgraph, stmt.children);
3546
- commentHolder.apply(subgraph, stmt.location);
3547
- break;
3548
- }
3549
- case "Attribute":
3550
- graph.set(stmt.key.value, stmt.value.value);
3551
- commentHolder.reset();
3552
- break;
3553
- case "Node":
3554
- commentHolder.apply(
3555
- graph.node(
3556
- stmt.id.value,
3557
- stmt.children.filter(
3558
- (v) => v.type === "Attribute"
3559
- ).reduce(
3560
- (acc, curr) => {
3561
- acc[curr.key.value] = curr.value.value;
3562
- return acc;
3563
- },
3564
- {}
3565
- )
3566
- ),
3567
- stmt.location
3568
- );
3569
- break;
3570
- case "Edge":
3571
- commentHolder.apply(
3572
- graph.edge(
3573
- convertToEdgeTargetTuple(stmt),
3574
- stmt.children.filter(
3575
- (v) => v.type === "Attribute"
3576
- ).reduce(
3577
- (acc, curr) => {
3578
- acc[curr.key.value] = curr.value.value;
3579
- return acc;
3580
- },
3581
- {}
3582
- )
3583
- ),
3584
- stmt.location
3585
- );
3586
- break;
3587
- case "AttributeList": {
3588
- const attrs = stmt.children.filter(
3589
- (v) => v.type === "Attribute"
3590
- ).reduce(
3591
- (acc, curr) => {
3592
- acc[curr.key.value] = curr.value.value;
3593
- return acc;
3594
- },
3595
- {}
3596
- );
3597
- switch (stmt.kind) {
3598
- case "Edge":
3599
- graph.edge(attrs);
3600
- break;
3601
- case "Node":
3602
- graph.node(attrs);
3603
- break;
3604
- case "Graph":
3605
- graph.graph(attrs);
3606
- break;
3607
- }
3608
- commentHolder.reset();
3609
- break;
3610
- }
3611
- case "Comment":
3612
- commentHolder.set(stmt);
3613
- }
3614
- }
3615
- }
3616
- const GraphPlugin = {
3617
- match(ast) {
3618
- return ast.type === "Graph";
3619
- },
3620
- convert(context, ast) {
3621
- const G = ast.directed ? context.models.Digraph : context.models.Graph;
3622
- const graph = new G(ast.id?.value, ast.strict);
3623
- applyStatements(graph, ast.children);
3624
- return graph;
3625
- }
3626
- };
3627
- const NodePlugin = {
3628
- match(ast) {
3629
- return ast.type === "Node";
3630
- },
3631
- convert(context, ast) {
3632
- const node = new context.models.Node(
3633
- ast.id.value,
3634
- ast.children.filter(
3635
- (v) => v.type === "Attribute"
3636
- ).reduce(
3637
- (acc, curr) => {
3638
- acc[curr.key.value] = curr.value.value;
3639
- return acc;
3640
- },
3641
- {}
3642
- )
3643
- );
3644
- return node;
3645
- }
3646
- };
3647
- const SubgraphPlugin = {
3648
- match(ast) {
3649
- return ast.type === "Subgraph";
3650
- },
3651
- convert(context, ast) {
3652
- const subgraph = new context.models.Subgraph(ast.id?.value);
3653
- applyStatements(subgraph, ast.children);
3654
- return subgraph;
3655
- }
3656
- };
3657
- const defaultPlugins = [
3658
- NodePlugin,
3659
- EdgePlugin,
3660
- SubgraphPlugin,
3661
- GraphPlugin,
3662
- DotPlugin
3663
- ];
3664
- class ToModelConverter {
3665
- constructor(options = {}) {
3666
- this.options = options;
3667
- }
3668
- /** @hidden */
3669
- plugins = [
3670
- ...defaultPlugins
3671
- ];
3672
- /**
3673
- * Convert AST to Model.
3674
- *
3675
- * @param ast AST node.
3676
- */
3677
- convert(ast) {
3678
- const plugins = [...this.plugins];
3679
- const context = {
3680
- models: common.createModelsContext(this.options.models ?? {}),
3681
- convert(m) {
3682
- for (const plugin of plugins) {
3683
- if (plugin.match(m)) {
3684
- return plugin.convert(context, m);
3685
- }
3686
- }
3687
- throw Error();
3688
- }
3689
- };
3690
- return context.convert(ast);
3691
- }
3692
- }
3693
- function toModel(ast, options) {
3694
- return new ToModelConverter(options).convert(ast);
3695
- }
3696
- exports.Builder = Builder;
3697
- exports.DotSyntaxError = DotSyntaxError;
3698
- exports.FromModelConverter = FromModelConverter;
3699
- exports.Printer = Printer;
3700
- exports.ToModelConverter = ToModelConverter;
3701
- exports.createElement = createElement;
3702
- exports.fromModel = fromModel;
3703
- exports.parse = parse;
3704
- exports.stringify = stringify;
3705
- exports.toModel = toModel;