(in-package :fomus-test) (defmethod backend-output-path ((backend (eql :raw)) filename) (merge-pathnames (make-pathname :type "fmr") filename)) (defmethod backend-output-path ((backend (eql :data)) filename) (merge-pathnames (make-pathname :type "fms") filename)) (defmethod backend-output-path ((backend (eql :lilypond)) filename) (merge-pathnames (make-pathname :type "ly") filename)) (defmethod backend-output-path ((backend (eql :musicxml)) filename) (merge-pathnames (make-pathname :type "xml") filename)) (defmethod backend-output-path ((backend (eql :cmn)) filename) (merge-pathnames (make-pathname :type "cmn") filename)) (defun hash-to-stream (hash stream) (flet ((function-name (f) (if (symbolp f) f (multiple-value-bind (x y name) (function-lambda-expression f) (declare (ignore x y)) (when (null name) (error "Cant determine name of '~S'." f)) name)))) (iter (for (key . value) in ;; we want to have the same order ;; across lisp implemenations (sort (iter (initially (print (function-name (hash-table-test hash)) stream)) (for (key value) in-hashtable hash) (collect (cons key value))) #'string< :key #'(lambda (cons) (concatenate 'string (string (caar cons)) (string (cdar cons)))))) (print key stream) (print value stream)))) (defun hash-from-stream (stream) (iter (with hash = (make-hash-table :test (symbol-function (read stream)))) (for key in-stream stream) (for form = (read stream)) (setf (gethash key hash) form) (finally (return hash))))