Skip to content

Commit

Permalink
Test adam's working code
Browse files Browse the repository at this point in the history
  • Loading branch information
dbgrigsby committed Mar 7, 2018
1 parent b429c26 commit 34184f2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Custom_Tests/test07.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var x = 10;
{
var y = 2;
var z = x * y;
x = z;
}
return x;
2 changes: 1 addition & 1 deletion interpreter.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
; All errors, despite their text, return 'error for test purposes
(define error->handler
(lambda (exception) ; It is correct to not delete the lambda to abstract this out. [exn:fail? error->handler] relies on this format.
'error))
exception))

; Important section helper functions for abstraction are defined below

Expand Down
26 changes: 19 additions & 7 deletions state-manipulation.scm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
((eq? 'var (get-upcoming-statement-name arglist)) (cons nullreturn (list (G-evaluate-var-declare-statement->state arglist state))))
((eq? 'while (get-upcoming-statement-name arglist)) (G-evaluate-while-statement->retval_state arglist state nullreturn))
((eq? 'if (get-upcoming-statement-name arglist)) (G-evaluate-if-statement->retval_state arglist state))
;((eq? 'begin (get-upcoming-statement-name arglist)) (G-evaluate-block-statement->retval_state arglist state))
((eq? 'begin (get-upcoming-statement-name arglist))
(list
(get-value-from-pair (evaluate-parse-tree->retval_state (cdr arglist) (G-add-scope-to-state->state state)))
(get-tail-scope (get-state-from-pair (evaluate-parse-tree->retval_state (cdr arglist) (G-add-scope-to-state->state state))))))
(else (cons nullreturn (list (get-state-from-pair (G-eval-atomic-statement->value_state arglist state))))))))

; Important section helper functions for abstraction are defined below
Expand All @@ -60,6 +65,20 @@



; Evaluate Block section

(define G-evaluate-block-statement->retval_state
(lambda (argslist state)
(cond
((evaluate-parse-tree->retval_state (rest-of-program argslist)
(G-remove-scope-from-state->state
(get-state-from-pair
(evaluate-parse-tree->retval_state
(block-statements argslist) (G-add-scope-to-state->state state)))))))))

(define block-statements cdr)
(define rest-of-program cdr)




Expand All @@ -82,13 +101,6 @@










; if statement section

; Returns the value yielded from an if statement and the updated state
Expand Down

0 comments on commit 34184f2

Please sign in to comment.