(import (language infix))
(import (language match))
(import (utils functions))
(import (utils conversions))

(define (run)
  (let* ((line (read-line))
	 (expr (with-input-from-string line read-all)))
    (match expr
      (`(exit)
       (values))
      (`(,single)
       (let ((value (eval single)))
	 (cond ((or (procedure? value)
		    (is value instance? kawa.lang.Macro))
		(display (eval expr))
		(newline)
		(run))
	       (else
		(display value)
		(newline)
		(run)))))
      (`(,_ . ,_)
       (display (eval expr))
       (newline)
       (run))
      ('()
       (run)))))
