summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormRnea <[email protected]>2024-07-29 23:56:06 +0300
committermRnea <[email protected]>2024-07-29 23:56:06 +0300
commit4091b0e81f30e4aba04f81fd0c6ae661f0b72603 (patch)
treec6515881bcdb117627a65ea481841fa2144c33a4
parent004c2b5628ba2db3297829a76a1e3983c62926ab (diff)
further fixes, probably need to change representation of tokens
-rw-r--r--cl-forth.lisp20
1 files changed, 10 insertions, 10 deletions
diff --git a/cl-forth.lisp b/cl-forth.lisp
index 5291ceb..4c5eaaf 100644
--- a/cl-forth.lisp
+++ b/cl-forth.lisp
@@ -48,7 +48,7 @@
(defun lex-file (file-name &optional report-errors)
(let ((has-error nil))
(values
- (with-open-file (str file-name)
+ (with-open-file (str file-name :external-format :utf-8)
(iter outer
(for line = (read-line str nil nil))
(until (null line))
@@ -99,30 +99,30 @@
(let ((op (token-op token)))
(cond ((numberp op)
(vector-push-extend `(push ,op) ops))
- ((eq 'ise op)
+ ((string= 'ise op)
(push (list 'ise i) stack)
(vector-push-extend (list 'ise nil) ops))
- ((eq 'yoksa op)
+ ((string= 'yoksa op)
(let ((top (pop stack)))
- (assert (eq 'ise (car top)))
+ (assert (string= 'ise (car top)))
(setf (second (aref ops (cadr top))) i)
(push (list 'yoksa i) stack)
(vector-push-extend (list 'yoksa nil i) ops)))
- ((eq 'yap op)
+ ((string= 'yap op)
(let ((top (pop stack)))
(cond ((find (car top) (list 'yoksa 'ise))
(setf (second (aref ops (cadr top))) i)
(vector-push-extend (list 'yap i) ops))
- ((eq 'iken (car top))
+ ((string= 'iken (car top))
(setf (second (aref ops (cadr top))) i)
(vector-push-extend (list 'yap i (third top)) ops))
(t (error "yap cannot reference: ~a" (car top))))))
- ((eq 'döngü op)
+ ((string= 'döngü op)
(push (list 'döngü i) stack)
(vector-push-extend (list 'döngü i) ops))
- ((eq 'iken op)
+ ((string= 'iken op)
(let ((top (pop stack)))
- (assert (eq 'döngü (car top)))
+ (assert (string= 'döngü (car top)))
(push (list 'iken i (cadr top)) stack)
(vector-push-extend (list 'iken nil) ops)))
((search "syscall" (string-downcase (string op)))
@@ -219,7 +219,7 @@
;;; COMPILER
-(defun write-program (program out &key mem-cap)
+(defun write-program (program out &key (mem-cap 640000))
(format out "~a~%" "segment .text")
(gen-dump out)
(format out "~{~a~%~}" '("global _start"