Robust parsing of map literals.

This commit is contained in:
Kyle 2015-04-06 10:09:11 -07:00
parent 55aeec08d3
commit e14ffc164f
1 changed files with 10 additions and 11 deletions

View File

@ -23,10 +23,10 @@
(reverse (concatenate 'string x))) (reverse (concatenate 'string x)))
(finalise-kv-pair () (finalise-kv-pair ()
(if key-p (if key-p
(progn (unless (null k)
(setq key-p nil (setq key-p nil
k (read-from-string (finalise-read k)))) k (read-from-string (finalise-read k))))
(progn (unless (null v)
(setq key-p t (setq key-p t
v (read-from-string (finalise-read v))) v (read-from-string (finalise-read v)))
(setf (gethash k m) v) (setf (gethash k m) v)
@ -39,8 +39,7 @@
(if key-p (if key-p
(push prev k) (push prev k)
(push prev v)))) (push prev v))))
(if (and (null k) (if (and (null v) (not (null k)))
(null v))
(error "Mismatched key value pairs.") (error "Mismatched key value pairs.")
(progn (progn
(finalise-kv-pair) (finalise-kv-pair)