@knowvah/dot-engine 2.6.5 → 2.6.7
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/dist/common/htmltable-lex-chardata.d.ts +37 -0
- package/dist/common/htmltable-lex-chardata.d.ts.map +1 -0
- package/dist/common/htmltable-lex-expat.d.ts +11 -9
- package/dist/common/htmltable-lex-expat.d.ts.map +1 -1
- package/dist/common/htmltable-lex.d.ts.map +1 -1
- package/dist/common/htmltable-parse.d.ts.map +1 -1
- package/dist/common/htmltable-types.d.ts +2 -0
- package/dist/common/htmltable-types.d.ts.map +1 -1
- package/dist/index.js +311 -200
- package/dist/index.js.map +4 -4
- package/dist/parser/ast.d.ts +2 -0
- package/dist/parser/ast.d.ts.map +1 -1
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/render.js +311 -200
- package/dist/render.js.map +4 -4
- package/package.json +1 -1
- package/src/common/htmltable-lex-chardata.ts +95 -0
- package/src/common/htmltable-lex-expat.ts +84 -21
- package/src/common/htmltable-lex.ts +33 -27
- package/src/common/htmltable-parse.ts +30 -32
- package/src/common/htmltable-types.ts +2 -0
- package/src/parser/ast.ts +2 -0
- package/src/parser/dot.js +168 -137
- package/src/parser/dot.pegjs +13 -3
- package/src/parser/index.ts +5 -2
package/src/parser/dot.pegjs
CHANGED
|
@@ -10,19 +10,29 @@
|
|
|
10
10
|
|
|
11
11
|
// ── Top-level rule ───────────────────────────────────────────────────────────
|
|
12
12
|
// grammar.y: graph : hdr body | error | /* empty */
|
|
13
|
+
// `end` is the offset just past the graph's closing brace: the last input the
|
|
14
|
+
// C scanner lexes (see GraphEof). The empty graph lexes everything.
|
|
13
15
|
|
|
14
16
|
Graph
|
|
15
|
-
= _ s:OptStrict _ t:GraphType _ id:OptGraphName _ "{" _ stmts:StmtList _ "}"
|
|
17
|
+
= _ s:OptStrict _ t:GraphType _ id:OptGraphName _ "{" _ stmts:StmtList _ "}" end:GraphEof
|
|
16
18
|
{
|
|
17
19
|
return {
|
|
18
20
|
type: "graph",
|
|
19
21
|
strict: s,
|
|
20
22
|
directed: t,
|
|
21
23
|
id: id,
|
|
22
|
-
stmts: stmts
|
|
24
|
+
stmts: stmts,
|
|
25
|
+
end: end
|
|
23
26
|
};
|
|
24
27
|
}
|
|
25
|
-
/ _ "" { return { type: "graph", strict: false, directed: false, id: null, stmts: [] }; }
|
|
28
|
+
/ _ "" { return { type: "graph", strict: false, directed: false, id: null, stmts: [], end: text().length }; }
|
|
29
|
+
|
|
30
|
+
// grammar.y: graph : hdr body {freestack(); endgraph();} — endgraph calls
|
|
31
|
+
// scan.l:aglexeof, which unputs GRAPH_EOF_TOKEN ('@'), so the next token is
|
|
32
|
+
// EOF and nothing after the closing brace is ever lexed: agmemread reads one
|
|
33
|
+
// graph and ignores the rest, junk or a second graph alike.
|
|
34
|
+
GraphEof
|
|
35
|
+
= .* { return offset(); }
|
|
26
36
|
|
|
27
37
|
// grammar.y: hdr : optstrict graphtype optgraphname
|
|
28
38
|
// grammar.y: optstrict : T_strict | /* empty */
|
package/src/parser/index.ts
CHANGED
|
@@ -272,8 +272,11 @@ export function parse(src: string): Graph {
|
|
|
272
272
|
}
|
|
273
273
|
throw err;
|
|
274
274
|
}
|
|
275
|
+
// Only the graph's own text was lexed; what follows its closing brace is
|
|
276
|
+
// never read (grammar.y:endgraph -> scan.l:aglexeof).
|
|
277
|
+
const lexed = src.slice(0, ast.end);
|
|
275
278
|
try {
|
|
276
|
-
validateEdgeOperators(
|
|
279
|
+
validateEdgeOperators(lexed, ast.directed);
|
|
277
280
|
} catch (err: unknown) {
|
|
278
281
|
// C's lexer hands the wrong operator to bison as '-': a syntax error there.
|
|
279
282
|
const offset = err instanceof ParseError ? err.location.offset : undefined;
|
|
@@ -283,7 +286,7 @@ export function parse(src: string): Graph {
|
|
|
283
286
|
}
|
|
284
287
|
throw err;
|
|
285
288
|
}
|
|
286
|
-
warnNumberAmbiguities(
|
|
289
|
+
warnNumberAmbiguities(lexed, lexed.length);
|
|
287
290
|
return buildFromAst(ast);
|
|
288
291
|
}
|
|
289
292
|
|