diff options
author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-06-10 20:35:00 -0300 |
---|---|---|
committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2024-06-10 20:35:00 -0300 |
commit | 8351935b3764169b83159ec0984ad231dc6b4e7a (patch) | |
tree | 01d9041e06961682ef7ed2dd7d114994ec831d4e | |
parent | c857477e0585b14a8ecba3d57d45e961449c2a90 (diff) | |
download | json-main.tar.gz json-main.zip |
-rw-r--r-- | load.lisp | 30 |
1 files changed, 8 insertions, 22 deletions
@@ -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)) |