From f12c2e6b7711c4f68631c1425f80b23ef6791ab6 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 26 Apr 2020 20:25:12 -0500 Subject: removed old json parser tutorial files --- examples/json-parser.org | 530 -------------------------------------------- examples/json-parzival.lisp | 97 -------- 2 files changed, 627 deletions(-) delete mode 100644 examples/json-parser.org delete mode 100644 examples/json-parzival.lisp diff --git a/examples/json-parser.org b/examples/json-parser.org deleted file mode 100644 index 737f5e8..0000000 --- a/examples/json-parser.org +++ /dev/null @@ -1,530 +0,0 @@ - -* A JSON parser written with =parzival= - - This file introduces the =parzival= Common Lisp library by building a simple - JSON parser. The parser that is completed will not be a "full" JSON parser in - that it won't parse the full range of number forms in the JSON spec, nor will - it parse escaped quote characters inside of strings. The code is for - educational purposes only. - - While as [[https://en.wikipedia.org/wiki/Parzival][Parzival]] sought the Holy Grail through much trial and folly, - =parzival= searches the space of context free languages while avoiding the - unholy = (parse-string - -;; failing to match a space, input starts with an #\x character -|json-parzival|> (parse-string - -;; matching and returning a newline -|json-parzival|> (parse-string (< - -;; failing to match either, empty string -|json-parzival|> (parse-string (< - -;; finally, matching a bunch of spaces or newlines and returning them as a list -|json-parzival|> (parse-string (<<* (< - -;; equivalently, just use your newly minted (parse-string -#+end_src - - Looking at the above, you already begin to see how new parsers can be built - up from old. We can go from a parser that accepts a single character, to one - that accepts either of two characters, to one that accepts a list of zero or - more of either of those two characters in a single clean line of code. Nice - stuff! - - -**** Ignoring Whitespace - - Now that you can match strings of whitespace you will create a parser to - ignore whitespace. Specifially, you'll write a parser that effectively - "strips" the whitespace around some other parser. The combinator doing the - heavy lifting is called =< (parse-string (< - -|json-parzival|> (parse-string (< - -#+end_src - - So what's happening here? First, the parser = (defvar json-txt "{\"name\" : \"Boutade\", - \"languages\" : [ {\"lang\" : \"Common Lisp\", - \"proficiency\" : null, - \"lovesIt\" : true } - - , {\"lang\" : \"Rust\", - \"proficiency\" : 0.8, - \"isAshamedToLoveIt\" : true} - - , {\"lang\" : \"Haskell\", - \"proficiency\" : 0.5, - \"lovesIt\" : \"sometimes, in some ways\"} - ], - \"religion\" : \"Goofism\", - \"pizzaOrder\" : [\"Tempeh Italian Sausage\", \"Spinach\", \"Mushrooms\", \"Red Pepper Flakes\"], - \"isCool\" : false, - \"isFunny\" : false, - \"thinksPeopleAreLaughing\" : true, - \"beHonest_thinksPeopleAreLaughing\" : false -}") -JSON-TXT - -|json-parzival|> (parse json-txt - - -#+end_src diff --git a/examples/json-parzival.lisp b/examples/json-parzival.lisp deleted file mode 100644 index 8937ab9..0000000 --- a/examples/json-parzival.lisp +++ /dev/null @@ -1,97 +0,0 @@ -;;;; A Toy parser for a most of JSON. -;;;; Specificially, double-quote characters are not escaped in strings -;;;; And the full range of numbers defined in the JSON specification are -;;;; not supported. This is file is intended to be a demonstration - -(defpackage "json-parzival" - (:use :cl :parzival)) - -(in-package "json-parzival") - -;;; Parses and returns JSON's null value - -(< T, false => NIL -(<