Add various transformation rules
This commit is contained in:
parent
ebe27cf026
commit
38406c80ee
4 changed files with 27 additions and 1 deletions
7
wip-duuqnd/user-side-compiler/asm-function.lisp
Normal file
7
wip-duuqnd/user-side-compiler/asm-function.lisp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
(in-package #:user-side-compiler)
|
||||||
|
|
||||||
|
;;; STUB, TODO
|
||||||
|
|
||||||
|
(define-transformation (token (token-name asm-function))
|
||||||
|
;; TODO: Create table of asm functions that this can draw from
|
||||||
|
nil)
|
|
@ -31,3 +31,6 @@
|
||||||
(write-string " " stream))
|
(write-string " " stream))
|
||||||
(when (slot-boundp object '%index)
|
(when (slot-boundp object '%index)
|
||||||
(format stream "@~A" (ref-index object)))))
|
(format stream "@~A" (ref-index object)))))
|
||||||
|
|
||||||
|
(define-transformation (ref (reference-constant reference)) ref)
|
||||||
|
(define-transformation (ref (reference-variable reference)) ref)
|
||||||
|
|
|
@ -31,9 +31,24 @@ reading immediately. Should be a subset of *SPECIAL-TOKEN-CHARS*.")
|
||||||
(when (slot-boundp object '%name)
|
(when (slot-boundp object '%name)
|
||||||
(format stream "\"~A\"" (name object)))))
|
(format stream "\"~A\"" (name object)))))
|
||||||
|
|
||||||
|
(define-transformation (token (token-name reference-variable))
|
||||||
|
(multiple-value-bind (value existsp)
|
||||||
|
(find-reference-by-symbol (name token))
|
||||||
|
(if existsp
|
||||||
|
value
|
||||||
|
(add-reference-symbol (name token)
|
||||||
|
(make-instance 'reference-variable
|
||||||
|
:name (name token))))))
|
||||||
|
|
||||||
(defclass token-number (token)
|
(defclass token-number (token)
|
||||||
((%value :accessor value :initarg :value)))
|
((%value :accessor value :initarg :value)))
|
||||||
|
|
||||||
|
(define-transformation (token (token-number reference-constant))
|
||||||
|
(make-instance 'reference-constant :value (value token)))
|
||||||
|
|
||||||
|
(define-transformation (token (token-number integer))
|
||||||
|
(value token))
|
||||||
|
|
||||||
(defclass token-comment (token)
|
(defclass token-comment (token)
|
||||||
((%text :accessor text :initarg :text)))
|
((%text :accessor text :initarg :text)))
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
:serial t
|
:serial t
|
||||||
:components
|
:components
|
||||||
((:file "package")
|
((:file "package")
|
||||||
|
(:file "transform")
|
||||||
(:file "reference")
|
(:file "reference")
|
||||||
(:file "symbol-table")
|
(:file "symbol-table")
|
||||||
(:file "transform")
|
(:file "asm-function")
|
||||||
(:file "tokenizer")
|
(:file "tokenizer")
|
||||||
(:file "label")
|
(:file "label")
|
||||||
(:file "high-level")
|
(:file "high-level")
|
||||||
|
|
Loading…
Add table
Reference in a new issue