aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Burwell <bburwell1@gmail.com>2013-04-11 16:20:52 -0400
committerBen Burwell <bburwell1@gmail.com>2013-04-11 16:20:52 -0400
commit5680368dd6345def423482af5c25ec3c7894c9bf (patch)
treef4db5a3dec5bb5580f520f788e66526b8941e5d4
parent7d63dac5c845d51eefdd8d25f71bcb7021a0ba9b (diff)
Added do-while
-rw-r--r--hw08.scm15
1 files changed, 14 insertions, 1 deletions
diff --git a/hw08.scm b/hw08.scm
index db673c7..3252a28 100644
--- a/hw08.scm
+++ b/hw08.scm
@@ -58,6 +58,8 @@
while-stmt)
(statement ("var" (separated-list identifier ",") ";" statement)
block-stmt)
+ (statement ("do" statement "while" expression)
+ do-while-stmt)
; (3.1) expressions
(expression (number) lit-expr)
@@ -228,6 +230,14 @@
(block-stmt (ids statement)
(execute-statement statement
(extend-env ids (map (lambda (id) 0) ids) env) ))
+
+ (do-while-stmt (stmt exp)
+ (let loop ()
+ (begin
+ (execute-statement stmt env)
+ (if (true-value? (eval-expression exp env))
+ (loop)
+ '()))))
)))
; expression evaluator
@@ -416,4 +426,7 @@
;(scan&parse test3.9a)
;(scan&parse test3.9b)
(scan&parse&eval test3.9a)
-(scan&parse&eval test3.9b) \ No newline at end of file
+(scan&parse&eval test3.9b)
+
+; this will let us enter the repl immediately
+(read-eval-print) \ No newline at end of file