summaryrefslogtreecommitdiff
path: root/json.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-11-12 03:16:55 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-11-12 03:16:55 -0300
commit6f70c5585f600d178c1bef4bd63bbe1d527ac44a (patch)
tree415ad75b7ea341e4d729505b2c600c603e8f64f7 /json.lisp
parentd1424efebc162c21717c7e7288a1146c802b0636 (diff)
downloadjson-6f70c5585f600d178c1bef4bd63bbe1d527ac44a.tar.gz
json-6f70c5585f600d178c1bef4bd63bbe1d527ac44a.zip
Better error reporting for numbers
If sign has been parsed, there must be a natural after it.
Diffstat (limited to 'json.lisp')
-rw-r--r--json.lisp5
1 files changed, 4 insertions, 1 deletions
diff --git a/json.lisp b/json.lisp
index 6fe95b8..23c9198 100644
--- a/json.lisp
+++ b/json.lisp
@@ -12,7 +12,10 @@
(defparameter number-literal
(let ((signed-digits
(comp ((sign (zero-or-one (some-char #\- #\+)))
- (natural (one-or-more (unit #'digit-char-p))))
+ (natural (if sign
+ (either (one-or-more (unit #'digit-char-p))
+ (fail "Malformed number."))
+ (one-or-more (unit #'digit-char-p)))))
(cons sign natural))))
(comp ((base signed-digits)
(dot (zero-or-one (the-char #\.)))