forge/sf: steps towards compiling, + minor improvements
This commit is contained in:
parent
2c9dbfde3e
commit
18bfcd8224
3 changed files with 12 additions and 7 deletions
|
@ -21,7 +21,7 @@
|
||||||
(:method ((it t))
|
(:method ((it t))
|
||||||
(pushd it))
|
(pushd it))
|
||||||
(:method ((it symbol))
|
(:method ((it symbol))
|
||||||
(funcall (func (symbol-value it)))))
|
(call-item (symbol-value it))))
|
||||||
|
|
||||||
(defgeneric comp-item (it))
|
(defgeneric comp-item (it))
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
(defclass word ()
|
(defclass word ()
|
||||||
((func :reader func :initarg :func)))
|
((func :reader func :initarg :func)))
|
||||||
|
|
||||||
(defmethod call-item ((it word))
|
(defmethod call-item ((w word))
|
||||||
(funcall (func it)))
|
(funcall (func w)))
|
||||||
|
|
||||||
(defclass comp-word (word) ())
|
(defclass comp-word (word) ())
|
||||||
|
|
||||||
|
@ -62,12 +62,15 @@
|
||||||
|
|
||||||
(defpackage :sf-builtin
|
(defpackage :sf-builtin
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:f :scopes/forge/sf))
|
(:local-nicknames (:f :scopes/forge/sf)
|
||||||
(:export #:add #:mul #:dup))
|
(:iter :scopes/util/iter))
|
||||||
|
(:export #:add #:mul #:dup #:in #:?))
|
||||||
|
|
||||||
(in-package :sf-builtin)
|
(in-package :sf-builtin)
|
||||||
|
|
||||||
(f:reg2 'add #'+)
|
(f:reg2 'add #'+)
|
||||||
(f:reg2 'mul #'*)
|
(f:reg2 'mul #'*)
|
||||||
|
|
||||||
(f:reg 'dup #'(lambda () (pushd (peekd))))
|
(f:reg 'dup #'(lambda () (f:pushd (f:peekd))))
|
||||||
|
|
||||||
|
(f:reg 'in #'(lambda () (f:pushd (iter:next-value f:*input*))))
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
(forge:exec-list '(4 2 add))
|
(forge:exec-list '(4 2 add))
|
||||||
(util:lgi forge:*stack*)
|
(util:lgi forge:*stack*)
|
||||||
(== (forge:popd) 6)
|
(== (forge:popd) 6)
|
||||||
|
(forge:exec-list '(in name))
|
||||||
|
(util:lgi (forge:popd))
|
||||||
(t:show-result))
|
(t:show-result))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
(defpackage :scopes/util/iter
|
(defpackage :scopes/util/iter
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:export #:next #:value #:process
|
(:export #:next #:value #:next-value #:process
|
||||||
#:list-iterator))
|
#:list-iterator))
|
||||||
|
|
||||||
(in-package :scopes/util/iter)
|
(in-package :scopes/util/iter)
|
||||||
|
|
Loading…
Add table
Reference in a new issue