summaryrefslogtreecommitdiff
path: root/load.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2024-06-10 20:35:00 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2024-06-10 20:35:00 -0300
commit8351935b3764169b83159ec0984ad231dc6b4e7a (patch)
tree01d9041e06961682ef7ed2dd7d114994ec831d4e /load.lisp
parentc857477e0585b14a8ecba3d57d45e961449c2a90 (diff)
downloadjson-main.tar.gz
json-main.zip
Use coerce and repeatHEADmain
Diffstat (limited to 'load.lisp')
-rw-r--r--load.lisp30
1 files changed, 8 insertions, 22 deletions
diff --git a/load.lisp b/load.lisp
index 4acfede..2377efc 100644
--- a/load.lisp
+++ b/load.lisp
@@ -18,39 +18,25 @@
(crit signed-digits)
nothing)))
(read-from-string
- (str:from-list
- (remove nil (append base (cons dot fraction) (cons (when e #\d) exponent))))))))
+ (coerce
+ (remove nil (append base (cons dot fraction) (cons (when e #\d) exponent)))
+ 'string)))))
(defparameter string-literal
(comp ((_ (unit #\"))
(chars (optional (many (one-of (comp ((slash (unit #\\))
(escaped (unit))
(codepoints (if (char= escaped #\u)
- (comp ((cp0 (unit digit-char-p))
- (cp1 (unit digit-char-p))
- (cp2 (unit digit-char-p))
- (cp3 (unit digit-char-p)))
- (let ((str (make-string 7)))
- (setf (char str 0) #\#)
- (setf (char str 1) #\\)
- (setf (char str 2) #\u)
- (setf (char str 3) cp0)
- (setf (char str 4) cp1)
- (setf (char str 5) cp2)
- (setf (char str 6) cp3)
- str))
+ (repeat (unit digit-char-p) 4)
nothing)))
(case escaped
- (#\n
- #\Newline)
- (#\t
- #\Tab)
- (#\u
- (read-from-string codepoints))
+ (#\n #\Newline)
+ (#\t #\Tab)
+ (#\u (read-from-string (coerce (append '(#\# #\\ #\u) codepoints) 'string)))
(t escaped)))
(unit (and (char/= it #\") (char/= it #\\)))))))
(_ (crit (unit #\"))))
- (str:from-list chars)))
+ (coerce chars 'string)))
(defparameter true-symbol
(comp ((_ (unit #\t))