From c10e3c13866ef25bab020ec597fd11aa8d01c862 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 16 Sep 2020 05:54:25 -0400 Subject: Changed the format of project descriptor files. --- stdlib/source/lux/data/format/json.lux | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'stdlib/source/lux/data/format/json.lux') diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 12e94a331..e9b6ab8b6 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -22,7 +22,8 @@ ["." list ("#@." fold functor)] ["." row (#+ Row row) ("#@." monad)] ["." dictionary (#+ Dictionary)]]] - ["." macro (#+ monad with-gensyms) + ["." meta (#+ monad with-gensyms)] + [macro [syntax (#+ syntax:)] ["." code]]]) @@ -88,7 +89,7 @@ (wrap (` [(~ (code.text key-name)) (~ (wrapper value))])) _ - (macro.fail "Wrong syntax for JSON object."))) + (meta.fail "Wrong syntax for JSON object."))) pairs)] (wrap (list (` (: JSON (#..Object ((~! dictionary.from-list) (~! text.hash) @@ -334,18 +335,18 @@ (wrap chars)))) (def: (kv~ json~) - (-> (-> Any (Parser JSON)) (Parser [String JSON])) + (-> (Parser JSON) (Parser [String JSON])) (do <>.monad [key string~ _ space~ _ (.this ":") _ space~ - value (json~ [])] + value json~] (wrap [key value]))) (template [ ] [(def: ( json~) - (-> (-> Any (Parser JSON)) (Parser )) + (-> (Parser JSON) (Parser )) (do <>.monad [_ (.this ) _ space~ @@ -354,16 +355,24 @@ _ (.this )] (wrap ( elems))))] - [array~ Array "[" "]" (json~ []) row.from-list] + [array~ Array "[" "]" json~ row.from-list] [object~ Object "{" "}" (kv~ json~) (dictionary.from-list text.hash)] ) -(def: (json~' _) - (-> Any (Parser JSON)) - ($_ <>.or null~ boolean~ number~ string~ (array~ json~') (object~ json~'))) +(def: json~ + (Parser JSON) + (<>.rec + (function (_ json~) + ($_ <>.or + null~ + boolean~ + number~ + string~ + (array~ json~) + (object~ json~))))) (structure: #export codec (Codec Text JSON) (def: encode ..format) - (def: decode (.run (json~' [])))) + (def: decode (.run json~))) -- cgit v1.2.3