Skip to content

Commit

Permalink
Fix nested expression diagram element generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmcg committed Dec 31, 2024
1 parent dde1a02 commit 00d7aed
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 59 deletions.
28 changes: 14 additions & 14 deletions examples/complex_chemical_formulas_diagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,22 +257,22 @@ <h1 class="railroad-heading" id="integer-0001">integer</h1>
<h1 class="railroad-heading" id="subscript-operations-0007">subscript operations</h1>
<div class="railroad-description"></div>
<div class="railroad-svg">
<svg class="railroad-diagram" height="168" viewBox="0 0 539.0 168" width="539.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg class="railroad-diagram" height="168" viewBox="0 0 445.5 168" width="445.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g transform="translate(.5 .5)">
<g>
<path d="M20 29v20m10 -20v20m-10 -10h20" /></g><g>
<path d="M40 39h0.0" /><path d="M499.0 39h0.0" /><path d="M40.0 39h20" /><g>
<path d="M60.0 39h0.0" /><path d="M479.0 39h0.0" /><g>
<path d="M60.0 39h0.0" /><path d="M479.0 39h0.0" /><rect class="group-box" height="68" rx="10" ry="10" width="419" x="60" y="20"></rect><g>
<path d="M60.0 39h10.0" /><path d="M469.0 39h10.0" /><g>
<path d="M70.0 39h0.0" /><path d="M342.5 39h0.0" /><path d="M70.0 39h20" /><g class="non-terminal ">
<path d="M90.0 39h76.5" /><path d="M246.0 39h76.5" /><rect height="22" width="79.5" x="166.5" y="28"></rect><a xlink:href="#element-0003"><text x="206.25" y="43">element</text><text x="206.25" y="43">element</text></a></g><path d="M322.5 39h20" /><path d="M70.0 39a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M90.0 69h0.0" /><path d="M322.5 69h0.0" /><rect height="22" width="232.5" x="90" y="58"></rect><a xlink:href="#nested-element-expression-0005"><text x="206.25" y="73">nested_element_expression</text><text x="206.25" y="73">nested_element_expression</text></a></g><path d="M322.5 69a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10" /></g><path d="M342.5 39h10" /><g>
<path d="M352.5 39h0.0" /><path d="M469.0 39h0.0" /><path d="M352.5 39h10" /><g class="non-terminal ">
<path d="M362.5 39h0.0" /><path d="M459.0 39h0.0" /><rect height="22" width="96.5" x="362.5" y="28"></rect><a xlink:href="#subscript-0006"><text x="410.75" y="43">subscript</text><text x="410.75" y="43">subscript</text></a></g><path d="M459.0 39h10" /><path d="M362.5 39a10 10 0 0 0 -10 10v0a10 10 0 0 0 10 10" /><g>
<path d="M362.5 59h96.5" /></g><path d="M459.0 59a10 10 0 0 0 10 -10v0a10 10 0 0 0 -10 -10" /></g></g></g></g><path d="M479.0 39h20" /><path d="M40.0 39a10 10 0 0 1 10 10v48a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 107h169.75" /><path d="M309.25 107h169.75" /><rect height="22" width="79.5" x="229.75" y="96"></rect><a xlink:href="#element-0003"><text x="269.5" y="111">element</text><text x="269.5" y="111">element</text></a></g><path d="M479.0 107a10 10 0 0 0 10 -10v-48a10 10 0 0 1 10 -10" /><path d="M40.0 39a10 10 0 0 1 10 10v78a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 137h93.25" /><path d="M385.75 137h93.25" /><rect height="22" width="232.5" x="153.25" y="126"></rect><a xlink:href="#nested-element-expression-0005"><text x="269.5" y="141">nested_element_expression</text><text x="269.5" y="141">nested_element_expression</text></a></g><path d="M479.0 137a10 10 0 0 0 10 -10v-78a10 10 0 0 1 10 -10" /></g><path d="M 499.0 39 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
<path d="M40 39h0.0" /><path d="M405.5 39h0.0" /><path d="M40.0 39h20" /><g>
<path d="M60.0 39h0.0" /><path d="M385.5 39h0.0" /><g>
<path d="M60.0 39h0.0" /><path d="M385.5 39h0.0" /><rect class="group-box" height="68" rx="10" ry="10" width="325.5" x="60" y="20"></rect><g>
<path d="M60.0 39h10.0" /><path d="M375.5 39h10.0" /><g>
<path d="M70.0 39h0.0" /><path d="M249.0 39h0.0" /><path d="M70.0 39h20" /><g class="non-terminal ">
<path d="M90.0 39h29.75" /><path d="M199.25 39h29.75" /><rect height="22" width="79.5" x="119.75" y="28"></rect><a xlink:href="#element-0003"><text x="159.5" y="43">element</text><text x="159.5" y="43">element</text></a></g><path d="M229.0 39h20" /><path d="M70.0 39a10 10 0 0 1 10 10v10a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M90.0 69h0.0" /><path d="M229.0 69h0.0" /><rect height="22" width="139" x="90" y="58"></rect><a xlink:href="#nested-element-0005"><text x="159.5" y="73">nested_element</text><text x="159.5" y="73">nested_element</text></a></g><path d="M229.0 69a10 10 0 0 0 10 -10v-10a10 10 0 0 1 10 -10" /></g><path d="M249.0 39h10" /><g>
<path d="M259.0 39h0.0" /><path d="M375.5 39h0.0" /><path d="M259.0 39h10" /><g class="non-terminal ">
<path d="M269.0 39h0.0" /><path d="M365.5 39h0.0" /><rect height="22" width="96.5" x="269" y="28"></rect><a xlink:href="#subscript-0006"><text x="317.25" y="43">subscript</text><text x="317.25" y="43">subscript</text></a></g><path d="M365.5 39h10" /><path d="M269.0 39a10 10 0 0 0 -10 10v0a10 10 0 0 0 10 10" /><g>
<path d="M269.0 59h96.5" /></g><path d="M365.5 59a10 10 0 0 0 10 -10v0a10 10 0 0 0 -10 -10" /></g></g></g></g><path d="M385.5 39h20" /><path d="M40.0 39a10 10 0 0 1 10 10v48a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 107h123.0" /><path d="M262.5 107h123.0" /><rect height="22" width="79.5" x="183" y="96"></rect><a xlink:href="#element-0003"><text x="222.75" y="111">element</text><text x="222.75" y="111">element</text></a></g><path d="M385.5 107a10 10 0 0 0 10 -10v-48a10 10 0 0 1 10 -10" /><path d="M40.0 39a10 10 0 0 1 10 10v78a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 137h93.25" /><path d="M292.25 137h93.25" /><rect height="22" width="139" x="153.25" y="126"></rect><a xlink:href="#nested-element-0005"><text x="222.75" y="141">nested_element</text><text x="222.75" y="141">nested_element</text></a></g><path d="M385.5 137a10 10 0 0 0 10 -10v-78a10 10 0 0 1 10 -10" /></g><path d="M 405.5 39 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
svg.railroad-diagram {
background-color:hsl(30,20%,95%);
}
Expand Down Expand Up @@ -308,7 +308,7 @@ <h1 class="railroad-heading" id="subscript-operations-0007">subscript operations
</div>

