From 68947d00aa6666d6e4daed6a0f75009c9bf3048d Mon Sep 17 00:00:00 2001 From: mRnea Date: Fri, 16 Aug 2024 00:16:26 +0300 Subject: added file inclusion and optional macro documentation list --- cl-forth.lisp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'cl-forth.lisp') diff --git a/cl-forth.lisp b/cl-forth.lisp index bad08ef..410b112 100644 --- a/cl-forth.lisp +++ b/cl-forth.lisp @@ -3,7 +3,8 @@ (defun make-token (sym? line col &optional (type nil)) (when (null type) (setf type - (cond ((numberp sym?) :number) + (cond ((consp sym? ) :list) + ((numberp sym?) :number) ((stringp sym?) :string) ((is-identifier sym?) :identifier) (t :unknown)))) @@ -183,7 +184,12 @@ (defmethod parse-op ((parser parser) token (type (eql :makro))) ;; makro name must be undefined before (let ((makro-name-tok (read-token parser))) - (assert (eq :unknown (getf (cdr makro-name-tok) :type))) + (assert (eq :unknown (getf (cdr makro-name-tok) :type))) + (let ((doc? (peek-token parser))) + (when (eq :list (getf (cdr doc?) :type)) + (read-token parser) + ;; setf doc? + )) (setf (gethash (car makro-name-tok) *makro-defs*) (do ((tok (read-token parser) (read-token parser)) @@ -197,6 +203,10 @@ (add-op (list :syscall syscall-num) parser))) (t (add-op (list type) parser)))) +(defmethod parse-op ((parser parser) token (type (eql :kütüphane))) + (let ((file (car (read-token parser)))) + (setf (tokens parser) (append (lex-file file) (tokens parser))))) + (defun parse-tokens (tokens) (let ((parser (make-parser tokens))) (iter (while (not (null (tokens parser)))) -- cgit v1.2.3