From da79da086a028a55130fbbbc5e08ed0ce736ff96 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 14 Jun 2022 21:28:23 -0400 Subject: New "parser" hierarchy. [Part 2] --- stdlib/source/format/lux/data/binary.lux | 55 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'stdlib/source/format') diff --git a/stdlib/source/format/lux/data/binary.lux b/stdlib/source/format/lux/data/binary.lux index e29a737ce..a0b96a581 100644 --- a/stdlib/source/format/lux/data/binary.lux +++ b/stdlib/source/format/lux/data/binary.lux @@ -7,10 +7,9 @@ [monad (.only Monad do)] [equivalence (.only Equivalence)]] [control + ["<>" parser (.open: "[1]#[0]" monad)] ["[0]" pipe] - ["[0]" function] - ["<>" parser (.open: "[1]#[0]" monad) - ["" binary (.only Offset Size Parser)]]] + ["[0]" function]] [data ["[0]" product] [text @@ -30,8 +29,8 @@ ["n" nat] ["[0]" i64] ["[0]" frac]]]]] - [\\unsafe - ["[0]" / (.only Binary)]]) + ["[0]" \\unsafe (.only Binary)] + ["" \\parser (.only Offset Size Parser)]) (with_template [ ] [(def: @@ -59,7 +58,7 @@ (def: .public (instance [size mutation]) (-> Specification Binary) - (|> size /.empty [0] mutation product.right)) + (|> size \\unsafe.empty [0] mutation product.right)) (def: .public monoid (Monoid Specification) @@ -87,10 +86,10 @@ [(n#+ offset) ( offset value binary)])]))] - [bits_8 .size_8 /.has_8!] - [bits_16 .size_16 /.has_16!] - [bits_32 .size_32 /.has_32!] - [bits_64 .size_64 /.has_64!] + [bits_8 .size_8 \\unsafe.has_8!] + [bits_16 .size_16 \\unsafe.has_16!] + [bits_32 .size_32 \\unsafe.has_32!] + [bits_64 .size_64 \\unsafe.has_64!] ) (def: .public (or left right) @@ -103,7 +102,7 @@ [(.++ caseS) (function (_ [offset binary]) (|> binary - (/.has_8! offset ) + (\\unsafe.has_8! offset ) [(.++ offset)] caseT))])]) ([0 .#Left left] @@ -146,30 +145,30 @@ [size (function (_ [offset binary]) [(n#+ size offset) - (/.copy! (n.min size (/.size value)) - 0 - value - offset - binary)])])) + (\\unsafe.copy! (n.min size (\\unsafe.size value)) + 0 + value + offset + binary)])])) (with_template [ ] [(def: .public (Writer Binary) (let [mask (..mask )] (function (_ value) - (let [size (|> value /.size (i64.and mask)) + (let [size (|> value \\unsafe.size (i64.and mask)) size' (n#+ size)] [size' (function (_ [offset binary]) [(n#+ size' offset) (|> binary ( offset size) - (/.copy! size 0 value (n#+ offset)))])]))))] + (\\unsafe.copy! size 0 value (n#+ offset)))])]))))] - [binary_8 ..bits_8 .size_8 /.has_8!] - [binary_16 ..bits_16 .size_16 /.has_16!] - [binary_32 ..bits_32 .size_32 /.has_32!] - [binary_64 ..bits_64 .size_64 /.has_64!] + [binary_8 ..bits_8 .size_8 \\unsafe.has_8!] + [binary_16 ..bits_16 .size_16 \\unsafe.has_16!] + [binary_32 ..bits_32 .size_32 \\unsafe.has_32!] + [binary_64 ..bits_64 .size_64 \\unsafe.has_64!] ) (with_template [ ] @@ -209,10 +208,10 @@ [(n#+ offset)] mutation))])))] - [sequence_8 .size_8 /.has_8!] - [sequence_16 .size_16 /.has_16!] - [sequence_32 .size_32 /.has_32!] - [sequence_64 .size_64 /.has_64!] + [sequence_8 .size_8 \\unsafe.has_8!] + [sequence_16 .size_16 \\unsafe.has_16!] + [sequence_32 .size_32 \\unsafe.has_32!] + [sequence_64 .size_64 \\unsafe.has_64!] ) (def: .public maybe @@ -248,7 +247,7 @@ [(.++ caseS) (function (_ [offset binary]) (|> binary - (/.has_8! offset ) + (\\unsafe.has_8! offset ) [(.++ offset)] caseT))])]) ([0 .#Primitive (..and ..text (..list again))] @@ -282,7 +281,7 @@ [(.++ caseS) (function (_ [offset binary]) (|> binary - (/.has_8! offset ) + (\\unsafe.has_8! offset ) [(.++ offset)] caseT))])]) ([0 .#Bit ..bit] -- cgit v1.2.3