summaryrefslogtreecommitdiff
path: root/main.lisp
diff options
context:
space:
mode:
authormRnea <akannemre@gmail.com>2024-07-18 13:50:14 +0300
committermRnea <akannemre@gmail.com>2024-07-18 13:50:14 +0300
commita0fb419b1be8ed53f580c509b7a55cde8e06d4c9 (patch)
tree36ee859bce5235621e6f7656bb41a269dbe90736 /main.lisp
başlangıç, push pop + - . vb.
Diffstat (limited to 'main.lisp')
-rw-r--r--main.lisp39
1 files changed, 39 insertions, 0 deletions
diff --git a/main.lisp b/main.lisp
new file mode 100644
index 0000000..716c76b
--- /dev/null
+++ b/main.lisp
@@ -0,0 +1,39 @@
+(in-package :cl-forth)
+
+(defun main ()
+ (let ((args (rest sb-ext:*posix-argv*)))
+ (let ((flag (first args)))
+ (cond ((string= flag "-c")
+ ;; (iter (for (k v) in-hashtable *operations*)
+ ;; (for i from 0)
+ ;; (format t "~s: ~s~%" i k))
+ ;; (let ((tokens (lex-file (second args))))
+ ;; (format t "~s~%" tokens)
+ ;; (let ((program (prog-from-tokens tokens)))
+ ;; (format t "~s~%" program)
+ ;; (generate-program program :compile t)))
+ (compile-program (second args)))
+ ((string= flag "-i")
+ (format t "Interpret program WIP~%"))
+ (t (format t "~a is not a valid flag~%" flag))))))
+
+;; (defun make-exe ()
+;; (sb-ext:save-lisp-and-die #P"cl-forth"
+;; :toplevel #'main
+;; :executable t))
+
+(defparameter *example-path* "./test/prog.lorth")
+
+(defun example-lex ()
+ (lex-file *example-path* t))
+
+(defun example-prog ()
+ (make-program *example-path*))
+
+(defun example-compile ()
+ (generate-program (make-program *example-path*) :path "test/output.asm"
+ :compile t))
+
+(defun example-run ()
+ (example-compile)
+ (run '("test/output")))