From 8368e32e98bc82e5220b0e534c04b4edba2bc9a4 Mon Sep 17 00:00:00 2001 From: aleksei Date: Thu, 11 Apr 2024 20:44:12 +1000 Subject: Initial commit --- main.lisp | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 main.lisp (limited to 'main.lisp') diff --git a/main.lisp b/main.lisp new file mode 100644 index 0000000..e4dd9c4 --- /dev/null +++ b/main.lisp @@ -0,0 +1,82 @@ +;; -*- mode: common-lisp -*- + +(setf + *source-file* + (open "/home/aleksei/lisp/wozmon.s")) + +(setf + *source-line-number* + 0) + +(defun interpret-character (s x) + "Interpret meanings of characters." + (cond + ((>= x (length s)) + 'end-of-line) + (t + ;; Have character, interpret + (let ((c (char s x))) + (cond + ((eq c #\;) ; Comment + 'comment) + ((eq c #\ ) ; Space + 'whitespace) + (t + 'normal)))))) + +(defun extract-word (line-string index) + "Extract a single word from line-string, starting at index." + (cond + ((member (interpret-character line-string index) + `(end-of-line comment)) + 'end-of-line) + ((equal (interpret-character line-string index) + 'whitespace) + 'whitespace) + (t + (subseq + line-string + index + (do ((end index (incf end))) + ((not (equal 'normal + (interpret-character line-string end))) + end)))))) + +(defun extract-words (line-string &optional (index 0)) + "Return a list the constituent word strings of line-string." + ;; Word Processing Logic + (let ((word (extract-word line-string index))) + (cond + ;; Terminate execution at end-of-line. + ((equal word 'end-of-line) + nil) + ;; If empty, continue on. + ((equal word 'whitespace) + (extract-words line-string (+ index 1))) + ;; Otherwise, extract word and move ahead. + (t + (cons word + (extract-words line-string + (+ index + (length word)))))))) + + + + +(defun last-char (s) + (char s (- (length s) 1))) + +(defun label? (s) + (eq (last-char s) #\:)) + + +(setf + *grammar* + (('label + (lambda (l) + )))) + +(defun read_code () + (incf *source-line-number*) + () + ) -- cgit v1.2.3