Skip to content

Commit

Permalink
Merge pull request #90 from triskaj/issue/89
Browse files Browse the repository at this point in the history
Changed unfolding of arithmetics from right to left
  • Loading branch information
takagi committed Nov 25, 2017
2 parents da575f2 + f524e5a commit 7b4d9a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/lang/compiler/compile-expression.lisp
Expand Up @@ -224,10 +224,10 @@
(operands (arithmetic-operands form)))
(if (<= (length operands) 2)
(compile-function form var-env func-env)
(let ((operand-head (car operands))
(operand-tail (cdr operands)))
(let ((form1 `(,operator ,operand-head
(,operator ,@operand-tail))))
(let ((operand-head (butlast operands))
(operand-tail (car (last operands))))
(let ((form1 `(,operator (,operator ,@operand-head)
,operand-tail)))
(compile-expression form1 var-env func-env))))))


Expand Down
2 changes: 1 addition & 1 deletion t/lang/compiler/compile-expression.lisp
Expand Up @@ -180,7 +180,7 @@

(let ((var-env (empty-variable-environment))
(func-env (empty-function-environment)))
(is (compile-arithmetic '(+ 1 1 1) var-env func-env) "(1 + (1 + 1))"
(is (compile-arithmetic '(+ 1 1 1) var-env func-env) "((1 + 1) + 1)"
"basic case 1"))


Expand Down

0 comments on commit 7b4d9a2

Please sign in to comment.