diff options
Diffstat (limited to 'stdlib/source/library/lux/control/parser/binary.lux')
-rw-r--r-- | stdlib/source/library/lux/control/parser/binary.lux | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 1018e7683..7cf526d41 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -27,11 +27,11 @@ ["." // ("#\." monad)]) (type: .public Offset - {#.doc (doc "An offset for reading within binary data.")} + {#.doc (example "An offset for reading within binary data.")} Nat) (type: .public Parser - {#.doc (doc "A parser for raw binary data.")} + {#.doc (example "A parser for raw binary data.")} (//.Parser [Offset Binary])) (exception: .public (binary_was_not_fully_read {binary_length Nat} {bytes_read Nat}) @@ -39,8 +39,8 @@ ["Binary length" (%.nat binary_length)] ["Bytes read" (%.nat bytes_read)])) -(def: .public (run parser input) - {#.doc (doc "Runs a parser and checks that all the binary data was read by it.")} +(def: .public (result parser input) + {#.doc (example "Runs a parser and checks that all the binary data was read by it.")} (All [a] (-> (Parser a) Binary (Try a))) (case (parser [0 input]) (#try.Failure msg) @@ -53,25 +53,25 @@ (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? - {#.doc (doc "Checks whether there is no more data to read.")} + {#.doc (example "Checks whether there is no more data to read.")} (Parser Bit) (function (_ (^@ input [offset data])) (#try.Success [input (n.= offset (/.size data))]))) (def: .public offset - {#.doc (doc "The current offset (i.e. how much data has been read).")} + {#.doc (example "The current offset (i.e. how much data has been read).")} (Parser Offset) (function (_ (^@ input [offset data])) (#try.Success [input offset]))) (def: .public remaining - {#.doc (doc "How much of the data remains to be read.")} + {#.doc (example "How much of the data remains to be read.")} (Parser Nat) (function (_ (^@ input [offset data])) (#try.Success [input (n.- offset (/.size data))]))) (type: .public Size - {#.doc (doc "The size of a chunk of data within a binary array.")} + {#.doc (example "The size of a chunk of data within a binary array.")} Nat) (def: .public size/8 Size 1) @@ -129,14 +129,14 @@ [1 #.Right right]])) (def: .public (rec body) - {#.doc (doc "Tie the knot for a recursive parser.")} + {#.doc (example "Tie the knot for a recursive parser.")} (All [a] (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) (def: .public any - {#.doc (doc "Does no parsing, and just returns a dummy value.")} + {#.doc (example "Does no parsing, and just returns a dummy value.")} (Parser Any) (//\in [])) @@ -156,18 +156,18 @@ _ (//.lift (exception.except ..not_a_bit [value]))))) (def: .public (segment size) - {#.doc (doc "Parses a chunk of data of a given size.")} + {#.doc (example "Parses a chunk of data of a given size.")} (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size - 0 (#try.Success [[offset binary] (/.create 0)]) + 0 (#try.Success [[offset binary] (/.empty 0)]) _ (|> binary (/.slice offset size) (\ try.monad map (|>> [[(n.+ size offset) binary]])))))) (template [<size> <name> <bits>] [(`` (def: .public <name> - {#.doc (doc (~~ (template.text ["Parses a block of data prefixed with a size that is " <size> " bytes long."])))} + {#.doc (example (~~ (template.text ["Parses a block of data prefixed with a size that is " <size> " bytes long."])))} (Parser Binary) (do //.monad [size (//\map .nat <bits>)] @@ -181,7 +181,7 @@ (template [<size> <name> <binary>] [(`` (def: .public <name> - {#.doc (doc (~~ (template.text ["Parses a block of (UTF-8 encoded) text prefixed with a size that is " <size> " bytes long."])))} + {#.doc (example (~~ (template.text ["Parses a block of (UTF-8 encoded) text prefixed with a size that is " <size> " bytes long."])))} (Parser Text) (do //.monad [utf8 <binary>] @@ -197,7 +197,7 @@ (template [<size> <name> <bits>] [(def: .public (<name> valueP) - {#.doc (doc (~~ (template.text ["Parses a row of values prefixed with a size that is " <size> " bytes long."])))} + {#.doc (example (~~ (template.text ["Parses a row of values prefixed with a size that is " <size> " bytes long."])))} (All [v] (-> (Parser v) (Parser (Row v)))) (do //.monad [amount (: (Parser Nat) @@ -227,7 +227,7 @@ (..or ..any)) (def: .public (list value) - {#.doc (doc "Parses an arbitrarily long list of values.")} + {#.doc (example "Parses an arbitrarily long list of values.")} (All [a] (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) |