Skip to content

Commit

Permalink
Merge branch 'AlbinTheander-let-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
Oskar Wickström committed Nov 29, 2015
2 parents 56775c6 + 1ca4095 commit 56f03ac
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions odenc/compiler/explode.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
(explode `(fn ,(list (car args)) ,(explode `(fn ,(cdr args) ,body))))]
[`(let ((,s ,v)) ,b)
`(let ((,s ,(explode v))) ,(explode b))]
[`(let ,ps ,b)
`(let ,(list (car ps)) ,(explode `(let ,(cdr ps) ,b)))]
[`(let ((,s ,v) ,ps ...) ,b)
`(let ((,s ,(explode v))) ,(explode `(let ,ps ,b)))]
[`(if ,c ,a ,b)
`(if ,(explode c) ,(explode a) ,(explode b))]
[`(,e : ,t)
Expand Down Expand Up @@ -52,6 +52,26 @@
(explode '((+ 1 2) : int))
'(((+ 1) 2) : int)))

(test-case "simple let expression"
(check-equal?
(explode '(let ((n 1)) n))
'(let ((n 1)) n)))

(test-case "simple double let expression"
(check-equal?
(explode '(let ((n 1) (m 2)) (+ n m)))
'(let ((n 1)) (let ((m 2)) ((+ n) m)))))

(test-case "single complex let expression"
(check-equal?
(explode '(let ((n (+ 1 2))) n))
'(let ((n ((+ 1) 2))) n)))

(test-case "double complex let expression"
(check-equal?
(explode '(let ((n (+ 1 2)) (m 5)) (+ n m)))
'(let ((n ((+ 1) 2))) (let ((m 5)) ((+ n) m)))))

(test-case "function application"
(check-equal?
(explode '(f a b c d e))
Expand Down

0 comments on commit 56f03ac

Please sign in to comment.