<div class="railroad-group">
<h1 class="railroad-heading" id="nested-element-expression-0005">nested_element_expression</h1>
<h1 class="railroad-heading" id="nested-element-0005">nested_element</h1>
<div class="railroad-description"></div>
<div class="railroad-svg">
<svg class="railroad-diagram" height="94" viewBox="0 0 473.0 94" width="473.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down
28 changes: 14 additions & 14 deletions examples/decaf_parser_diagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -1063,20 +1063,20 @@ <h1 class="railroad-heading" id="z-operations-0062"><= | < | >= | > operations</
<h1 class="railroad-heading" id="z-operations-0042">'!' operations</h1>
<div class="railroad-description"></div>
<div class="railroad-svg">
<svg class="railroad-diagram" height="147" viewBox="0 0 378.0 147" width="378.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<svg class="railroad-diagram" height="147" viewBox="0 0 374.5 147" width="374.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g transform="translate(.5 .5)">
<g>
<path d="M20 38v20m10 -20v20m-10 -10h20" /></g><g>
<path d="M40 48h0.0" /><path d="M338.0 48h0.0" /><path d="M40.0 48h20" /><g>
<path d="M60.0 48h1.75" /><path d="M316.25 48h1.75" /><g>
<path d="M61.75 48h0.0" /><path d="M316.25 48h0.0" /><rect class="group-box" height="47" rx="10" ry="10" width="254.5" x="61.75" y="20"></rect><g>
<path d="M61.75 48h10.0" /><path d="M306.25 48h10.0" /><g>
<path d="M71.75 48h0.0" /><path d="M157.25 48h0.0" /><path d="M71.75 48a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10" /><g>
<path d="M91.75 28h45.5" /></g><path d="M137.25 28a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10" /><path d="M71.75 48h20" /><g class="terminal ">
<path d="M91.75 48h0.0" /><path d="M137.25 48h0.0" /><rect height="22" rx="10" ry="10" width="45.5" x="91.75" y="37"></rect><text x="114.5" y="52">&apos;!&apos;</text></g><path d="M137.25 48h20" /></g><path d="M157.25 48h10" /><g class="non-terminal ">
<path d="M167.25 48h0.0" /><path d="M306.25 48h0.0" /><rect height="22" width="139" x="167.25" y="37"></rect><a xlink:href="#z-operations-0042"><text x="236.75" y="52">&apos;!&apos; operations</text><text x="236.75" y="52">&apos;!&apos; operations</text></a></g></g></g></g><path d="M318.0 48h20" /><path d="M40.0 48a10 10 0 0 1 10 10v18a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 86h76.5" /><path d="M241.5 86h76.5" /><rect height="22" width="105" x="136.5" y="75"></rect><a xlink:href="#arith-expr-0053"><text x="189" y="90">arith_expr</text><text x="189" y="90">arith_expr</text></a></g><path d="M318.0 86a10 10 0 0 0 10 -10v-18a10 10 0 0 1 10 -10" /><path d="M40.0 48a10 10 0 0 1 10 10v48a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 116h0.0" /><path d="M318.0 116h0.0" /><rect height="22" width="258" x="60" y="105"></rect><a xlink:href="#nested-arith-expr-expression-0060"><text x="189" y="120">nested_arith_expr_expression</text><text x="189" y="120">nested_arith_expr_expression</text></a></g><path d="M318.0 116a10 10 0 0 0 10 -10v-48a10 10 0 0 1 10 -10" /></g><path d="M 338.0 48 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
<path d="M40 48h0.0" /><path d="M334.5 48h0.0" /><path d="M40.0 48h20" /><g>
<path d="M60.0 48h0.0" /><path d="M314.5 48h0.0" /><g>
<path d="M60.0 48h0.0" /><path d="M314.5 48h0.0" /><rect class="group-box" height="47" rx="10" ry="10" width="254.5" x="60" y="20"></rect><g>
<path d="M60.0 48h10.0" /><path d="M304.5 48h10.0" /><g>
<path d="M70.0 48h0.0" /><path d="M155.5 48h0.0" /><path d="M70.0 48a10 10 0 0 0 10 -10v0a10 10 0 0 1 10 -10" /><g>
<path d="M90.0 28h45.5" /></g><path d="M135.5 28a10 10 0 0 1 10 10v0a10 10 0 0 0 10 10" /><path d="M70.0 48h20" /><g class="terminal ">
<path d="M90.0 48h0.0" /><path d="M135.5 48h0.0" /><rect height="22" rx="10" ry="10" width="45.5" x="90" y="37"></rect><text x="112.75" y="52">&apos;!&apos;</text></g><path d="M135.5 48h20" /></g><path d="M155.5 48h10" /><g class="non-terminal ">
<path d="M165.5 48h0.0" /><path d="M304.5 48h0.0" /><rect height="22" width="139" x="165.5" y="37"></rect><a xlink:href="#z-operations-0042"><text x="235" y="52">&apos;!&apos; operations</text><text x="235" y="52">&apos;!&apos; operations</text></a></g></g></g></g><path d="M314.5 48h20" /><path d="M40.0 48a10 10 0 0 1 10 10v18a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 86h74.75" /><path d="M239.75 86h74.75" /><rect height="22" width="105" x="134.75" y="75"></rect><a xlink:href="#arith-expr-0053"><text x="187.25" y="90">arith_expr</text><text x="187.25" y="90">arith_expr</text></a></g><path d="M314.5 86a10 10 0 0 0 10 -10v-18a10 10 0 0 1 10 -10" /><path d="M40.0 48a10 10 0 0 1 10 10v48a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 116h45.0" /><path d="M269.5 116h45.0" /><rect height="22" width="164.5" x="105" y="105"></rect><a xlink:href="#nested-arith-expr-0060"><text x="187.25" y="120">nested_arith_expr</text><text x="187.25" y="120">nested_arith_expr</text></a></g><path d="M314.5 116a10 10 0 0 0 10 -10v-48a10 10 0 0 1 10 -10" /></g><path d="M 334.5 48 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
svg.railroad-diagram {
background-color:hsl(30,20%,95%);
}
Expand Down Expand Up @@ -1290,7 +1290,7 @@ <h1 class="railroad-heading" id="z---operations-0043">'-' operations</h1>
<path d="M60.0 386h80.75" /><path d="M271.25 386h80.75" /><rect height="22" width="130.5" x="140.75" y="375"></rect><a xlink:href="#new-statement-0050"><text x="206" y="390">new_statement</text><text x="206" y="390">new_statement</text></a></g><path d="M352.0 386a10 10 0 0 0 10 -10v-318a10 10 0 0 1 10 -10" /><path d="M40.0 48a10 10 0 0 1 10 10v348a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 416h97.75" /><path d="M254.25 416h97.75" /><rect height="22" width="96.5" x="157.75" y="405"></rect><a xlink:href="#new-array-0052"><text x="206" y="420">new_array</text><text x="206" y="420">new_array</text></a></g><path d="M352.0 416a10 10 0 0 0 10 -10v-348a10 10 0 0 1 10 -10" /><path d="M40.0 48a10 10 0 0 1 10 10v378a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 446h114.75" /><path d="M237.25 446h114.75" /><rect height="22" width="62.5" x="174.75" y="435"></rect><a xlink:href="#ident-0027"><text x="206" y="450">ident</text><text x="206" y="450">ident</text></a></g><path d="M352.0 446a10 10 0 0 0 10 -10v-378a10 10 0 0 1 10 -10" /><path d="M40.0 48a10 10 0 0 1 10 10v408a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 476h34.0" /><path d="M318.0 476h34.0" /><rect height="22" width="224" x="94" y="465"></rect><a xlink:href="#nested-rvalue-expression-0054"><text x="206" y="480">nested_rvalue_expression</text><text x="206" y="480">nested_rvalue_expression</text></a></g><path d="M352.0 476a10 10 0 0 0 10 -10v-408a10 10 0 0 1 10 -10" /></g><path d="M 372.0 48 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
<path d="M60.0 476h80.75" /><path d="M271.25 476h80.75" /><rect height="22" width="130.5" x="140.75" y="465"></rect><a xlink:href="#nested-rvalue-0054"><text x="206" y="480">nested_rvalue</text><text x="206" y="480">nested_rvalue</text></a></g><path d="M352.0 476a10 10 0 0 0 10 -10v-408a10 10 0 0 1 10 -10" /></g><path d="M 372.0 48 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
svg.railroad-diagram {
background-color:hsl(30,20%,95%);
}
Expand Down Expand Up @@ -1611,7 +1611,7 @@ <h1 class="railroad-heading" id="comma-0051">COMMA</h1>
</div>

