From d438edc542ae524c69cd0a5259c76313cf3abc76 Mon Sep 17 00:00:00 2001 From: dibyendumajumdar Date: Sat, 28 Oct 2023 12:13:35 +0100 Subject: Add writeup of if statement parsing --- chapter05/docs/05-graph1.gv | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 chapter05/docs/05-graph1.gv (limited to 'chapter05/docs/05-graph1.gv') diff --git a/chapter05/docs/05-graph1.gv b/chapter05/docs/05-graph1.gv new file mode 100644 index 00000000..99993814 --- /dev/null +++ b/chapter05/docs/05-graph1.gv @@ -0,0 +1,85 @@ +digraph chapter05 { +/* +int a = 1; +if (arg == 1) + a = arg+2; +else { + a = arg-3; + #showGraph; +} +return a; +#showGraph; + +*/ + rankdir=BT; + subgraph cluster_Nodes { + Start1 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg
+
> + ]; + Con_5 [ label="#1" ]; + EQNode6 [ label="EQNode" ]; + If7 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Con_11 [ label="#2" ]; + Add12 [ label="Add" ]; + Con_13 [ label="#3" ]; + Sub14 [ label="Sub" ]; + } + node [shape=plaintext]; + subgraph cluster_Scope20_0 { + Scope20_0 [label=< + + +
0$ctrlarg
>]; + subgraph cluster_Scope20_1 { + Scope20_1 [label=< + + +
1a
>]; + } + } + node [shape=plaintext]; + subgraph cluster_Scope21_0 { + Scope21_0 [label=< + + +
0$ctrlarg
>]; + subgraph cluster_Scope21_1 { + Scope21_1 [label=< + + +
1a
>]; + } + } + EQNode6 -> Start1:p1; + EQNode6 -> Con_5; + If7 -> Start1:p0 [color=red]; + If7 -> EQNode6; + Add12 -> Start1:p1; + Add12 -> Con_11; + Sub14 -> Start1:p1; + Sub14 -> Con_13; + edge [style=dashed color=cornflowerblue]; + Scope20_0:"Scope20_0_$ctrl" -> If7:p1; + Scope20_0:"Scope20_0_arg" -> Start1:p1; + Scope20_1:"Scope20_1_a" -> Sub14; + edge [style=dashed color=cornflowerblue]; + Scope21_0:"Scope21_0_$ctrl" -> If7:p0; + Scope21_0:"Scope21_0_arg" -> Start1:p1; + Scope21_1:"Scope21_1_a" -> Add12; +} \ No newline at end of file -- cgit v1.2.3