;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.excosy) ;;;;;; ;;; Nothing (def class* nothing/ast (ast) ()) (def function read-nothing (machine ast input) (make-instance 'nothing)) (def function print-nothing (machine ast output) (values)) (def function interpret-nothing (machine ast) (values)) ;;;;;; ;;; Boolean ;; TODO: kill? (def class* boolean/ast (ast) ((reader-function 'read-boolean) (printer-function 'print-boolean) (interpreter-function 'interpret-abstraction) (memory-location-allocator-function 'allocate-boolean-memory-location) (value :type boolean))) (def function read-boolean (machine ast input) ;; TODO: nil) (def function print-boolean (machine ast output) (if (value-p ast) (format output "true") (format output "false"))) (def function allocate-boolean-memory-location (machine ast) (declare (ignore machine)) (logior (ash (if (value-p ast) 0 1) 2) #b01)) ;;;;;; ;;; Integer (def class* integer/ast (ast) ((reader-function 'read-integer) (printer-function 'print-integer) (interpreter-function 'interpret-abstraction) (memory-location-allocator-function 'allocate-integer-memory-location) (value :type integer))) (def function read-integer (machine ast input) (make-instance 'integer :value (parse-integer input))) (def function print-integer (machine ast output) (format output "~A" (value-of ast))) (def function allocate-integer-memory-location (machine ast) (declare (ignore machine)) (logior (ash (value-of ast) 2) #b00))