From 6f70c5585f600d178c1bef4bd63bbe1d527ac44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Sat, 12 Nov 2022 03:16:55 -0300 Subject: Better error reporting for numbers If sign has been parsed, there must be a natural after it. --- json.lisp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'json.lisp') 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 #\.))) -- cgit v1.2.3