From e9634ef6b77c080a2f4241225074da5f7b2d495f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind?= Date: Mon, 21 Feb 2022 12:41:33 +0100 Subject: [PATCH] Finish ps2 --- exercises/02/TDT4205_PS2_oyvindps.pdf | Bin 0 -> 29438 bytes exercises/02/vslc/src/parser.y | 1 + exercises/02/vslc/src/tree.c | 47 +++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 exercises/02/TDT4205_PS2_oyvindps.pdf diff --git a/exercises/02/TDT4205_PS2_oyvindps.pdf b/exercises/02/TDT4205_PS2_oyvindps.pdf new file mode 100644 index 0000000000000000000000000000000000000000..78bd121cef85c51fea5f47a34cfadf7ea4294ea2 GIT binary patch literal 29438 zcmeFYWmIHamMx6CyA!y(L*nl4?(XjH?(UYjd*Wn5;*z+#J0uQ|Teqsas{6M5dGGu4 z#fUK?VxJTH#GY%fd6vu|QxFlOW1?q+A?tl8dWT^JFaqq2tYE%;0Wio|+L;0NnYjQAasXxkgUaW*Ol-^m zK0X*zJCi@=1N=XJz_9((LR35*OaTlUN~UI?%P_Swcd-C4F|q*|#4K%GOr1VoZ46yZ zMNEzDO+HWi^Hssn$<`V02MWUWHmbgMyQ(iKVfNz0>FVKi39eQ2zsp&jmC6 zfrF%-iK)lu04v~6TqNzx>;WuHpT9#1z@TJr?*d@|^S$yXqyWx8=X3iTQY`-o9R^7e zfc6(QPE$@!BNHQbMpHu*HdbR3RwGVRQ)W|k7EU8$b`~SPFD532EG&%dh9+Drtc*-% z%&ewNT#TRZ*;$QD{xBDx?jJ^Qc5yN_w1x4=F*Y*UGB+?X;DjdCa1y8{2K2Xs4^e}n z=-2`5s1ppbU`Utz0!ViPzz$s!GPor$N@A%%B^+`<8)5{F;svU)kYI;QSHMY!1Xr*G zPL_lW%NT<+j27TzV&>?BhOn^2Ie~#v4iWbMu=?Mx`Tvpq{}Z79|G@t>1YrKy*Z&|5 zIYV1hX8`*j?)SOv@*T7fu`V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8nrY zp}QV<7w%!DiKnSeCy`;~Y=vX|w8%|v7slwoXfDi&4~_3FQ&Hg5WI~45G(=d^usKXH zs8Y2P3xm)_aB#VK5Rty5>DcamreU!*3oLg>5n3la?B7U{>v3uuk)9DvzB=tC+FJ3B z?hlPz(-huj^tz<85s`?H``PnEliXuVfFy-O_{YxEYH(PBR6UEZ$&90$HBPujN{a5^i-ytw`9j?~2JZfpA z%?!xARU|n%-+3uRGxkV}F?(Z@GPIl`b4+2$3sP?eX~a0tsZ#W*#*nV(U_Vh_Pf&$- z?%jOK()UA(0R>r2!(@seSl6IJRhLfHyJ^2e_r$XO9nDJW%}WKDJlUy%PYkV{E+cI- z{46tVam5v#{b5#^0VhuOZjox#g=ylGMjNH0fNoXx(WZue3cXKlX~n1`ZP@qnAvIYV z&fHut8A;~K)BTn~a^jwx#zBtySz52;M9C9Xp? zMlRxf4%$7N*^L8YSNnSv0r+pzCdhI|IJZ7BlUSGeZ0q~BnS7@m)O`n~nV{KX`$*u+F7k|_Vm8WC~AEwaTx-%={y(v&RC*lZKirsH-aJj`bJ%H{Ce1z zn9}mOL@o+y95KpJFBxxQl!ZNO`0)_m(6ll=@T*Buz6|0mnB7?sl&({A5?5E^1HIt3 z1T&1?i9;lj;3@tL(X{HiO8kU9mdr0ZG3(i*z>2}kks$y0V0=e#o>wbj$%JNFBfkbj zOVN#Ripx%AvwACkLcGYI{JVvGzLpY#N^z^|?e#}M6cRt_dAk8RW_$01pN~z9R8ECx z4vbXQg4qd~VQw3`#DS>OVvH8c2P~X5|lM$Blrvo(03~7RN40?H)>zbzC^~T?s$uhg&PlTUaR4@ML z^X@;ptpDq}{1*@++y8S8;(y`|KeC(ue-R8n@}-9>wVz{fcr=+gQKLBRFZ=G50+O4IsgCw literal 0 HcmV?d00001 diff --git a/exercises/02/vslc/src/parser.y b/exercises/02/vslc/src/parser.y index 3df5fde..ab5b7bd 100644 --- a/exercises/02/vslc/src/parser.y +++ b/exercises/02/vslc/src/parser.y @@ -13,6 +13,7 @@ %left '*' '/' %nonassoc UMINUS %right '~' +%expect 1 %nonassoc IF THEN %nonassoc ELSE diff --git a/exercises/02/vslc/src/tree.c b/exercises/02/vslc/src/tree.c index 25aab7a..4372474 100644 --- a/exercises/02/vslc/src/tree.c +++ b/exercises/02/vslc/src/tree.c @@ -5,6 +5,50 @@ static void node_finalize ( node_t *discard ); static void destroy_subtree ( node_t *discard ); +typedef struct stem_t *stem; +struct stem_t { const char *str; stem next; }; +static void +tree_print(node_t* root, stem head) +{ + static const char *sdown = " │", *slast = " └", *snone = " "; + struct stem_t col = {0, 0}, *tail; + + for (tail = head; tail; tail = tail->next) { + if (!tail->next) { + if (!strcmp(sdown, tail->str)) + printf(" ├"); + else + printf("%s", tail->str); + break; + } + printf("%s", tail->str); + } + + printf("──%s", node_string[root->type] ); + if ( root->type == IDENTIFIER_DATA || + root->type == STRING_DATA || + root->type == EXPRESSION ) + printf("(%s)", (char *) root->data); + else if (root->type == NUMBER_DATA) + printf ( "(%ld)", *((int64_t *)root->data) ); + putchar ( '\n' ); + + if (!root->n_children) return; + + if (tail && tail->str == slast) + tail->str = snone; + + if (!tail) tail = head = &col; + else tail->next = &col; + + for ( int64_t i=0; i < root->n_children; i++ ) { + col.str = root->n_children - i - 1 ? sdown : slast; + tree_print(root->children[i], head); + } + tail->next = 0; +} + + /* External interface */ void destroy_syntax_tree ( void ) @@ -16,7 +60,8 @@ destroy_syntax_tree ( void ) void print_syntax_tree ( void ) { - node_print ( root, 0 ); + //node_print ( root, 0 ); + tree_print(root, 0); }