From 219d23703198a61fd7ce647ad8f4b0edd8a52e9b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 26 Apr 2020 19:03:52 -0500 Subject: ws cleanup --- examples/Tutorial.org | 134 +++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 68 deletions(-) diff --git a/examples/Tutorial.org b/examples/Tutorial.org index 8788d5c..2da2c36 100644 --- a/examples/Tutorial.org +++ b/examples/Tutorial.org @@ -1,5 +1,3 @@ -#+TITLE: The Goofism Guide to PARZIVAL - *** Table Of Contents + [[#The Goofism Guide to PARZIVAL][The Goofism Guide to PARZIVAL]] @@ -20,7 +18,7 @@ * The Goofism Guide to PARZIVAL - + _A Gentle Introduction_ This tutorial will guide you through the process of creating a @@ -54,8 +52,8 @@ *** Parsers In =parzival= a parser is a function that accepts a character - stream and returns three values: - + stream and returns three values: + 1. A result value, which can be anything. 2. A success indicator, which is ~T~ if the parse succeeded, or ~NIL~ otherwise. @@ -84,7 +82,7 @@ that explicit mention of the terms here will make the tutorial easier to read and understand. -*** Naming Conventions +*** Naming Conventions The =parzival= package exports a number of tragically un-lispy looking symbols. You'll see things like =< (let ((string " ")) T # -PZ-JSON> (let ((string " +PZ-JSON> (let ((string " ")) (parse string -PZ-JSON> +PZ-JSON> -#+END_SRC +#+END_SRC So what is going on? The combinators =< (parse "hey dude" (< (parse "hey dude" (< -PZ-JSON> +PZ-JSON> #+END_SRC Ah! Much easier to understand. You just apply =#'string-upcase= to -the result of =(< ; #'(LAMBDA (NULL) :NULL) -; +; ; caught STYLE-WARNING: ; The variable NULL is defined but never used. -; +; ; compilation unit finished ; caught 1 STYLE-WARNING condition PZ-JSON> (parse "null" (parse "abcd" (< -PZ-JSON> - +PZ-JSON> + #+END_SRC Both parses succeed, but the second one would have failed if it @@ -391,11 +389,11 @@ PZ-JSON> #+BEGIN_SRC lisp -PZ-JSON> (< (< (parse "?z 7" -PZ-JSON> +PZ-JSON> -#+END_SRC +#+END_SRC What is going on here? The above example, while illustrative, is perhaps a bit hard to look at. Stay strong - relief will soon be @@ -424,11 +422,11 @@ PZ-JSON> =(< You could perhaps clarify the above definition with some intermediate parsers: -#+BEGIN_SRC +#+BEGIN_SRC -(< (parse "00001.443E+3" -PZ-JSON> +PZ-JSON> #+END_SRC @@ -532,7 +530,7 @@ In the very last REPL example, you see that = (parse "\"ab\\u6211cd moo \\n\"" @@ -683,7 +681,7 @@ PZ-JSON> (parse "\"they call me Colin \\\"Parse Master\\\" Okay\"" -PZ-JSON> +PZ-JSON> #+END_SRC @@ -736,7 +734,7 @@ And finally, = (parse "{\"a\" : 10 , \"b\" : 3 }" -PZ-JSON> (parse "{ \"name\" : \"colin\", -\"hobbies\" : [\"lisp\" , \"parsing\" ] , +PZ-JSON> (parse "{ \"name\" : \"colin\", +\"hobbies\" : [\"lisp\" , \"parsing\" ] , \"features\" : { \"head\" : \"round\", \"eyes\" : 2} }" -PZ-JSON> +PZ-JSON> #+END_SRC @@ -781,7 +779,7 @@ PZ-JSON> PZ-JSON> (with-open-file (file-input "examples/foo.json") (let ((rp-stream (make-instance 'replay-streams:character-input-replay-stream :source file-input))) - (parse rp-stream ("beHonest_thinksPeopleAreLaughing" . T))) T # - PZ-JSON> + PZ-JSON> #+END_SRC @@ -894,7 +892,7 @@ cbeo. (<