diff options
Diffstat (limited to 'stdlib/source/library/lux/control/parser/binary.lux')
-rw-r--r-- | stdlib/source/library/lux/control/parser/binary.lux | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index d2d195888..ec251b304 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -27,11 +27,9 @@ ["." // ("#\." monad)]) (type: .public Offset - {#.doc (example "An offset for reading within binary data.")} Nat) (type: .public Parser - {#.doc (example "A parser for raw binary data.")} (//.Parser [Offset Binary])) (exception: .public (binary_was_not_fully_read {binary_length Nat} {bytes_read Nat}) @@ -40,7 +38,6 @@ ["Bytes read" (%.nat bytes_read)])) (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 +50,21 @@ (exception.except ..binary_was_not_fully_read [length end]))))) (def: .public end? - {#.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 (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 (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 (example "The size of a chunk of data within a binary array.")} Nat) (def: .public size/8 Size 1) @@ -129,14 +122,12 @@ [1 #.Right right]])) (def: .public (rec body) - {#.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 (example "Does no parsing, and just returns a dummy value.")} (Parser Any) (//\in [])) @@ -156,7 +147,6 @@ _ (//.lifted (exception.except ..not_a_bit [value]))))) (def: .public (segment size) - {#.doc (example "Parses a chunk of data of a given size.")} (-> Nat (Parser Binary)) (function (_ [offset binary]) (case size @@ -167,7 +157,6 @@ (template [<size> <name> <bits>] [(`` (def: .public <name> - {#.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 +170,6 @@ (template [<size> <name> <binary>] [(`` (def: .public <name> - {#.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 +185,6 @@ (template [<size> <name> <bits>] [(def: .public (<name> valueP) - {#.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) @@ -212,8 +199,8 @@ (if (n.< amount index) (do //.monad [value valueP] - (recur (.inc index) - (row.add value output))) + (recur (.++ index) + (row.suffix value output))) (//\in output)))))] [08 row/8 ..bits/8] @@ -227,7 +214,6 @@ (..or ..any)) (def: .public (list value) - {#.doc (example "Parses an arbitrarily long list of values.")} (All [a] (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) |