Coverage report: /home/ellis/comp/core/lib/dat/sxp.lisp
Kind | Covered | All | % |
expression | 12 | 82 | 14.6 |
branch | 1 | 4 | 25.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; lib/dat/sxp.lisp --- S-eXPressions
3
;; A portable S-Expression data format
11
(defgeneric sxpp (self form))
14
(defmethod write-ast ((self ast:ast) stream &key (pretty *print-pretty*) (case :downcase))
20
(defmethod read-ast ((self ast:ast) stream &key)
21
(setf (ast:ast self) (slurp-stream-forms stream :count nil)))
23
(defmethod read-ast ((self null) stream &key)
24
(slurp-stream-forms stream :count nil))
26
;; (defsetf unwrap ) (defsetf wrap )
29
(defun read-sxp-file (file)
30
(make-instance 'ast:ast :ast (read-file-forms file)))
32
(defun write-sxp-file (sxp file &optional &key if-exists)
33
(with-output-file (out file) :if-exists if-exists
36
(defun read-sxp-string (self str) (with-input-from-string (s str) (read-ast self s)))
38
(defun write-sxp-string (sxp)
39
(let ((ast (ast:ast sxp)))
41
(if (> (length ast) 1)
43
(write-to-string (car ast)))))
45
(defun make-sxp (&rest form) (make-instance 'ast:ast :ast form))
47
(deftype sxp-fmt-designator () '(member :canonical :collapsed :pretty))
49
(defun file-read-forms (file)
50
(declare (sb-kernel:pathname-designator file))
51
(awhen (the list (read-file-forms file))
57
(defmethod serialize (self (format (eql :sxp)) &key stream)
59
(ast (write-ast self stream))
60
(t (write self :stream stream))))
62
(defmethod deserialize ((from string) (format (eql :sxp)) &key)
63
(with-input-from-string (s from)
66
(defmethod deserialize ((from stream) (format (eql :sxp)) &key)
69
(defmethod deserialize ((from pathname) (format (eql :sxp)) &key)