added repl
This commit is contained in:
13
main.lisp
13
main.lisp
@@ -14,7 +14,7 @@
|
|||||||
;; (generate-program program :compile t)))
|
;; (generate-program program :compile t)))
|
||||||
(compile-program (second args)))
|
(compile-program (second args)))
|
||||||
((string= flag "-i")
|
((string= flag "-i")
|
||||||
(format t "Interpret program WIP~%"))
|
(interpret-program (make-program (second args))))
|
||||||
(t (format t "~a is not a valid flag~%" flag))))))
|
(t (format t "~a is not a valid flag~%" flag))))))
|
||||||
|
|
||||||
;; (defun make-exe ()
|
;; (defun make-exe ()
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
;; :toplevel #'main
|
;; :toplevel #'main
|
||||||
;; :executable t))
|
;; :executable t))
|
||||||
|
|
||||||
(defparameter *example-path* "./test/prog.lorth")
|
(defparameter *example-path* (from-root "test/prog.lorth"))
|
||||||
|
|
||||||
(defun example-lex ()
|
(defun example-lex ()
|
||||||
(lex-file *example-path* t))
|
(lex-file *example-path* t))
|
||||||
@@ -34,6 +34,15 @@
|
|||||||
(generate-program (make-program *example-path*) :path "test/output.asm"
|
(generate-program (make-program *example-path*) :path "test/output.asm"
|
||||||
:compile t))
|
:compile t))
|
||||||
|
|
||||||
|
(defun example-interpret ()
|
||||||
|
(interpret-program (make-program *example-path*)))
|
||||||
|
|
||||||
(defun example-run ()
|
(defun example-run ()
|
||||||
(example-compile)
|
(example-compile)
|
||||||
(run '("test/output")))
|
(run '("test/output")))
|
||||||
|
|
||||||
|
(defun start-forth-repl ()
|
||||||
|
(iter (for line = (progn (format t "~&> ") (read-line)))
|
||||||
|
(when (string= line "bye")
|
||||||
|
(finish))
|
||||||
|
(interpret-program (parse-tokens (lex-line line 0)))))
|
||||||
|
|||||||
@@ -24,6 +24,9 @@
|
|||||||
(format t "~{~a~^ ~}~%" args)
|
(format t "~{~a~^ ~}~%" args)
|
||||||
(uiop:run-program args :output *standard-output*))
|
(uiop:run-program args :output *standard-output*))
|
||||||
|
|
||||||
|
(defun from-root (path)
|
||||||
|
(merge-pathnames path (asdf:system-source-directory :cl-forth)))
|
||||||
|
|
||||||
;; ,(file-namestring
|
;; ,(file-namestring
|
||||||
;; (make-pathname :name (pathname-name path)
|
;; (make-pathname :name (pathname-name path)
|
||||||
;; :type "o"))
|
;; :type "o"))
|
||||||
|
|||||||
Reference in New Issue
Block a user