(defun opentag (space key) (format nil "~a<~a>~%" space key)) (defun closetag (space key) (let ((key (string key))) ;; only print up to the first space (format nil "~a~%" space (subseq key 0 (position #\Space key))))) (defun str (space str) (format nil "~a~a~%" space str)) (defun indent (space) "increase an indention level" (format nil " ~a" space)) (defun strconcat (l) "concatenate a list of strings, return the new string" (reduce #'(lambda (a b) (concatenate 'string a b)) l)) (defun parse (l s) (strconcat (list (opentag s (car l)) (strconcat (mapcar #'(lambda (i) (if (stringp i) (str s i) (parse i (indent s)))) (cdr l))) (closetag s (car l))))) (with-open-file (f "in.lsp") (princ (parse (read f) "")))