;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.projectional-editor) ;;;;;; ;;; Reference to text projection (def class* projection/reference-to-text (projection) ()) ;;;;;; ;;; Reference to text projection constructors (def (function e) make-projection/reference-to-text () (make-instance 'projection/reference-to-text)) ;;;;;; ;;; Reference to text printer (def method project-document (reference-document (projection projection/reference-to-text)) (labels ((recurse (input) (pattern-case input ((sequence-position (the ?a ?b) ?c) (format nil "~A~%The ~Ath position of that ~A is a character position." (recurse `(the ,?a ,?b)) ?c ?a)) ((the ?a (content-of (the document document))) (format nil "The content of the document is a ~A." ?a)) ((the ?a (elt (the list ?b) ?c)) (format nil "~A~%The ~Ath member of that LIST is a ~A." (recurse `(the list ,?b)) ?c ?a)) ((the ?a (?b (?if (ends-with-subseq "-of" (string-downcase ?b))) (the ?c ?d))) (bind ((b (string-downcase ?b))) (format nil "~A~%The ~A of that ~A is a ~A." (recurse `(the ,?c ,?d)) (subseq b 0 (- (length b) 3)) ?c ?a))) ((the ?a (slot-value (the ?b ?c) ?d)) (format nil "~A~%The ~A of that ~A is a ~A." (recurse `(the ,?b ,?c)) (string-downcase (second ?d)) ?b ?a)) (?a (write-to-string ?a))))) (make-document (recurse (content-of reference-document)) :source (make-source reference-document projection (make-mapping)))))