;;; -*- 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) reference-dispatching () ((default-projection :type projection) (reference-projection-pairs :type list))) ;;;;;; ;;; Construction (def (function e) make-projection/reference-dispatching (default-projection reference-projection-pairs) (make-projection 'reference-dispatching :default-projection default-projection :reference-projection-pairs reference-projection-pairs)) ;;;;;; ;;; Construction (def (macro e) reference-dispatching (&body forms) `(make-projection/reference-dispatching ,(first forms) (list ,@(iter (for (reference projection) :in (rest forms)) (collect `(list ',reference ,projection)))))) ;;;;;; ;;; Printer (def printer reference-dispatching (projection recursion input input-reference output-reference) (declare (ignore recursion)) (iter (with reference-projection-pairs = (reference-projection-pairs-of projection)) (for (reference projection) :in-sequence reference-projection-pairs) (when (equal reference input-reference) (return (funcall projection projection input input-reference output-reference))) (finally (return (funcall (default-projection-of projection) projection input input-reference output-reference))))) ;;;;;; ;;; Reader (def reader reference-dispatching (projection recursion input input-reference output-reference) (declare (ignore projection recursion input input-reference output-reference)) nil)