;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.projectional-editor) ;;;;;; ;;; Projection (def (projection e) sequential () ((elements :type list))) ;;;;;; ;;; Construction (def (function e) make-projection/sequential (projections) (make-projection 'sequential :elements projections)) ;;;;;; ;;; Construction (def (macro e) sequential (&body forms) `(make-projection/sequential (list ,@forms))) ;;;;;; ;;; Printer (def printer sequential (projection recursion input input-reference output-reference) (iter (for output :initially input :then (output-of iomap)) (for index :from 0) (for element :in (elements-of projection)) ;; TODO: how do we handle input output references here? what is forward here? (for element-input-reference :initially input-reference :then `(forward ,element-input-reference)) (for element-output-reference = `(forward ,element-input-reference)) ;; TODO: KLUDGE: properly recurse with iomap (for iomap = (bind ((*iomap* (if *iomap* (make-iomap/recursive input output (list *iomap* (make-iomap/sequential input output element-iomaps))) (make-iomap/sequential input output element-iomaps)))) (funcall (printer-of element) element recursion output element-input-reference (if (= index (1- (length (elements-of projection)))) output-reference element-output-reference)))) (collect iomap :into element-iomaps) (finally (return (make-iomap/sequential input output element-iomaps))))) ;;;;;; ;;; Reader (def reader sequential (projection recursion input input-reference output-reference) ;; KLUDGE: (iter (for output :initially input :then (or xxx input)) (for index :from 0) (for element :in (reverse (elements-of projection))) (for xxx = (funcall (reader-of element) element recursion output input-reference output-reference)) (finally (return xxx))))