@formulavize/lezer-fiz 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,12 +19,12 @@ jobs:
19
19
  - name: Install pnpm
20
20
  uses: pnpm/action-setup@v4
21
21
  with:
22
- version: 10
22
+ version: 11
23
23
 
24
24
  - name: Set up Node.js
25
25
  uses: actions/setup-node@v4
26
26
  with:
27
- node-version: 24
27
+ node-version: 26
28
28
  cache: pnpm
29
29
 
30
30
  - run: pnpm install --frozen-lockfile
package/dist/index.cjs CHANGED
@@ -5,10 +5,10 @@ var highlight = require('@lezer/highlight');
5
5
 
6
6
  // This file was generated by lezer-generator. You probably shouldn't edit it.
7
7
  const Unit = 1,
8
- cssIdentifier = 45,
9
- insertSemi = 46,
10
- spaces = 48,
11
- newline = 49,
8
+ cssIdentifier = 47,
9
+ insertSemi = 48,
10
+ spaces = 50,
11
+ newline = 51,
12
12
  LineComment = 2,
13
13
  BlockComment = 3;
14
14
 
@@ -99,6 +99,7 @@ const fizHighlighting = highlight.styleTags({
99
99
  Unit: highlight.tags.unit,
100
100
  StyleTag: highlight.tags.tagName,
101
101
  Namespace: highlight.tags.namespace,
102
+ "RendererDirective/Identifier": highlight.tags.annotation,
102
103
  "( )": highlight.tags.paren,
103
104
  "{ }": highlight.tags.brace,
104
105
  "[ ]": highlight.tags.squareBracket,
@@ -110,24 +111,24 @@ const fizHighlighting = highlight.styleTags({
110
111
  // This file was generated by lezer-generator. You probably shouldn't edit it.
111
112
  const parser = lr.LRParser.deserialize({
112
113
  version: 14,
113
- states: "+|Q`QSOOO!YQdO'#CgOOQ`'#Cf'#CfO!gQSO'#CzO!nQdO'#CwO!|QSO'#C{O#RQSO'#CtO#ZQSO'#C}O#`QSO'#DOO#eQSO'#DQO#jQdO'#D`OOQO'#DS'#DSQ`QSOOO#rQSO'#DTO#wQfO,59RO$fQSO'#CeO$nQUO'#CkO$|QdO,58{OOQO,59a,59aO%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!aO!U!_O~Ob!bO~OU!cO~O]!fOe|Og{O}yO~O^`O!Oki!Yki~O^`OjiX!UiX~OUuO~OV!kO!U!_O~Oc!mOe!mO!W!lO~O[]O]ZXeZXgZX}ZX~OP!oO!OdX!UdX!YdX~O!OpO!U!pO!YpO~O!Q!RU!R~",
115
- goto: "&^!YPPPPP!ZPPP!k!Z!vPPP#T#o#sPP#wP#oP#{$RP$[PP$h$[P#{#{P#{P$t%O%X%_%e%kPPPPPP%q%wP%}P&TWYOR[fSv_!_Q!ZlR!h!XUaPu!YQhSR!Rc`QOR[_fl!X!_R!d{SbP!UQgSQ!PaS!QchQ![mQ!]nQ!^oR!g!RT|`}Tz`}T!m!b!pXYOR[fWUOR[fR!VjWYOR[fQ!ZlR!h!X[SOR[fl!XTcP!YQ[OQfRTr[fW^Pu!Y!cRt^Q!`xR!j!`Q}`R!e}Q!q!nR!t!qQkUR!WkXZOR[fQx_R!i!_Q!n!bR!s!pQqYQ!r!nR!u!q",
116
- nodeNames: "⚠ Unit LineComment BlockComment Recipe Call Identifier ) ( ArgList RhsVariable QualifiableIdentifier . } { StyleArgList StyleDeclaration PropertyName : ColorLiteral NumberLiteral StringLiteral StyleTag # Assignment LhsVariable Eq Namespace ] [ StatementList Import @ StyleTagDeclaration StyleBinding % GlobalStyleBinding *",
117
- maxTerm: 56,
114
+ states: ",`Q`QSOOO!]QdO'#CgOOQ`'#Cf'#CfO!jQSO'#CzO!qQdO'#CwO#PQSO'#C{O#UQSO'#CtO#^QSO'#C}O#cQSO'#DOO#hQSO'#DQO#mQSO'#DSO#rQdO'#DbOOQO'#DU'#DUQ`QSOOO#zQSO'#DVO$PQfO,59RO$nQSO'#CeO$vQUO'#CkO%UQdO,58{OOQO,59a,59aO%gQdO,59cO%uQSO,59gOOQ`,59f,59fO%zQSO,59fOOQ`,59c,59cO%jQdO,59cOOQ`,59g,59gO&RQSO'#DZO&WQSO,59`O&`QSO,59`O&kQSO,59iO&kQSO,59jO&kQSO,59lO&kQSO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^O]ZXeZXgZX!PZX~OP!rO!QdX!WdX![dX~O!QrO!W!sO![rO~O!S!TU!T~",
116
+ goto: "&c![PPPPP!]PPP!m!]!xPPP#V#t#xPP#|P#tP$Q$WP$aPP$m$aP$Q$QP$QP$QP$y%T%^%d%j%pPPPPPP%v%|P&SP&YWZOR]gSx`!bQ!]mR!k!ZUbPw![QiSR!Td`QOR]`gm!Z!bR!g}ScP!WQhSQ!RbS!SdiQ!^nQ!_oQ!`pQ!aqR!j!TT!Oa!PT|a!PT!p!e!sXZOR]gWUOR]gR!XkWZOR]gQ!]mR!k!Z[SOR]gm!ZTdP![Q]OQgRTt]gW_Pw![!fRv_Q!czR!m!cQ!PaR!h!PQ!t!qR!w!tQlUR!YlX[OR]gQz`R!l!bQ!q!eR!v!sQsZQ!u!qR!x!t",
117
+ nodeNames: "⚠ Unit LineComment BlockComment Recipe Call Identifier ) ( ArgList RhsVariable QualifiableIdentifier . } { StyleArgList StyleDeclaration PropertyName : ColorLiteral NumberLiteral StringLiteral StyleTag # Assignment LhsVariable Eq Namespace ] [ StatementList Import @ StyleTagDeclaration StyleBinding % GlobalStyleBinding * RendererDirective ^",
118
+ maxTerm: 58,
118
119
  context: trackNewline,
119
120
  nodeProps: [
120
- ["group", -2,5,10,"Statement Value",-3,19,20,21,"StyleValue",-6,24,27,31,33,34,36,"Statement"],
121
+ ["group", -2,5,10,"Statement Value",-3,19,20,21,"StyleValue",-7,24,27,31,33,34,36,38,"Statement"],
121
122
  ["openedBy", 7,"(",13,"{",28,"["],
122
123
  ["closedBy", 8,")",14,"}",29,"]"]
123
124
  ],
124
125
  propSources: [fizHighlighting],
125
126
  skippedNodes: [0,2,3],
126
127
  repeatNodeCount: 6,
127
- tokenData: "3P~R!RXY$[YZ%PZ[$[]^%Ppq$[rs%Ust&xtu)Zuv*Owx*Txy+ryz+wz{+|{|,R|}-m}!O,R!O!P-r!P!Q-z!Q![-[![!]/s!]!^/x!_!`/}!b!c0S!c!})Z!}#O0X#P#Q0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",
128
129
  tokenizers: [unitToken, cssIdentifierToken, 0, 1, insertSemicolon],
129
130
  topRules: {"Recipe":[0,4]},
130
- tokenPrec: 388
131
+ tokenPrec: 396
131
132
  });
132
133
 
133
134
  exports.parser = parser;
package/dist/index.es.js CHANGED
@@ -3,10 +3,10 @@ import { styleTags, tags } from '@lezer/highlight';
3
3
 
4
4
  // This file was generated by lezer-generator. You probably shouldn't edit it.
5
5
  const Unit = 1,
6
- cssIdentifier = 45,
7
- insertSemi = 46,
8
- spaces = 48,
9
- newline = 49,
6
+ cssIdentifier = 47,
7
+ insertSemi = 48,
8
+ spaces = 50,
9
+ newline = 51,
10
10
  LineComment = 2,
11
11
  BlockComment = 3;
12
12
 
@@ -97,6 +97,7 @@ const fizHighlighting = styleTags({
97
97
  Unit: tags.unit,
98
98
  StyleTag: tags.tagName,
99
99
  Namespace: tags.namespace,
100
+ "RendererDirective/Identifier": tags.annotation,
100
101
  "( )": tags.paren,
101
102
  "{ }": tags.brace,
102
103
  "[ ]": tags.squareBracket,
@@ -108,24 +109,24 @@ const fizHighlighting = styleTags({
108
109
  // This file was generated by lezer-generator. You probably shouldn't edit it.
109
110
  const parser = LRParser.deserialize({
110
111
  version: 14,
111
- states: "+|Q`QSOOO!YQdO'#CgOOQ`'#Cf'#CfO!gQSO'#CzO!nQdO'#CwO!|QSO'#C{O#RQSO'#CtO#ZQSO'#C}O#`QSO'#DOO#eQSO'#DQO#jQdO'#D`OOQO'#DS'#DSQ`QSOOO#rQSO'#DTO#wQfO,59RO$fQSO'#CeO$nQUO'#CkO$|QdO,58{OOQO,59a,59aO%_QdO,59cO%mQSO,59gOOQ`,59f,59fO%rQSO,59fOOQ`,59c,59cO%bQdO,59cOOQ`,59g,59gO%yQSO'#DXO&OQSO,59`O&WQSO,59`O&cQSO,59iO&cQSO,59jO&cQSO,59lOOQQ'#De'#DeOOQO,59z,59zOOQO-E7Q-E7QOOQb,59o,59oOOQb-E7R-E7RO&hQSO'#CgOOQO'#Da'#DaOO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P#{$RP$[PP$h$[P#{#{P#{P$t%O%X%_%e%kPPPPPP%q%wP%}P&TWYOR[fSv_!_Q!ZlR!h!XUaPu!YQhSR!Rc`QOR[_fl!X!_R!d{SbP!UQgSQ!PaS!QchQ![mQ!]nQ!^oR!g!RT|`}Tz`}T!m!b!pXYOR[fWUOR[fR!VjWYOR[fQ!ZlR!h!X[SOR[fl!XTcP!YQ[OQfRTr[fW^Pu!Y!cRt^Q!`xR!j!`Q}`R!e}Q!q!nR!t!qQkUR!WkXZOR[fQx_R!i!_Q!n!bR!s!pQqYQ!r!nR!u!q",
114
- nodeNames: "⚠ Unit LineComment BlockComment Recipe Call Identifier ) ( ArgList RhsVariable QualifiableIdentifier . } { StyleArgList StyleDeclaration PropertyName : ColorLiteral NumberLiteral StringLiteral StyleTag # Assignment LhsVariable Eq Namespace ] [ StatementList Import @ StyleTagDeclaration StyleBinding % GlobalStyleBinding *",
115
- maxTerm: 56,
112
+ states: ",`Q`QSOOO!]QdO'#CgOOQ`'#Cf'#CfO!jQSO'#CzO!qQdO'#CwO#PQSO'#C{O#UQSO'#CtO#^QSO'#C}O#cQSO'#DOO#hQSO'#DQO#mQSO'#DSO#rQdO'#DbOOQO'#DU'#DUQ`QSOOO#zQSO'#DVO$PQfO,59RO$nQSO'#CeO$vQUO'#CkO%UQdO,58{OOQO,59a,59aO%gQdO,59cO%uQSO,59gOOQ`,59f,59fO%zQSO,59fOOQ`,59c,59cO%jQdO,59cOOQ`,59g,59gO&RQSO'#DZO&WQSO,59`O&`QSO,59`O&kQSO,59iO&kQSO,59jO&kQSO,59lO&kQSO,59nOOQQ'#Dg'#DgOOQO,59|,59|OOQO-E7S-E7SOOQb,59q,59qOOQb-E7T-E7TO&pQSO'#CgOOQO'#Dc'#DcOOQ`,59P,59PO'OQSO,59POOQO'#Cm'#CmO'WQSO'#ClO']QSO'#CrOOQQ'#DX'#DXO'bQUO,59VOOQ`,59V,59VOOQ`1G.g1G.gOOQ`1G.}1G.}O'pQdO1G.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!bR!g}ScP!WQhSQ!RbS!SdiQ!^nQ!_oQ!`pQ!aqR!j!TT!Oa!PT|a!PT!p!e!sXZOR]gWUOR]gR!XkWZOR]gQ!]mR!k!Z[SOR]gm!ZTdP![Q]OQgRTt]gW_Pw![!fRv_Q!czR!m!cQ!PaR!h!PQ!t!qR!w!tQlUR!YlX[OR]gQz`R!l!bQ!q!eR!v!sQsZQ!u!qR!x!t",
115
+ nodeNames: "⚠ Unit LineComment BlockComment Recipe Call Identifier ) ( ArgList RhsVariable QualifiableIdentifier . } { StyleArgList StyleDeclaration PropertyName : ColorLiteral NumberLiteral StringLiteral StyleTag # Assignment LhsVariable Eq Namespace ] [ StatementList Import @ StyleTagDeclaration StyleBinding % GlobalStyleBinding * RendererDirective ^",
116
+ maxTerm: 58,
116
117
  context: trackNewline,
117
118
  nodeProps: [
118
- ["group", -2,5,10,"Statement Value",-3,19,20,21,"StyleValue",-6,24,27,31,33,34,36,"Statement"],
119
+ ["group", -2,5,10,"Statement Value",-3,19,20,21,"StyleValue",-7,24,27,31,33,34,36,38,"Statement"],
119
120
  ["openedBy", 7,"(",13,"{",28,"["],
120
121
  ["closedBy", 8,")",14,"}",29,"]"]
121
122
  ],
122
123
  propSources: [fizHighlighting],
123
124
  skippedNodes: [0,2,3],
124
125
  repeatNodeCount: 6,
125
- tokenData: "3P~R!RXY$[YZ%PZ[$[]^%Ppq$[rs%Ust&xtu)Zuv*Owx*Txy+ryz+wz{+|{|,R|}-m}!O,R!O!P-r!P!Q-z!Q![-[![!]/s!]!^/x!_!`/}!b!c0S!c!})Z!}#O0X#P#Q0^#R#S)Z#T#o)Z#o#p0c#q#r0h$f$g$[$g#BY)Z#BY#BZ0m#BZ$IS)Z$IS$I_0m$I_$I|)Z$I|$I}2`$I}$JO2`$JO$JT)Z$JT$JU0m$JU$KV)Z$KV$KW0m$KW&FU)Z&FU&FV0m&FV;'S)Z;'S;=`)x<%l?HT)Z?HT?HU0m?HUO)Z~$aY!Q~XY$[Z[$[p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)^!Q![)^!c!})^#R#S)^#T#o)^$g;'S)^;'S;=`){<%lO)^~*OP;=`<%l)^~*WOs~~*ZWOY*WZw*Wwx%tx#O*W#O#P*s#P;'S*W;'S;=`+o<%lO*W~*vRO;'S*W;'S;=`+P;=`O*W~+SXOY*WZw*Wwx%tx#O*W#O#P*s#P;'S*W;'S;=`+o;=`<%l*W<%lO*W~+rP;=`<%l*W~+zOW~~,POV~~,UOu~Q,XQ!O!P,_!Q![-_Q,bP!Q![,eQ,jR!YQ!Q![,e!g!h,s#X#Y,sQ,vR{|-P}!O-P!Q![-VQ-SP!Q![-VQ-[P!YQ!Q![-VQ-dS!YQ!O!P,e!Q![-_!g!h,s#X#Y,s~-uO!W~R-zP[P!Q![,e~.QQz{.W!P!Q/_~.ZTOz.Wz{.j{;'S.W;'S;=`/X<%lO.W~.mVOz.Wz{.j{!P.W!P!Q/S!Q;'S.W;'S;=`/X<%lO.W~/XOR~~/[P;=`<%l.W~/dSQ~OY/_Z;'S/_;'S;=`/p<%lO/_~/sP;=`<%l/_~/{Ob~~0QO![~~0VOj~~0[Op~~0aOm~~0fOl~~0kOw~~0pO^~~0uO]~~0|h!S~U~XY$_Z[$_pq$_tu)^!Q![)^!c!})^#R#S)^#T#o)^$f$g$_$g#BY)^#BY#BZ0u#BZ$IS)^$IS$I_0u$I_$JT)^$JT$JU0u$JU$KV)^$KV$KW0u$KW&FU)^&FU&FV0u&FV;'S)^;'S;=`){<%l?HT)^?HT?HU0u?HUO)^~2oW!T~U~tu)^!Q![)^!c!})^#R#S)^#T#o)^$g;'S)^;'S;=`){<%lO)^",
126
127
  tokenizers: [unitToken, cssIdentifierToken, 0, 1, insertSemicolon],
127
128
  topRules: {"Recipe":[0,4]},
128
- tokenPrec: 388
129
+ tokenPrec: 396
129
130
  });
130
131
 
131
132
  export { parser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formulavize/lezer-fiz",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "fiz grammar for lezer",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "module",
@@ -12,20 +12,20 @@
12
12
  "types": "dist/index.d.ts",
13
13
  "dependencies": {
14
14
  "@lezer/highlight": "^1.2.3",
15
- "@lezer/lr": "^1.4.8"
15
+ "@lezer/lr": "^1.4.10"
16
16
  },
17
17
  "devDependencies": {
18
18
  "@lezer/generator": "^1.8.0",
19
19
  "chokidar-cli": "^3.0.0",
20
- "mocha": "^11.7.5",
20
+ "mocha": "^11.8.0",
21
21
  "npm-run-all": "^4.1.5",
22
22
  "only-allow": "^1.2.2",
23
- "prettier": "^3.8.1",
24
- "rollup": "^4.60.1"
23
+ "prettier": "^3.9.6",
24
+ "rollup": "^4.62.4"
25
25
  },
26
26
  "engines": {
27
- "node": ">=24.0",
28
- "pnpm": ">=10"
27
+ "node": ">=26.0",
28
+ "pnpm": ">=11"
29
29
  },
30
30
  "scripts": {
31
31
  "preinstall": "npx only-allow pnpm",
@@ -0,0 +1,517 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>fiz Grammar — Railroad Diagrams</title>
7
+ <style>
8
+ body {
9
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
10
+ max-width: 1200px;
11
+ margin: 0 auto;
12
+ padding: 2rem;
13
+ background: #fafafa;
14
+ color: #222;
15
+ }
16
+ h1 { margin-bottom: 0.25rem; }
17
+ h1 + p { color: #666; margin-top: 0; }
18
+ .toc { margin: 1rem 0 2rem; columns: 3; column-gap: 2rem; }
19
+ .toc a { font-family: "SF Mono", "Fira Code", monospace; font-size: 0.9rem; display: block; margin-bottom: 0.3rem; }
20
+ section { margin-bottom: 2.5rem; scroll-margin-top: 1rem; }
21
+ h2 {
22
+ font-size: 1.1rem;
23
+ font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
24
+ background: #e8e8e8;
25
+ display: inline-block;
26
+ padding: 0.2rem 0.6rem;
27
+ border-radius: 4px;
28
+ margin-bottom: 0.5rem;
29
+ }
30
+ .note {
31
+ font-size: 0.85rem;
32
+ color: #666;
33
+ margin-top: 0.25rem;
34
+ font-style: italic;
35
+ }
36
+ svg { display: block; margin: 0.5rem 0; border: 1px solid #ddd; border-radius: 6px; background: #fff; }
37
+ </style>
38
+ </head>
39
+ <body>
40
+
41
+ <h1>fiz Grammar — Railroad Diagrams</h1>
42
+ <p>Auto-generated from <code>lezer-fiz/src/fiz.grammar</code></p>
43
+
44
+ <div id="toc" class="toc"></div>
45
+ <div id="diagrams"></div>
46
+
47
+ <script>
48
+ // ── Minimal railroad diagram renderer ──────────────────────────
49
+ // Generates SVG railroad/syntax diagrams without any dependencies.
50
+
51
+ const FONT = '13px "SF Mono","Fira Code","Cascadia Code",monospace';
52
+ const PAD = 6; // text padding inside boxes
53
+ const H = 24; // box height
54
+ const R = 10; // arc radius
55
+ const GAP = 10; // horizontal gap between elements
56
+ const VGAP = 8; // vertical gap between choice branches
57
+ const ARROW = 8; // arrowhead size
58
+
59
+ // Measure text width (approximate, works offline)
60
+ const _canvas = document.createElement("canvas");
61
+ const _ctx = _canvas.getContext("2d");
62
+ _ctx.font = FONT;
63
+ function tw(text) { return _ctx.measureText(text).width; }
64
+
65
+ // SVG helpers
66
+ function svgEl(tag, attrs, ...children) {
67
+ const el = document.createElementNS("http://www.w3.org/2000/svg", tag);
68
+ for (const [k, v] of Object.entries(attrs || {})) el.setAttribute(k, v);
69
+ for (const c of children) {
70
+ if (typeof c === "string") el.appendChild(document.createTextNode(c));
71
+ else if (c) el.appendChild(c);
72
+ }
73
+ return el;
74
+ }
75
+
76
+ function path(d) { return svgEl("path", { d, fill: "none", stroke: "#333", "stroke-width": "2" }); }
77
+
78
+ // ── Node types ──────────────────────────────────────────────────
79
+
80
+ class Terminal {
81
+ constructor(text) { this.text = text; this.w = tw(text) + PAD * 2 + 8; this.h = H; this.label = null; }
82
+ render(x, y) {
83
+ const g = svgEl("g");
84
+ const r = 6;
85
+ g.appendChild(svgEl("rect", { x, y: y - this.h / 2, width: this.w, height: this.h, rx: r, ry: r, fill: "#ddf4ff", stroke: "#333", "stroke-width": "1.5" }));
86
+ g.appendChild(svgEl("text", { x: x + this.w / 2, y: y + 4.5, "text-anchor": "middle", fill: "#222", style: `font: ${FONT}` }, this.text));
87
+ return g;
88
+ }
89
+ }
90
+
91
+ class NonTerminal {
92
+ constructor(text) { this.text = text; this.w = tw(text) + PAD * 2 + 8; this.h = H; this.label = null; }
93
+ render(x, y) {
94
+ const g = svgEl("g");
95
+ g.appendChild(svgEl("rect", { x, y: y - this.h / 2, width: this.w, height: this.h, fill: "#fff3cd", stroke: "#333", "stroke-width": "1.5" }));
96
+ g.appendChild(svgEl("text", { x: x + this.w / 2, y: y + 4.5, "text-anchor": "middle", fill: "#222", style: `font: ${FONT}` }, this.text));
97
+ return g;
98
+ }
99
+ }
100
+
101
+ class Seq {
102
+ constructor(items) {
103
+ this.items = items;
104
+ this.h = Math.max(...items.map(i => i.h));
105
+ this.w = items.reduce((s, i) => s + i.w, 0) + GAP * (items.length - 1);
106
+ this.label = null;
107
+ }
108
+ render(x, y) {
109
+ const g = svgEl("g");
110
+ let cx = x;
111
+ for (let i = 0; i < this.items.length; i++) {
112
+ const item = this.items[i];
113
+ g.appendChild(item.render(cx, y));
114
+ cx += item.w;
115
+ if (i < this.items.length - 1) {
116
+ g.appendChild(path(`M${cx},${y} h${GAP}`));
117
+ cx += GAP;
118
+ }
119
+ }
120
+ return g;
121
+ }
122
+ }
123
+
124
+ function measureBranches(items) {
125
+ // For each item, measure height above and below center
126
+ const above = [];
127
+ const below = [];
128
+ for (const item of items) {
129
+ above.push(item.h / 2);
130
+ below.push(item.h / 2);
131
+ }
132
+ return { above, below };
133
+ }
134
+
135
+ class ChoiceNode {
136
+ constructor(defaultIdx, items) {
137
+ this.defaultIdx = defaultIdx;
138
+ this.items = items;
139
+ const maxW = Math.max(...items.map(i => i.w));
140
+ this.innerW = maxW;
141
+ this.w = maxW + R * 4 + GAP * 2;
142
+
143
+ // Calculate total height
144
+ let totalH = 0;
145
+ for (let i = 0; i < items.length; i++) {
146
+ totalH += items[i].h;
147
+ if (i < items.length - 1) totalH += VGAP;
148
+ }
149
+ this.h = totalH;
150
+ this.label = null;
151
+
152
+ // Pre-calculate y offsets for each branch (relative to center of default branch)
153
+ this.branchY = [];
154
+ let accum = 0;
155
+ for (let i = 0; i < items.length; i++) {
156
+ this.branchY.push(accum + items[i].h / 2);
157
+ accum += items[i].h + VGAP;
158
+ }
159
+ const defaultCenter = this.branchY[defaultIdx];
160
+ for (let i = 0; i < this.branchY.length; i++) this.branchY[i] -= defaultCenter;
161
+ }
162
+ render(x, y) {
163
+ const g = svgEl("g");
164
+ const midX = x + this.w / 2;
165
+ for (let i = 0; i < this.items.length; i++) {
166
+ const item = this.items[i];
167
+ const by = y + this.branchY[i];
168
+ const itemX = midX - item.w / 2;
169
+ // Left connector
170
+ if (i === this.defaultIdx) {
171
+ g.appendChild(path(`M${x},${y} H${itemX}`));
172
+ } else {
173
+ const goDown = by > y;
174
+ if (goDown) {
175
+ g.appendChild(path(`M${x},${y} v${by - y - R} a${R},${R} 0 0,0 ${R},${R} H${itemX}`));
176
+ } else {
177
+ g.appendChild(path(`M${x},${y} v${by - y + R} a${R},${R} 0 0,1 ${R},-${R} H${itemX}`));
178
+ }
179
+ }
180
+ g.appendChild(item.render(itemX, by));
181
+ // Right connector
182
+ const rightEnd = x + this.w;
183
+ const itemRight = itemX + item.w;
184
+ if (i === this.defaultIdx) {
185
+ g.appendChild(path(`M${itemRight},${by} H${rightEnd}`));
186
+ } else {
187
+ const goUp = by > y;
188
+ if (goUp) {
189
+ g.appendChild(path(`M${itemRight},${by} H${rightEnd - R} a${R},${R} 0 0,0 ${R},-${R} V${y}`));
190
+ } else {
191
+ g.appendChild(path(`M${itemRight},${by} H${rightEnd - R} a${R},${R} 0 0,1 ${R},${R} V${y}`));
192
+ }
193
+ }
194
+ }
195
+ return g;
196
+ }
197
+ }
198
+
199
+ class LoopNode {
200
+ // item going forward, rep going backward (optional)
201
+ constructor(item, rep, skipAllowed) {
202
+ this.item = item;
203
+ this.rep = rep;
204
+ this.skipAllowed = skipAllowed;
205
+ this.w = Math.max(item.w, rep ? rep.w : 0) + R * 4 + GAP * 2;
206
+ const repH = rep ? rep.h : H * 0.6;
207
+ this.h = item.h + repH + VGAP;
208
+ this.label = null;
209
+ }
210
+ render(x, y) {
211
+ const g = svgEl("g");
212
+ const midX = x + this.w / 2;
213
+ const itemX = midX - this.item.w / 2;
214
+ const loopY = y + this.item.h / 2 + VGAP + (this.rep ? this.rep.h / 2 : 4);
215
+
216
+ if (this.skipAllowed) {
217
+ // Draw skip path above
218
+ const skipY = y - this.item.h / 2 - VGAP;
219
+ g.appendChild(path(`M${x},${y} v${skipY - y + R} a${R},${R} 0 0,1 ${R},-${R} H${x + this.w - R} a${R},${R} 0 0,1 ${R},${R} V${y}`));
220
+ }
221
+
222
+ // Forward path
223
+ g.appendChild(path(`M${x},${y} H${itemX}`));
224
+ g.appendChild(this.item.render(itemX, y));
225
+ g.appendChild(path(`M${itemX + this.item.w},${y} H${x + this.w}`));
226
+
227
+ // Loop-back path
228
+ const repX = this.rep ? midX - this.rep.w / 2 : midX;
229
+ // Right side going down
230
+ g.appendChild(path(`M${x + this.w - R},${y} a${R},${R} 0 0,1 ${R},${R} V${loopY - R} a${R},${R} 0 0,1 -${R},${R}`));
231
+ if (this.rep) {
232
+ g.appendChild(path(`M${x + this.w - R},${loopY} H${repX + this.rep.w}`));
233
+ g.appendChild(this.rep.render(repX, loopY));
234
+ g.appendChild(path(`M${repX},${loopY} H${x + R}`));
235
+ } else {
236
+ // Just a line with arrow
237
+ g.appendChild(path(`M${x + this.w - R},${loopY} H${x + R}`));
238
+ // Arrow in middle pointing left
239
+ const arrowX = midX;
240
+ g.appendChild(svgEl("polygon", { points: `${arrowX + 4},${loopY - 4} ${arrowX - 4},${loopY} ${arrowX + 4},${loopY + 4}`, fill: "#333", stroke: "none" }));
241
+ }
242
+ // Left side going up
243
+ g.appendChild(path(`M${x + R},${loopY} a${R},${R} 0 0,1 -${R},-${R} V${y + R} a${R},${R} 0 0,1 ${R},-${R}`));
244
+
245
+ return g;
246
+ }
247
+ }
248
+
249
+ class OptNode {
250
+ constructor(item) {
251
+ this.item = item;
252
+ this.w = item.w + R * 4 + GAP * 2;
253
+ this.h = item.h + VGAP + R * 2;
254
+ this.label = null;
255
+ }
256
+ render(x, y) {
257
+ const g = svgEl("g");
258
+ const midX = x + this.w / 2;
259
+ const itemX = midX - this.item.w / 2;
260
+
261
+ // Main path through item
262
+ g.appendChild(path(`M${x},${y} H${itemX}`));
263
+ g.appendChild(this.item.render(itemX, y));
264
+ g.appendChild(path(`M${itemX + this.item.w},${y} H${x + this.w}`));
265
+
266
+ // Skip path (below)
267
+ const skipY = y + this.item.h / 2 + VGAP;
268
+ g.appendChild(path(`M${x},${y} v${skipY - y - R} a${R},${R} 0 0,0 ${R},${R} H${x + this.w - R} a${R},${R} 0 0,0 ${R},-${R} V${y}`));
269
+
270
+ return g;
271
+ }
272
+ }
273
+
274
+ // ── Builder functions ───────────────────────────────────────────
275
+
276
+ function T(text) { return new Terminal(text); }
277
+ function NT(text) { return new NonTerminal(text); }
278
+ function Seq_(...items) { return items.length === 1 ? items[0] : new Seq(items); }
279
+ function Choice(defaultIdx, ...items) { return items.length === 1 ? items[0] : new ChoiceNode(defaultIdx, items); }
280
+ function Opt(item) { return new OptNode(item); }
281
+ function ZeroOrMore(item, rep) { return new LoopNode(item, rep || null, true); }
282
+ function OneOrMore(item, rep) { return new LoopNode(item, rep || null, false); }
283
+
284
+ function renderDiagram(node) {
285
+ const padX = 20;
286
+ const padY = 20;
287
+ const totalW = node.w + padX * 2 + 30; // extra for entry/exit lines
288
+ const totalH = node.h + padY * 2;
289
+
290
+ const svg = svgEl("svg", {
291
+ width: totalW,
292
+ height: totalH,
293
+ viewBox: `0 0 ${totalW} ${totalH}`,
294
+ class: "railroad-diagram",
295
+ });
296
+
297
+ const centerY = totalH / 2;
298
+ const startX = padX;
299
+ const nodeX = padX + 15;
300
+
301
+ // Entry line
302
+ svg.appendChild(path(`M${startX},${centerY} H${nodeX}`));
303
+ // Entry circle
304
+ svg.appendChild(svgEl("circle", { cx: startX, cy: centerY, r: 3, fill: "#333" }));
305
+
306
+ // Main content
307
+ svg.appendChild(node.render(nodeX, centerY));
308
+
309
+ // Exit line
310
+ const exitStart = nodeX + node.w;
311
+ const exitEnd = exitStart + 15;
312
+ svg.appendChild(path(`M${exitStart},${centerY} H${exitEnd}`));
313
+ // Exit double line
314
+ svg.appendChild(svgEl("circle", { cx: exitEnd, cy: centerY, r: 3, fill: "#333" }));
315
+ svg.appendChild(svgEl("circle", { cx: exitEnd, cy: centerY, r: 6, fill: "none", stroke: "#333", "stroke-width": "1.5" }));
316
+
317
+ return svg;
318
+ }
319
+
320
+ // ── Grammar definitions ─────────────────────────────────────────
321
+
322
+ const rules = [];
323
+ function def(name, node, note) { rules.push({ name, node, note }); }
324
+
325
+ // Recipe (top-level)
326
+ def("Recipe",
327
+ ZeroOrMore(NT("statement"))
328
+ );
329
+
330
+ // statement
331
+ def("statement",
332
+ Seq_(
333
+ Choice(0,
334
+ NT("Call"),
335
+ NT("RhsVariable"),
336
+ NT("Assignment"),
337
+ NT("StyleTagDeclaration"),
338
+ NT("StyleBinding"),
339
+ NT("GlobalStyleBinding"),
340
+ NT("Namespace"),
341
+ NT("Import"),
342
+ ),
343
+ NT("semi"),
344
+ )
345
+ );
346
+
347
+ // semi
348
+ def("semi",
349
+ Choice(0, T(";"), T("\u23CE auto-insert")),
350
+ "Semicolons are automatically inserted at newlines (ASI)"
351
+ );
352
+
353
+ // QualifiableIdentifier
354
+ def("QualifiableIdentifier",
355
+ Seq_(T("Identifier"), ZeroOrMore(Seq_(T("."), T("Identifier"))))
356
+ );
357
+
358
+ // Call
359
+ def("Call",
360
+ Seq_(T("Identifier"), NT("ArgList"), Opt(NT("StyleArgList")))
361
+ );
362
+
363
+ // ArgList
364
+ def("ArgList",
365
+ Seq_(T("("), Opt(Seq_(NT("value"), ZeroOrMore(Seq_(T(","), NT("value"))))), T(")"))
366
+ );
367
+
368
+ // value
369
+ def("value",
370
+ Choice(0, NT("RhsVariable"), NT("Call")),
371
+ "Namespace and Import are disallowed inside ArgList for readability"
372
+ );
373
+
374
+ // RhsVariable
375
+ def("RhsVariable",
376
+ NT("QualifiableIdentifier")
377
+ );
378
+
379
+ // LhsVariable
380
+ def("LhsVariable",
381
+ Seq_(T("Identifier"), Opt(NT("StyleArgList")))
382
+ );
383
+
384
+ // Assignment
385
+ def("Assignment",
386
+ Seq_(
387
+ NT("LhsVariable"),
388
+ ZeroOrMore(Seq_(T(","), NT("LhsVariable"))),
389
+ T("="),
390
+ Choice(0, NT("Call"), NT("RhsVariable"), NT("Namespace"), NT("Import")),
391
+ )
392
+ );
393
+
394
+ // Namespace
395
+ def("Namespace",
396
+ Seq_(Opt(T("Identifier")), NT("StatementList"), Opt(NT("ArgList")), Opt(NT("StyleArgList")))
397
+ );
398
+
399
+ // StatementList
400
+ def("StatementList",
401
+ Seq_(T("["), ZeroOrMore(NT("statement")), T("]"))
402
+ );
403
+
404
+ // Import
405
+ def("Import",
406
+ Seq_(Opt(T("Identifier")), T("@"), T("StringLiteral")),
407
+ "StringLiteral is a path-like resource identifier"
408
+ );
409
+
410
+ // StyleTagDeclaration
411
+ def("StyleTagDeclaration",
412
+ Seq_(T("#"), T("Identifier"), NT("StyleArgList"))
413
+ );
414
+
415
+ // StyleTag
416
+ def("StyleTag",
417
+ Seq_(T("#"), NT("QualifiableIdentifier"))
418
+ );
419
+
420
+ // StyleArgList
421
+ def("StyleArgList",
422
+ Seq_(T("{"), ZeroOrMore(Choice(0, NT("StyleDeclaration"), NT("StyleTag"), T("StringLiteral"))), T("}"))
423
+ );
424
+
425
+ // StyleDeclaration
426
+ def("StyleDeclaration",
427
+ Seq_(NT("PropertyName"), T(":"), NT("styleValue"), ZeroOrMore(Seq_(T(","), NT("styleValue"))), NT("semi"))
428
+ );
429
+
430
+ // styleValue
431
+ def("styleValue",
432
+ Choice(0, T("ColorLiteral"), NT("NumberLiteral"), T("StringLiteral"))
433
+ );
434
+
435
+ // StyleBinding
436
+ def("StyleBinding",
437
+ Seq_(T("%"), T("Identifier"), NT("StyleArgList"))
438
+ );
439
+
440
+ // GlobalStyleBinding
441
+ def("GlobalStyleBinding",
442
+ Seq_(T("*"), T("Identifier"), NT("StyleArgList"))
443
+ );
444
+
445
+ // NumberLiteral
446
+ def("NumberLiteral",
447
+ Seq_(T("number"), Opt(T("Unit")))
448
+ );
449
+
450
+ // PropertyName
451
+ def("PropertyName",
452
+ T("cssIdentifier")
453
+ );
454
+
455
+ // Identifier (token)
456
+ def("Identifier",
457
+ Seq_(T("letter | _ | $"), ZeroOrMore(T("letter | digit | _ | $"))),
458
+ "Token rule — also allows Unicode \\u00A1+"
459
+ );
460
+
461
+ // ColorLiteral (token)
462
+ def("ColorLiteral",
463
+ Seq_(T("#"), T("hex\u00D7 3"), Opt(Seq_(T("hex"), Opt(Seq_(T("hex\u00D7 2"), Opt(T("hex\u00D7 2"))))))),
464
+ "Supports #RGB, #RGBA, #RRGGBB, #RRGGBBAA"
465
+ );
466
+
467
+ // StringLiteral (token)
468
+ def("StringLiteral",
469
+ Choice(0,
470
+ Seq_(T('"'), ZeroOrMore(Choice(0, T("char"), Seq_(T("\\"), T("any")))), T('"')),
471
+ Seq_(T("'"), ZeroOrMore(Choice(0, T("char"), Seq_(T("\\"), T("any")))), T("'")),
472
+ ),
473
+ "Double or single quoted with backslash escapes"
474
+ );
475
+
476
+ // ── Render all ──────────────────────────────────────────────────
477
+
478
+ const container = document.getElementById("diagrams");
479
+ const tocEl = document.getElementById("toc");
480
+
481
+ for (const { name, node, note } of rules) {
482
+ const id = "rule-" + name;
483
+
484
+ // TOC entry
485
+ const a = document.createElement("a");
486
+ a.href = "#" + id;
487
+ a.textContent = name;
488
+ tocEl.appendChild(a);
489
+
490
+ // Section
491
+ const section = document.createElement("section");
492
+ section.id = id;
493
+ const heading = document.createElement("h2");
494
+ heading.textContent = name;
495
+ section.appendChild(heading);
496
+
497
+ try {
498
+ section.appendChild(renderDiagram(node));
499
+ } catch (e) {
500
+ const err = document.createElement("pre");
501
+ err.style.color = "red";
502
+ err.textContent = "Error rendering: " + e.message;
503
+ section.appendChild(err);
504
+ }
505
+
506
+ if (note) {
507
+ const p = document.createElement("p");
508
+ p.className = "note";
509
+ p.textContent = note;
510
+ section.appendChild(p);
511
+ }
512
+
513
+ container.appendChild(section);
514
+ }
515
+ </script>
516
+ </body>
517
+ </html>
package/src/fiz.grammar CHANGED
@@ -8,6 +8,7 @@ statement[@isGroup=Statement] {
8
8
  StyleTagDeclaration |
9
9
  StyleBinding |
10
10
  GlobalStyleBinding |
11
+ RendererDirective |
11
12
  Namespace |
12
13
  Import
13
14
  )
@@ -53,6 +54,8 @@ StyleBinding { "%" Identifier StyleArgList }
53
54
 
54
55
  GlobalStyleBinding { "*" Identifier StyleArgList }
55
56
 
57
+ RendererDirective { "^" Identifier StyleArgList }
58
+
56
59
  StatementList { "[" statement* "]" }
57
60
 
58
61
  Namespace { Identifier? StatementList ArgList? StyleArgList? }
@@ -111,6 +114,8 @@ Import { Identifier? "@" StringLiteral }
111
114
 
112
115
  "*"
113
116
 
117
+ "^"
118
+
114
119
  "(" ")" "{" "}" "[" "]"
115
120
 
116
121
  }
package/src/highlight.js CHANGED
@@ -12,6 +12,7 @@ export const fizHighlighting = styleTags({
12
12
  Unit: t.unit,
13
13
  StyleTag: t.tagName,
14
14
  Namespace: t.namespace,
15
+ "RendererDirective/Identifier": t.annotation,
15
16
  "( )": t.paren,
16
17
  "{ }": t.brace,
17
18
  "[ ]": t.squareBracket,
@@ -0,0 +1,154 @@
1
+ # Empty Renderer Directive
2
+
3
+ ^cytoscape{}
4
+
5
+ ==>
6
+
7
+ Recipe(
8
+ RendererDirective(Identifier, StyleArgList())
9
+ )
10
+
11
+ # Renderer Directive with Style Declarations
12
+
13
+ ^cytoscape{
14
+ rankDir: "LR"
15
+ background-color: #ff0000
16
+ }
17
+
18
+ ==>
19
+
20
+ Recipe(
21
+ RendererDirective(
22
+ Identifier,
23
+ StyleArgList(
24
+ StyleDeclaration(PropertyName, StringLiteral),
25
+ StyleDeclaration(PropertyName, ColorLiteral)
26
+ )
27
+ )
28
+ )
29
+
30
+ # Renderer Directive with StyleTags
31
+
32
+ ^cytoscape{
33
+ #compact #dark
34
+ }
35
+
36
+ ==>
37
+
38
+ Recipe(
39
+ RendererDirective(
40
+ Identifier,
41
+ StyleArgList(
42
+ StyleTag(QualifiableIdentifier(Identifier)),
43
+ StyleTag(QualifiableIdentifier(Identifier))
44
+ )
45
+ )
46
+ )
47
+
48
+ # Renderer Directive with Qualified StyleTag
49
+
50
+ ^cytoscape{ #themes.compact }
51
+
52
+ ==>
53
+
54
+ Recipe(
55
+ RendererDirective(
56
+ Identifier,
57
+ StyleArgList(
58
+ StyleTag(QualifiableIdentifier(Identifier, Identifier))
59
+ )
60
+ )
61
+ )
62
+
63
+ # Renderer Directive Mixed Content
64
+
65
+ ^cytoscape{
66
+ #base
67
+ rankDir: "TB"
68
+ "note"
69
+ }
70
+
71
+ ==>
72
+
73
+ Recipe(
74
+ RendererDirective(
75
+ Identifier,
76
+ StyleArgList(
77
+ StyleTag(QualifiableIdentifier(Identifier)),
78
+ StyleDeclaration(PropertyName, StringLiteral),
79
+ StringLiteral
80
+ )
81
+ )
82
+ )
83
+
84
+ # Multiple Renderer Directives
85
+
86
+ ^cytoscape{ rankDir: "LR" }
87
+ ^minimal{ x: "y" }
88
+
89
+ ==>
90
+
91
+ Recipe(
92
+ RendererDirective(
93
+ Identifier,
94
+ StyleArgList(StyleDeclaration(PropertyName, StringLiteral))
95
+ )
96
+ RendererDirective(
97
+ Identifier,
98
+ StyleArgList(StyleDeclaration(PropertyName, StringLiteral))
99
+ )
100
+ )
101
+
102
+ # Renderer Directive Alongside Global Style Binding
103
+
104
+ *node{ color: #abc }
105
+ ^cytoscape{ rankDir: "RL" }
106
+
107
+ ==>
108
+
109
+ Recipe(
110
+ GlobalStyleBinding(
111
+ Identifier,
112
+ StyleArgList(StyleDeclaration(PropertyName, ColorLiteral))
113
+ )
114
+ RendererDirective(
115
+ Identifier,
116
+ StyleArgList(StyleDeclaration(PropertyName, StringLiteral))
117
+ )
118
+ )
119
+
120
+ # Renderer Directive with Semicolons
121
+
122
+ ^cytoscape{ rankDir: "LR"; background-color: "#fff" };
123
+
124
+ ==>
125
+
126
+ Recipe(
127
+ RendererDirective(
128
+ Identifier,
129
+ StyleArgList(
130
+ StyleDeclaration(PropertyName, StringLiteral),
131
+ StyleDeclaration(PropertyName, StringLiteral)
132
+ )
133
+ )
134
+ )
135
+
136
+ # Renderer Directive in a StatementList
137
+
138
+ ns[
139
+ ^cytoscape{ rankDir: "LR" }
140
+ ]
141
+
142
+ ==>
143
+
144
+ Recipe(
145
+ Namespace(
146
+ Identifier,
147
+ StatementList(
148
+ RendererDirective(
149
+ Identifier,
150
+ StyleArgList(StyleDeclaration(PropertyName, StringLiteral))
151
+ )
152
+ )
153
+ )
154
+ )