aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/format
diff options
context:
space:
mode:
authorEduardo Julian2022-06-14 21:28:23 -0400
committerEduardo Julian2022-06-14 21:28:23 -0400
commitda79da086a028a55130fbbbc5e08ed0ce736ff96 (patch)
tree3cca77c0271a65e29c5d8057d3837db3e330e359 /stdlib/source/format
parent3a81232c2367df2416f62f651259ff9297abc7d4 (diff)
New "parser" hierarchy. [Part 2]
Diffstat (limited to 'stdlib/source/format')
-rw-r--r--stdlib/source/format/lux/data/binary.lux55
1 files changed, 27 insertions, 28 deletions
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 [<name> <extension> <post>]
[(def: <name>
@@ -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#+ <size> offset)
(<write> 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 <number>)
+ (\\unsafe.has_8! offset <number>)
[(.++ 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 [<name> <bits> <size> <write>]
[(def: .public <name>
(Writer Binary)
(let [mask (..mask <size>)]
(function (_ value)
- (let [size (|> value /.size (i64.and mask))
+ (let [size (|> value \\unsafe.size (i64.and mask))
size' (n#+ <size> size)]
[size'
(function (_ [offset binary])
[(n#+ size' offset)
(|> binary
(<write> offset size)
- (/.copy! size 0 value (n#+ <size> offset)))])]))))]
+ (\\unsafe.copy! size 0 value (n#+ <size> 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 [<name> <binary>]
@@ -209,10 +208,10 @@
[(n#+ <size> 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 <number>)
+ (\\unsafe.has_8! offset <number>)
[(.++ offset)]
caseT))])])
([0 .#Primitive (..and ..text (..list again))]
@@ -282,7 +281,7 @@
[(.++ caseS)
(function (_ [offset binary])
(|> binary
- (/.has_8! offset <number>)
+ (\\unsafe.has_8! offset <number>)
[(.++ offset)]
caseT))])])
([0 .#Bit ..bit]