anchor.diff:      (read stream)))
   
   
  +
  +;;Parser
  +;;parses into a list, PERFECT!
  +(defun get-file (filename)
  +  (with-open-file (stream filename)
  +    (read stream)))
  +
  +
   (unless (= 2 (length *args*))
     (error "Incorrect arguments given. Should be of form: %prog input-file output-file"))
   (defparameter *code* (get-file (first *args*)))
  -
  -
  -(evaluate *code* '())
  +(format t "~a" *code*)
  +
  +
  +(defparameter *output* (concatenate 'string
  +				    (format nil ".data~%")
  +				    (format nil "~a" *data*)
  +				    (format nil ".text~%.globl main~%main:~%")
  +				    (format nil "~a" *text*)))
  +
  +(evaluate *code*)
   (let ((stream (open (second *args*) :direction :output)))
  -  (format stream "~a" *output*)
  -  (format t "~a" *output*)
  +  (format stream ".data~%")
  +  (format stream "~a" *data*)
  +  (format stream ".text~%.globl main~%main:~%")
  +  (format stream "~a" *text*)
  +  (format t ".data~%")
  +  (format t "~(~a~)" *data*)
  +  (format t ".text~%.globl main~%main:~%")
  +  (format t "~(~a~)" *text*)
  +  
     (close stream))
  +
  +
  +
  
positive.code:       (push  (make-register :name (symbol-name (car part)))
  	     *register-list*)))
  (setf *register-list* (reverse *register-list*))
  ;(format t "~%All registers loaded~%")
  
  (defun get-trap-code (function)
    (let ((trap-code 0)
  	(syscall (list 'print_int 
  			 'print_float
  			 'print_double 
  			 'print_string 
  			 'read_int 
  			 'read_float 
  			 'read_double 
  			 'read_string 
  			 'sbrk 
  			 'exit 
  			 'print_char 
  			 'read_char
  			 'file_open
  			 'file_read 
  			 'file_write 
  			 'file_close )))
      (dolist (sys syscall trap-code)
        (incf trap-code)
        (when (equal function sys)
  
negative.code: ;;Can be rewritten using find
  
  (defun find-empty-t-register ()
    "find an empty register of type t"
    (dolist (reg *register-list*)
      (when (and (equal (register-type reg) '$t)
  	       (register-free? reg))
        (return reg))))
  
  (defun temp-register-allot (constant)
    "Temporarily allot a t register"
    (let ((a  (find-empty-t-register)))
      (with-output-to-string (stream *text*)
        (format stream "li ~a , ~a ~%" a constant))
      (setf (register-value a) constant
  	  (register-temp? a) t
  	  (register-free? a) nil)
      a))
  
  
  
  (defun var-register-allot (constant)
    "Allot a t register to a variable"
    (let ((a  (find-empty-t-register)))
      (with-output-to-string (stream *text*)
        (format stream "li ~a , ~a ~%" a constant))
      (setf (register-value a) constant
  	  (register-temp? a) nil
  	  (register-free? a) nil)
      a))
  
  
  ;;Convert into a macro for freeing register
  
  (defun free-temp-register (params)
    "Takes a list of registers and frees those which are temporary"
    (dolist (param params)
      (when (and param (register-temp? param))
        (setf (register-free? param) t))))
  
  
  (defun free-register-list (params)
    "Takes a list of registers and frees those which are temporary"
    (dolist (param params)
      (setf (register-free? param) t)))
  
  (defparameter *env* '())
  
  
  
  (defun make-frame (var-val-list)
    "var-val list is ((var value) (var value)). Value defaults to 0"
    (let ((frame '()))
      (dolist (var-val var-val-list)
        (if (listp var-val)
  	  (setf frame (acons (first var-val) (var-register-allot (second var-val))  frame))
  	  (setf frame (acons (first var-val) (var-register-allot 0)  frame ))))
      (format t "Frame to be added ~a ~%" frame)
      frame))
  
  (defun add-frame (var-val-list)
    (format t "Adding frame with vars ~a ~%" var-val-list)
    (push (make-frame var-val-list) *env*))
  
  (defun pop-frame ()
    (let ((register-list '()))
      (dolist ( var (first *env*))
        (push (cdr var) register-list))
      (free-register-list register-list)))
  
  (defparameter *procedures* (make-hash-table))
  
  
  
  
  
  
  (defmacro defprocedure (func &body body)
    "make primitive procedures"
    `(setf (gethash ,func *procedures*) (lambda (params)
  					(let ((output ( find-empty-t-register)))
  					  (with-output-to-string (s *text*)
  					    ,@body)
  					  (free-temp-register params)
  					  output)))
    )
  
  (defprocedure '+
  