diff options
Diffstat (limited to 'src/cljcc/tacky.clj')
| -rw-r--r-- | src/cljcc/tacky.clj | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/cljcc/tacky.clj b/src/cljcc/tacky.clj index e25c87f..4772766 100644 --- a/src/cljcc/tacky.clj +++ b/src/cljcc/tacky.clj @@ -61,9 +61,10 @@ (conj instructions (return-instruction val)))) (defn statement-transform [_ret-keyword exp] - (reverse (ret-instructions exp))) + {:instructions (reverse (ret-instructions exp))}) (defn tacky-generate [ast] + (reset! counter 0) (insta/transform {:statement statement-transform} ast)) (comment @@ -106,13 +107,11 @@ (pp/pprint (ret-instructions ex-ret)) - (def exprg - "int main(void) { + (def exprg + "int main(void) { return -(~(-8)); }") - (pp/pprint (parse "int main(void) {return 2;}")) - - (pp/pprint (parse exprg)) + (pp/pprint (parse "int main(void) {return 2;}")) - ,) + (pp/pprint (parse exprg))) |
