summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoutade <thegoofist@protonmail.com>2019-05-03 16:00:27 -0500
committerBoutade <thegoofist@protonmail.com>2019-05-03 16:00:27 -0500
commit614f605513f80db554efb3c90cb6c072265bb140 (patch)
tree756ffc8b97fe619c38a5eb0bdaa159e9f0ac3750
parentd6b9ef40b4e98752d7969c421d04a0cb2618ff4d (diff)
added to the example json, cleaned up parzival.lisp
-rw-r--r--examples/foo.json58
-rw-r--r--parzival.lisp19
2 files changed, 43 insertions, 34 deletions
diff --git a/examples/foo.json b/examples/foo.json
index 8a410b6..b140166 100644
--- a/examples/foo.json
+++ b/examples/foo.json
@@ -1,20 +1,42 @@
-{"name" : "Boutade",
- "languages" : [ {"lang" : "Common Lisp",
- "proficiency" : null,
- "lovesIt" : true }
+[
+ {"name" : "Boutade",
+ "languages" : [ {"lang" : "Common Lisp",
+ "proficiency" : null,
+ "lovesIt" : true }
- , {"lang" : "Rust",
- "proficiency" : 0.8,
- "lovesIt" : true,
- "isAshamedToLoveIt" : true}
+ , {"lang" : "Rust",
+ "proficiency" : 0.8,
+ "lovesIt" : true,
+ "isAshamedToLoveIt" : true}
- , {"lang" : "Haskell",
- "proficiency" : 0.5,
- "lovesIt" : "sometimes, in some ways"}
- ],
- "pizzaOrder" : ["Tempeh Italian Sausage", "Spinach", "Mushrooms", "Red Pepper Flakes"],
- "isCool" : false,
- "isFunny" : false,
- "thinksPeopleAreLaughing" : true,
- "beHonest_thinksPeopleAreLaughing" : false
-}
+ , {"lang" : "Haskell",
+ "proficiency" : 0.5,
+ "lovesIt" : "sometimes, in some ways"}
+ ],
+ "pizzaOrder" : ["Tempeh Italian Sausage", "Spinach", "Mushrooms", "Red Pepper Flakes"],
+ "isCool" : false,
+ "isFunny" : false,
+ "thinksPeopleAreLaughing" : true,
+ "beHonest_thinksPeopleAreLaughing" : false
+ },
+ {"name" : "Goofist",
+ "languages" : [ {"lang" : "Common Lisp",
+ "proficiency" : ["over", 9000],
+ "lovesIt" : true }
+
+ , {"lang" : "Rust",
+ "proficiency" : -1,
+ "lovesIt" : true,
+ "isAshamedToLoveIt" : true}
+
+ , {"lang" : "Haskell",
+ "proficiency" : -1,
+ "lovesIt" : "i cannot tell a lie"}
+ ],
+ "pizzaOrder" : ["Blue Stilton", "Walnuts", "Pork Sausage", "Apple Slices"],
+ "isCool" : true,
+ "isFunny" : true,
+ "thinksPeopleAreLaughing" : true,
+ "beHonest_thinksPeopleAreLaughing" : true
+ }
+]
diff --git a/parzival.lisp b/parzival.lisp
index 4691a07..01e728a 100644
--- a/parzival.lisp
+++ b/parzival.lisp
@@ -335,20 +335,6 @@ the character C."
(<<map-cons result (<<* parser))))))
- ;; (lambda (stream)
- ;; (let ((result nil)
- ;; (parser (<<~ parser)))
- ;; (labels ((rec (stream)
- ;; (multiple-value-bind
- ;; (res ok? stream2) (funcall parser stream)
- ;; (if ok?
- ;; (progn
- ;; (push res result)
- ;; (rec stream2))
- ;; (values (nreverse result) t stream2)))))
- ;; (rec stream)))))
-
-
(defun <<+ (parser)
"Like <<* but fails if P does not succeed at least once."
(<<cons parser (<<* parser)))
@@ -386,7 +372,6 @@ the character C."
(<<cons value-parser (<<* (<<and separator-parser value-parser))))
-
(defun <<brackets (left center right)
(<<and left (<<bind center
(lambda (bracketed-value)
@@ -400,6 +385,7 @@ the character C."
;;; VALUE PARSERS. The following section contains utilities for parsing common
;;; values like strings or numbers.
+
(defun <<string (str)
"Parses exactly the string STR, resulting in STR on success."
(<<map (returning str)
@@ -421,10 +407,12 @@ the character C."
(<<def <whitespace< (<<* (<<or <space< <newline< <return< <linefeed< <tab<))
"Parses zero or more whitespace characters, returning them as a list")
+
(<<def <word< (<<to-string (<<+ <letter<))
"Parses a sequence of one or more letters characters, resulting in
a string containing them.")
+
(defun read-from-char-list (l)
(read-from-string (concatenate 'string l)))
@@ -451,7 +439,6 @@ the character C."
"Parses a fractional number in decimal format - e.g. .3234 or .002")
-
(<<def <real<
(<<bind (<<? (<<char #\-))
(lambda (neg?)