added file inclusion and optional macro documentation list

This commit is contained in:
2024-08-16 00:16:26 +03:00
parent 6eb5ad5b42
commit 68947d00aa
2 changed files with 13 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
(in-package :cl-forth)
(defparameter *psuedo-identifiers*
'(syscall-1 syscall-2 syscall-3 syscall-4 syscall-5 syscall-6 makro son)
'(syscall-1 syscall-2 syscall-3 syscall-4 syscall-5 syscall-6 makro son kütüphane)
"These do not map to operations that generate code directly, but are valid to lexer and parser")
(defparameter *identifiers* ())

View File

@@ -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))))
@@ -184,6 +185,11 @@
;; makro name must be undefined before
(let ((makro-name-tok (read-token parser)))
(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))))