summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-12-25 23:50:37 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-12-25 23:50:37 -0300
commitd7d3e70886554cb8350ea444adf384ca078673fb (patch)
treece1340d4dbbce302b3587845227b43d386cc8edb
parent7dc8f899bfb9c7d44fcfde6bb314e6f550222533 (diff)
downloadjson-d7d3e70886554cb8350ea444adf384ca078673fb.tar.gz
json-d7d3e70886554cb8350ea444adf384ca078673fb.zip
Adapt to latest version of monparser
-rw-r--r--json.lisp32
1 files changed, 14 insertions, 18 deletions
diff --git a/json.lisp b/json.lisp
index 17e111a..80fef99 100644
--- a/json.lisp
+++ b/json.lisp
@@ -2,22 +2,22 @@
(defparameter number-literal
(let ((signed-digits
- (comp ((sign (optional (either (unit #\-)
+ (comp ((sign (optional (one-of (unit #\-)
(unit #\+))))
(natural (if sign
- (either (many (unit-if #'digit-char-p))
+ (one-of (many (unit-if #'digit-char-p))
(fail "Malformed number."))
(many (unit-if #'digit-char-p)))))
(cons sign natural))))
(comp ((base signed-digits)
(dot (optional (unit #\.)))
(fraction (if dot
- (either (many (unit-if #'digit-char-p))
+ (one-of (many (unit-if #'digit-char-p))
(fail "Malformed fractional part."))
nothing))
- (e (optional (either (unit #\e) (unit #\E))))
+ (e (optional (one-of (unit #\e) (unit #\E))))
(exponent (if e
- (either signed-digits
+ (one-of signed-digits
(fail "Malformed exponent part."))
nothing)))
(read-from-string
@@ -26,7 +26,7 @@
(defparameter string-literal
(comp ((_ (unit #\"))
- (chars (optional (many (either (comp ((slash (unit #\\))
+ (chars (optional (many (one-of (comp ((slash (unit #\\))
(escaped (unit-if))
(codepoints (if (char= escaped #\u)
(comp ((cp0 (unit-if #'digit-char-p))
@@ -53,33 +53,29 @@
(t escaped)))
(unit-if (lambda (x) (and (char/= x #\")
(char/= x #\\))))))))
- (_ (either (unit #\")
+ (_ (one-of (unit #\")
(fail "String is not properly closed."))))
(str:from-list chars)))
-(defparameter whitespace
- (comp ((_ (optional (many (either (unit #\Space) (unit #\Newline) (unit #\Tab))))))
- nil))
-
(defparameter true-symbol
(comp ((_ (unit #\t))
- (_ (either (literal "rue")
+ (_ (one-of (literal "rue")
(fail "Expected 'true'."))))
'true))
(defparameter false-symbol
(comp ((_ (unit #\f))
- (_ (either (literal "alse")
+ (_ (one-of (literal "alse")
(fail "Expected 'false'."))))
'false))
(defparameter null-symbol
(comp ((_ (unit #\n))
- (_ (either (literal "ull")
+ (_ (one-of (literal "ull")
(fail "Expected 'null'."))))
'null))
-(defvar json-value)
+(defvar json-value nil)
(defparameter json-array
(comp ((_ (unit #\[))
@@ -90,10 +86,10 @@
(defparameter json-object
(let ((json-pair
(comp ((_ whitespace)
- (k (either string-literal
+ (k (one-of string-literal
(fail "Expected a string.")))
(_ whitespace)
- (_ (either (unit #\:)
+ (_ (one-of (unit #\:)
(fail "Expected a \":\"")))
(v json-value))
(cons k v))))
@@ -107,7 +103,7 @@
(setf json-value
(comp ((_ whitespace)
- (v (either number-literal
+ (v (one-of number-literal
string-literal
json-object
json-array