From 2e4ab42aa00eca81332d14145a20bb281ca22af4 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sun, 26 Jan 2025 20:06:53 -0500 Subject: [PATCH] json: Notes --- src/Parser/JSON.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Parser/JSON.md b/src/Parser/JSON.md index 3fa005e..87af1dc 100644 --- a/src/Parser/JSON.md +++ b/src/Parser/JSON.md @@ -108,6 +108,7 @@ Define a `whitespace` character class based on the json specifications ```idris whitespace : Parser Char whitespace = do + pnote "Whitespace character" result <- parseChar (\x => any (== x) $ the (List _) [' ', '\n', '\r', '\t']) id case result of @@ -132,6 +133,7 @@ Top level json value parser export value : Parser (t : JSONType ** JSONValue t) value = do + pnote "JSON Value" surround whitespace $ oneOfE "Expected JSON Value" [ @@ -148,6 +150,7 @@ Now go through our json value types ```idris object = do + pnote "JSON Object" oneOfE "Expected Object" [emptyObject, occupiedObject] @@ -180,6 +183,7 @@ object = do ```idris array = do + pnote "JSON Array" oneOfE "Expected Array" [emptyArray, occupiedArray] @@ -210,6 +214,7 @@ array = do ```idris string = do + pnote "JSON String" str <- parseString $ delimited '"' '"' (many stringCharacter) pure $ VString str where @@ -223,12 +228,14 @@ string = do ```idris number = do + pnote "JSON Number" d <- double pure $ VNumber d ``` ```idris bool = do + pnote "JSON Bool" oneOfE "Expected Bool" [true, false] @@ -245,6 +252,7 @@ bool = do ```idris null = do + pnote "JSON null" _ <- exactString "null" pure VNull ```