rexim / ebf

Brainfuck language transpiler to Emacs Lisp
20 stars 3 forks source link

Get rid of progn in the compilation result #17

Closed rexim closed 8 years ago

rexim commented 8 years ago

The code

(ebf input output \,+++[->+<].)

currently produces

(let ((MEMORY68087 (make-vector 100 0))
      (POINTER68088 0)
      (INPUT68085 input)
      (OUTPUT68086 output))
  (aset MEMORY68087 POINTER68088 (funcall INPUT68085))
  (cl-incf (aref MEMORY68087 POINTER68088) 3)
  (while (not (zerop (aref MEMORY68087 POINTER68088)))
    (cl-decf (aref MEMORY68087 POINTER68088) 1)
    (progn (cl-incf POINTER68088 1)
           (while (<= (length MEMORY68087) POINTER68088)
             (let ((memory-length (length MEMORY68087)))
               (setq MEMORY68087
                     (vconcat MEMORY68087
                              (make-vector
                               (max 1 (/ memory-length 2))
                               0))))))
    (cl-incf (aref MEMORY68087 POINTER68088) 1)
    (cl-decf POINTER68088 1))
  (funcall OUTPUT68086 (aref MEMORY68087 POINTER68088)))

I believe we can get rid of that progn in the memory expansion chunk.