diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/parser/lux/data/binary.lux | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/stdlib/source/parser/lux/data/binary.lux b/stdlib/source/parser/lux/data/binary.lux index d09eeba86..117f07a34 100644 --- a/stdlib/source/parser/lux/data/binary.lux +++ b/stdlib/source/parser/lux/data/binary.lux @@ -44,7 +44,7 @@ "Bytes read" (%.nat bytes_read))) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (template (<name> <parameter> <subject>) [(<extension> <parameter> <subject>)]))] @@ -53,7 +53,7 @@ [n#- "lux i64 -"] ) -(def: .public (result parser input) +(def .public (result parser input) (All (_ a) (-> (Parser a) Binary (Try a))) (case (parser [0 input]) {try.#Success [[end _] output]} @@ -65,17 +65,17 @@ failure (as_expected failure))) -(def: .public end? +(def .public end? (Parser Bit) (function (_ (^.let input [offset data])) {try.#Success [input (n#= offset (/.size data))]})) -(def: .public offset +(def .public offset (Parser Offset) (function (_ (^.let input [offset data])) {try.#Success [input offset]})) -(def: .public remaining +(def .public remaining (Parser Nat) (function (_ (^.let input [offset data])) {try.#Success [input (n#- offset (/.size data))]})) @@ -83,10 +83,10 @@ (type: .public Size Nat) -(def: .public size_8 Size 1) -(def: .public size_16 Size (n.* 2 size_8)) -(def: .public size_32 Size (n.* 2 size_16)) -(def: .public size_64 Size (n.* 2 size_32)) +(def .public size_8 Size 1) +(def .public size_16 Size (n.* 2 size_8)) +(def .public size_32 Size (n.* 2 size_16)) +(def .public size_64 Size (n.* 2 size_32)) (exception: .public (range_out_of_bounds [length Nat start Nat @@ -97,7 +97,7 @@ "Range end" (%.nat end))) (with_template [<name> <size> <read>] - [(def: .public <name> + [(def .public <name> (Parser I64) (function (_ [start binary]) (let [end (n#+ <size> start)] @@ -114,14 +114,14 @@ ) (with_template [<name> <type>] - [(def: .public <name> (Parser <type>) ..bits_64)] + [(def .public <name> (Parser <type>) ..bits_64)] [nat Nat] [int Int] [rev Rev] ) -(def: .public frac +(def .public frac (Parser Frac) (//#each frac.of_bits ..bits_64)) @@ -131,7 +131,7 @@ "Tag range" (%.nat range) "Tag value" (%.nat byte))) -(def: !variant +(def !variant (template (!variant <case>+) [(do [! //.monad] [flag (is (Parser Nat) @@ -144,18 +144,18 @@ _ (//.lifted (exception.except ..invalid_tag [(template.amount [<case>+]) flag])))))])) -(def: .public (or left right) +(def .public (or left right) (All (_ l r) (-> (Parser l) (Parser r) (Parser (Or l r)))) (!variant [[0 [.#Left] left] [1 [.#Right] right]])) -(def: .public (rec body) +(def .public (rec body) (All (_ a) (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) -(def: .public any +(def .public any (Parser Any) (//#in [])) @@ -164,7 +164,7 @@ "Expected values" "either 0 or 1" "Actual value" (%.nat value))) -(def: .public bit +(def .public bit (Parser Bit) (do //.monad [value (is (Parser Nat) @@ -174,7 +174,7 @@ 1 (in #1) _ (//.lifted (exception.except ..not_a_bit [value]))))) -(def: .public (segment size) +(def .public (segment size) (-> Nat (Parser Binary)) (case size 0 (//#in (/.empty 0)) @@ -188,7 +188,7 @@ {try.#Success})))))) (with_template [<size> <name> <bits>] - [(`` (def: .public <name> + [(`` (def .public <name> (Parser Binary) (do //.monad [size (//#each (|>> .nat) <bits>)] @@ -201,7 +201,7 @@ ) (with_template [<size> <name> <binary>] - [(`` (def: .public <name> + [(`` (def .public <name> (Parser Text) (do //.monad [utf8 <binary>] @@ -213,10 +213,10 @@ [64 utf8_64 ..binary_64] ) -(def: .public text ..utf8_64) +(def .public text ..utf8_64) (with_template [<size> <name> <bits>] - [(def: .public (<name> valueP) + [(def .public (<name> valueP) (All (_ v) (-> (Parser v) (Parser (Sequence v)))) (do //.monad [amount (is (Parser Nat) @@ -240,11 +240,11 @@ [64 sequence_64 ..bits_64] ) -(def: .public maybe +(def .public maybe (All (_ a) (-> (Parser a) (Parser (Maybe a)))) (..or ..any)) -(def: .public (list value) +(def .public (list value) (All (_ a) (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) @@ -252,7 +252,7 @@ (exception: .public set_elements_are_not_unique) -(def: .public (set hash value) +(def .public (set hash value) (All (_ a) (-> (Hash a) (Parser a) (Parser (Set a)))) (do //.monad [raw (..list value) @@ -262,11 +262,11 @@ (set.size output)))] (in output))) -(def: .public symbol +(def .public symbol (Parser Symbol) (//.and ..text ..text)) -(def: .public type +(def .public type (Parser Type) (..rec (function (_ type) @@ -285,11 +285,11 @@ [9 [.#Apply] pair] [10 [.#Named] (//.and ..symbol type)]]))))) -(def: .public location +(def .public location (Parser Location) (all //.and ..text ..nat ..nat)) -(def: .public code +(def .public code (Parser Code) (..rec (function (_ again) |