diff options
author | aleksei <aleksei@aj.org> | 2024-04-14 11:51:02 +1000 |
---|---|---|
committer | aleksei <aleksei@aj.org> | 2024-04-14 11:51:02 +1000 |
commit | 45045f2484f2eb88da587f98ec5c7fdeff672c94 (patch) | |
tree | 32422c19e332e6fe072cccb7b8039bb3e0c7a520 | |
parent | 3b2b63913b1a550c8469acd3943abafbf22ccd13 (diff) |
Finally got macro-pass working
-rw-r--r-- | main.lisp | 58 |
1 files changed, 38 insertions, 20 deletions
@@ -22,29 +22,47 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA To solve the problem of the colliding syntax rules We can test only the addressin modes we know the opcode to have This not only solves this problem, it just makes more sense. -|# +Need to use the existing lists to find keywords to watch out for during compilation. +ESPECIALLY run through the output of macro-list to find collisions +This owuld make it simple +|# (setf *the-program* (program "~/clasm-6502/wozmon.s")) -(defun macro-list (program-list) - "Create an associative list of program-list macros." - (let ((return-alist nil)) +(defun macro-pass (program-list) + "Translate a programs macros" + (let ((macro-association-list + (let ((return-alist nil)) + (dolist (i program-list) + (if (equal (syntax-rule (cadr i) *grammar*) 'macro) + (setf return-alist + (cons (list (first (cadr i)) (car (last (cadr i)))) + return-alist)) + nil)) + return-alist)) + (return-list nil)) + ;; For every line in program list.. (dolist (i program-list) - (if (equal (syntax-rule (cadr i) *grammar*) 'macro) - (setf return-alist - (cons (list (first (cadr i)) (car (last (cadr i)))) - return-alist)) - nil)) - return-alist)) - -*the-program* - -(macro-list *the-program*) - - -(last (cadr '(100 ("Hey" "There")))) - - -(defun pass-attributes (program-list)) + ;; ..excluding the macro lines.. + (if (eq (syntax-rule (cadr i) *grammar*) 'macro) + nil + ;; ..add to return list this value: + (setf return-list + (cons + ;; For every word in the line, + (let ((append-list nil)) + (dolist (j (cadr i)) + (setf append-list + ;; add it to the output line, and change whatever is a macro. + (cons (if (assoc j macro-association-list :test #'string=) + (cadr (assoc j macro-association-list :test #'string=)) + j) + append-list))) + ;; Return the line number and program. + (cons (car i) + (list (reverse append-list)))) + return-list)))) + ;; Return everything. + (reverse return-list))) |