summaryrefslogtreecommitdiff
path: root/src/parse.lisp
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-07 23:58:29 -0400
committerbd <bdunahu@operationnull.com>2025-04-07 23:58:29 -0400
commit0fe2cc70abacc7c9e7aa2602836c8226bb1a1dc3 (patch)
tree6d0b35edad95195221e55c976d944d19c46e6a58 /src/parse.lisp
parent1ba3929b633b35a2131960b5344359478594626a (diff)
Add label processing, mnemonic and label lookup maps
Diffstat (limited to 'src/parse.lisp')
-rw-r--r--src/parse.lisp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/parse.lisp b/src/parse.lisp
new file mode 100644
index 0000000..8bd8c50
--- /dev/null
+++ b/src/parse.lisp
@@ -0,0 +1,21 @@
+(in-package #:parse)
+
+(defun tokens->ast (program)
+ (let ((program (remove nil (mapcar #'extract-label program))))
+ ;; TODO
+ program))
+
+(let ((i 0))
+ (defun extract-label (line)
+ "Given a series of tokens LINE, determines if LINE is
+in the form STRING {colon}. If it is, then it is treated as a
+label, and pushed onto the stack with the line index.
+
+Note that this function is intended to be called using mapcar,
+so that labels can be added to a map and otherwise removed from
+processing."
+ (trivia:match line
+ ((list (and id (type string))
+ (satisfies (lambda (x) (equal x 'lex::colon))))
+ (progn (push (cons (read-from-string id) i) util:label-loc) nil))
+ (_ (progn (incf i) line)))))