diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df12f8..4fc2c6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for bytesmith +## 0.3.11.0 -- 2023-??-?? + +* Add `Data.Bytes.Parser.Latin.hexWord32`. + ## 0.3.10.0 -- 2023-07-25 * Add `mapErrorEffectfully`. diff --git a/src/Data/Bytes/Parser/Latin.hs b/src/Data/Bytes/Parser/Latin.hs index 3315048..ea4d13c 100644 --- a/src/Data/Bytes/Parser/Latin.hs +++ b/src/Data/Bytes/Parser/Latin.hs @@ -80,6 +80,7 @@ module Data.Bytes.Parser.Latin -- *** Variable Length , hexWord8 , hexWord16 + , hexWord32 -- *** Fixed Length , hexFixedWord8 , hexFixedWord16 @@ -473,6 +474,12 @@ hexWord16 e = Parser (# s1, r #) -> (# s1, upcastWord16Result r #) ) +hexWord32 :: e -> Parser e s Word32 +hexWord32 e = Parser + (\chunk0 s0 -> case hexSmallWordStart e 4294967296 (boxBytes chunk0) s0 of + (# s1, r #) -> (# s1, upcastWord32Result r #) + ) + -- | Parse a decimal-encoded 16-bit word. If the number is larger -- than 65535, this parser fails. decWord16 :: e -> Parser e s Word16