<div class="railroad-group">
<h1 class="railroad-heading" id="nested-rvalue-expression-0054">nested_rvalue_expression</h1>
<h1 class="railroad-heading" id="nested-rvalue-0054">nested_rvalue</h1>
<div class="railroad-description"></div>
<div class="railroad-svg">
<svg class="railroad-diagram" height="94" viewBox="0 0 405.0 94" width="405.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down Expand Up @@ -1747,7 +1747,7 @@ <h1 class="railroad-heading" id="z-0057">+ | -</h1>
</div>

<div class="railroad-group">
<h1 class="railroad-heading" id="nested-arith-expr-expression-0060">nested_arith_expr_expression</h1>
<h1 class="railroad-heading" id="nested-arith-expr-0060">nested_arith_expr</h1>
<div class="railroad-description"></div>
<div class="railroad-svg">
<svg class="railroad-diagram" height="94" viewBox="0 0 498.5 94" width="498.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down
4 changes: 2 additions & 2 deletions examples/lox_parser_diagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ <h1 class="railroad-heading" id="z---operations-0030">! | - operations</h1>
<path d="M141.75 326h31.25" /><path d="M235.5 326h31.25" /><rect height="22" width="62.5" x="173" y="315"></rect><a xlink:href="#super-0023"><text x="204.25" y="330">SUPER</text><text x="204.25" y="330">SUPER</text></a></g><path d="M266.75 326a10 10 0 0 1 10 10v0a10 10 0 0 1 -10 10h-125.0a10 10 0 0 0 -10 10v0a10 10 0 0 0 10 10" /><g class="terminal ">
<path d="M141.75 366h39.75" /><path d="M227.0 366h39.75" /><rect height="22" rx="10" ry="10" width="45.5" x="181.5" y="355"></rect><text x="204.25" y="370">&apos;.&apos;</text></g><path d="M266.75 366a10 10 0 0 1 10 10v0a10 10 0 0 1 -10 10h-125.0a10 10 0 0 0 -10 10v0a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M141.75 406h10.0" /><path d="M256.75 406h10.0" /><rect height="22" width="105" x="151.75" y="395"></rect><a xlink:href="#identifier-0002"><text x="204.25" y="410">identifier</text><text x="204.25" y="410">identifier</text></a></g><path d="M266.75 406h10" /><path d="M276.75 406h71.75" /></g><path d="M348.5 406a10 10 0 0 0 10 -10v-338a10 10 0 0 1 10 -10" /><path d="M40.0 48a10 10 0 0 1 10 10v368a10 10 0 0 0 10 10" /><g class="non-terminal ">
<path d="M60.0 436h2.5" /><path d="M346.0 436h2.5" /><rect height="22" width="283.5" x="62.5" y="425"></rect><a xlink:href="#nested-arith-operand-expression-0032"><text x="204.25" y="440">nested_arith_operand_expression</text><text x="204.25" y="440">nested_arith_operand_expression</text></a></g><path d="M348.5 436a10 10 0 0 0 10 -10v-368a10 10 0 0 1 10 -10" /></g><path d="M 368.5 48 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
<path d="M60.0 436h49.25" /><path d="M299.25 436h49.25" /><rect height="22" width="190" x="109.25" y="425"></rect><a xlink:href="#nested-arith-operand-0032"><text x="204.25" y="440">nested_arith_operand</text><text x="204.25" y="440">nested_arith_operand</text></a></g><path d="M348.5 436a10 10 0 0 0 10 -10v-368a10 10 0 0 1 10 -10" /></g><path d="M 368.5 48 h 20 m -10 -10 v 20 m 10 -20 v 20"></path></g><style>/* <![CDATA[ */
svg.railroad-diagram {
background-color:hsl(30,20%,95%);
}
Expand Down Expand Up @@ -1815,7 +1815,7 @@ <h1 class="railroad-heading" id="identifier-0002">identifier</h1>
</div>

<div class="railroad-group">
<h1 class="railroad-heading" id="nested-arith-operand-expression-0032">nested_arith_operand_expression</h1>
<h1 class="railroad-heading" id="nested-arith-operand-0032">nested_arith_operand</h1>
<div class="railroad-description"></div>
<div class="railroad-svg">
<svg class="railroad-diagram" height="94" viewBox="0 0 524.0 94" width="524.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
Expand Down
Loading

0 comments on commit 00d7aed

Please sign in to comment.