summaryrefslogtreecommitdiff
path: root/chapter03/docs/03-graph3.svg
diff options
context:
space:
mode:
authorDibyendu Majumdar <dibyendumajumdar@users.noreply.github.com>2023-10-01 18:01:54 +0100
committerGitHub <noreply@github.com>2023-10-01 10:01:54 -0700
commitdf5294e88cc409d7adf3e10666bfcb40e34472b9 (patch)
treea890d2a65704870a27211613b81f1e950f73a588 /chapter03/docs/03-graph3.svg
parent3f2e9e84e137462272ae1bb592f47cecc362bdff (diff)
downloadSimple-df5294e88cc409d7adf3e10666bfcb40e34472b9.tar.gz
Simple-df5294e88cc409d7adf3e10666bfcb40e34472b9.zip
Chapter 3 - add vars and lexical scope. (#7)
* Chapter 3 - add vars and lexical scope. * Fix typo * Overhaul graph viz Makes the scopes pointing into the graph being build more visually appealing. Constants are a printed with just the constant value. * Fix control edge color * Fix missing grouping operator parse Add a parens test. Shorten names 'Identifier' to 'Id' _lexer.match -> match require() passes a Node thru, so can be flow-coded. Uniform syntax error messages. Handy Lexer.toString for debugging. Drop Optional for null returns; less total code; less objects; less confusion. camelCase some fcns. * All parser helpers return Node, not void. Drop _ret. parseBlock and parseStatement now the same. * CLosely align chap2 and chap3 parsers Mostly whitespace aligned; dragged a few functions around to make more sense. I think the diff from Ch2 and Ch3 is down a few differences about what is a statement, plus all the symbol stuff for scopes and variables. * Add examples illustrating the symbol table creation. * Update docs and comments --------- Co-authored-by: Cliff Click <cliffc@acm.org>
Diffstat (limited to 'chapter03/docs/03-graph3.svg')
-rw-r--r--chapter03/docs/03-graph3.svg120
1 files changed, 120 insertions, 0 deletions
diff --git a/chapter03/docs/03-graph3.svg b/chapter03/docs/03-graph3.svg
new file mode 100644
index 00000000..3900b93d
--- /dev/null
+++ b/chapter03/docs/03-graph3.svg
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter03 Pages: 1 -->
+<svg width="394pt" height="292pt"
+ viewBox="0.00 0.00 394.00 292.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 288)">
+<title>chapter03</title>
+<polygon fill="white" stroke="transparent" points="-4,4 -4,-288 390,-288 390,4 -4,4"/>
+<g id="clust1" class="cluster">
+<title>cluster_Nodes</title>
+<polygon fill="none" stroke="black" points="8,-80 8,-276 378,-276 378,-80 8,-80"/>
+</g>
+<g id="clust2" class="cluster">
+<title>cluster_0</title>
+<polygon fill="none" stroke="black" points="115,-8 115,-60 259,-60 259,-8 115,-8"/>
+</g>
+<!-- Start1 -->
+<g id="node1" class="node">
+<title>Start1</title>
+<polygon fill="yellow" stroke="black" points="220,-268 166,-268 166,-232 220,-232 220,-268"/>
+<text text-anchor="middle" x="193" y="-246.3" font-family="Times,serif" font-size="14.00">Start</text>
+</g>
+<!-- Con_2 -->
+<g id="node2" class="node">
+<title>Con_2</title>
+<ellipse fill="none" stroke="black" cx="343" cy="-106" rx="27" ry="18"/>
+<text text-anchor="middle" x="343" y="-102.3" font-family="Times,serif" font-size="14.00">#1</text>
+</g>
+<!-- Con_19 -->
+<g id="node3" class="node">
+<title>Con_19</title>
+<ellipse fill="none" stroke="black" cx="216" cy="-178" rx="27" ry="18"/>
+<text text-anchor="middle" x="216" y="-174.3" font-family="Times,serif" font-size="14.00">#8</text>
+</g>
+<!-- Con_19&#45;&gt;Start1 -->
+<g id="edge1" class="edge">
+<title>Con_19&#45;&gt;Start1</title>
+<path fill="none" stroke="black" stroke-dasharray="1,5" d="M210.43,-195.95C207.84,-203.82 204.7,-213.38 201.8,-222.21"/>
+<polygon fill="black" stroke="black" points="198.47,-221.13 198.68,-231.72 205.12,-223.32 198.47,-221.13"/>
+</g>
+<!-- Con_3 -->
+<g id="node4" class="node">
+<title>Con_3</title>
+<ellipse fill="none" stroke="black" cx="271" cy="-106" rx="27" ry="18"/>
+<text text-anchor="middle" x="271" y="-102.3" font-family="Times,serif" font-size="14.00">#2</text>
+</g>
+<!-- Return20 -->
+<g id="node5" class="node">
+<title>Return20</title>
+<polygon fill="yellow" stroke="black" points="226,-124 160,-124 160,-88 226,-88 226,-124"/>
+<text text-anchor="middle" x="193" y="-102.3" font-family="Times,serif" font-size="14.00">Return</text>
+</g>
+<!-- Return20&#45;&gt;Start1 -->
+<g id="edge2" class="edge">
+<title>Return20&#45;&gt;Start1</title>
+<path fill="none" stroke="red" d="M187.59,-124.47C184.7,-134.71 181.45,-147.96 180,-160 178.08,-175.88 178.08,-180.12 180,-196 181.02,-204.47 182.93,-213.53 184.98,-221.72"/>
+<polygon fill="red" stroke="red" points="181.64,-222.77 187.59,-231.53 188.4,-220.97 181.64,-222.77"/>
+</g>
+<!-- Return20&#45;&gt;Con_19 -->
+<g id="edge3" class="edge">
+<title>Return20&#45;&gt;Con_19</title>
+<path fill="none" stroke="black" d="M198.69,-124.3C201.25,-132.1 204.33,-141.49 207.18,-150.17"/>
+<polygon fill="black" stroke="black" points="203.93,-151.49 210.38,-159.9 210.58,-149.3 203.93,-151.49"/>
+</g>
+<!-- Con_4 -->
+<g id="node6" class="node">
+<title>Con_4</title>
+<ellipse fill="none" stroke="black" cx="115" cy="-106" rx="27" ry="18"/>
+<text text-anchor="middle" x="115" y="-102.3" font-family="Times,serif" font-size="14.00">#3</text>
+</g>
+<!-- Con_5 -->
+<g id="node7" class="node">
+<title>Con_5</title>
+<ellipse fill="none" stroke="black" cx="43" cy="-106" rx="27" ry="18"/>
+<text text-anchor="middle" x="43" y="-102.3" font-family="Times,serif" font-size="14.00">#4</text>
+</g>
+<!-- scope0 -->
+<g id="node8" class="node">
+<title>scope0</title>
+<polygon fill="aqua" stroke="transparent" points="131,-23 131,-44 147,-44 147,-23 131,-23"/>
+<polygon fill="none" stroke="black" points="131,-23 131,-44 147,-44 147,-23 131,-23"/>
+<text text-anchor="start" x="134" y="-29.8" font-family="Times,serif" font-size="14.00">0</text>
+<polygon fill="none" stroke="black" points="147,-23 147,-44 171,-44 171,-23 147,-23"/>
+<text text-anchor="start" x="150" y="-29.8" font-family="Times,serif" font-size="14.00">y0</text>
+<polygon fill="none" stroke="black" points="171,-23 171,-44 195,-44 195,-23 171,-23"/>
+<text text-anchor="start" x="174" y="-29.8" font-family="Times,serif" font-size="14.00">x0</text>
+<polygon fill="none" stroke="black" points="195,-23 195,-44 219,-44 219,-23 195,-23"/>
+<text text-anchor="start" x="198" y="-29.8" font-family="Times,serif" font-size="14.00">y1</text>
+<polygon fill="none" stroke="black" points="219,-23 219,-44 243,-44 243,-23 219,-23"/>
+<text text-anchor="start" x="222" y="-29.8" font-family="Times,serif" font-size="14.00">x1</text>
+</g>
+<!-- scope0&#45;&gt;Con_2 -->
+<g id="edge5" class="edge">
+<title>scope0:scope0_x0&#45;&gt;Con_2</title>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M183,-45C183,-102.26 255.22,-55.55 307,-80 310.61,-81.71 314.26,-83.76 317.77,-85.96"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="315.88,-88.9 326.13,-91.56 319.78,-83.09 315.88,-88.9"/>
+</g>
+<!-- scope0&#45;&gt;Con_3 -->
+<g id="edge4" class="edge">
+<title>scope0:scope0_y0&#45;&gt;Con_3</title>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M159,-45C159,-82.19 202.71,-61.55 235,-80 238.3,-81.89 241.68,-83.99 244.99,-86.15"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="243.22,-89.18 253.46,-91.9 247.15,-83.39 243.22,-89.18"/>
+</g>
+<!-- scope0&#45;&gt;Con_4 -->
+<g id="edge7" class="edge">
+<title>scope0:scope0_x1&#45;&gt;Con_4</title>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M231,-45C231,-83.81 184.88,-61.06 151,-80 147.51,-81.95 143.94,-84.15 140.47,-86.42"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="138.44,-83.57 132.14,-92.09 142.37,-89.35 138.44,-83.57"/>
+</g>
+<!-- scope0&#45;&gt;Con_5 -->
+<g id="edge6" class="edge">
+<title>scope0:scope0_y1&#45;&gt;Con_5</title>
+<path fill="none" stroke="cornflowerblue" stroke-dasharray="5,2" d="M207,-45C207,-103.98 132.44,-55.04 79,-80 75.38,-81.69 71.73,-83.74 68.22,-85.93"/>
+<polygon fill="cornflowerblue" stroke="cornflowerblue" points="66.21,-83.06 59.85,-91.53 70.11,-88.87 66.21,-83.06"/>
+</g>
+</g>
+</svg>