minor modification to simülation
This commit is contained in:
@@ -22,6 +22,8 @@
|
|||||||
(case (car op)
|
(case (car op)
|
||||||
(:push-int (push* (cadr op)))
|
(:push-int (push* (cadr op)))
|
||||||
(:+ (push* (+ (pop*) (pop*))))
|
(:+ (push* (+ (pop*) (pop*))))
|
||||||
|
(:- (let ((top (pop*)))
|
||||||
|
(push* (- (pop*) top))))
|
||||||
(:dump (format t "~a~%" (pop*)))
|
(:dump (format t "~a~%" (pop*)))
|
||||||
(:= (push* (if (= (pop*) (pop*)) 1 0)))
|
(:= (push* (if (= (pop*) (pop*)) 1 0)))
|
||||||
(:eş (let ((top (pop*)))
|
(:eş (let ((top (pop*)))
|
||||||
@@ -36,6 +38,7 @@
|
|||||||
(push* (if (< (pop*) top) 1 0))))
|
(push* (if (< (pop*) top) 1 0))))
|
||||||
(:iken (when (= 0 (pop*))
|
(:iken (when (= 0 (pop*))
|
||||||
(setf i (cadr op))))
|
(setf i (cadr op))))
|
||||||
|
(:döngü nil)
|
||||||
(:bel (push* 0))
|
(:bel (push* 0))
|
||||||
(:oku (push* (aref *bel* (pop*))))
|
(:oku (push* (aref *bel* (pop*))))
|
||||||
(:yaz (let ((top (pop*)))
|
(:yaz (let ((top (pop*)))
|
||||||
@@ -75,7 +78,9 @@
|
|||||||
(top2 (pop*)))
|
(top2 (pop*)))
|
||||||
(push* top2)
|
(push* top2)
|
||||||
(push* top1)
|
(push* top1)
|
||||||
(push* top2)))))))
|
(push* top2)))
|
||||||
|
(otherwise (format t "Unknown keyword: ~a~%" (car op))
|
||||||
|
(finish))))))
|
||||||
|
|
||||||
(defun str->prog (str)
|
(defun str->prog (str)
|
||||||
(parse-tokens (lex-string str)))
|
(parse-tokens (lex-string str)))
|
||||||
|
|||||||
Reference in New Issue
Block a user