packages feed

flatparse 0.3.0.3 → 0.3.1.0

raw patch · 5 files changed

+91/−9 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ FlatParse.Basic: anyWord16_ :: Parser e ()
+ FlatParse.Basic: anyWord32_ :: Parser e ()
+ FlatParse.Basic: anyWord8_ :: Parser e ()
+ FlatParse.Basic: anyWord_ :: Parser e ()
+ FlatParse.Basic: fusedSatisfy_ :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> Parser e ()
+ FlatParse.Basic: satisfy_ :: (Char -> Bool) -> Parser e ()
+ FlatParse.Stateful: anyWord16_ :: Parser e ()
+ FlatParse.Stateful: anyWord32_ :: Parser e ()
+ FlatParse.Stateful: anyWord8_ :: Parser e ()
+ FlatParse.Stateful: anyWord_ :: Parser e ()
+ FlatParse.Stateful: fusedSatisfy_ :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> Parser e ()
+ FlatParse.Stateful: satisfy_ :: (Char -> Bool) -> Parser e ()

Files

bench/FPBasic.hs view
@@ -9,7 +9,7 @@ ws      = many_ $(switch [| case _ of " " -> pure (); "\n" -> pure () |]) open    = $(char '(') >> ws close   = $(char ')') >> ws-ident   = some_ (satisfyASCII isLatinLetter) >> ws+ident   = some_ (satisfyASCII_ isLatinLetter) >> ws sexp    = branch open (some_ sexp >> close) ident src     = sexp >> eof runSexp = runParser src@@ -18,7 +18,7 @@ longws    = some_ (longw >> ws) >> eof runLongws = runParser longws -numeral   = some_ (satisfyASCII isDigit) >> ws+numeral   = some_ (satisfyASCII_ isDigit) >> ws comma     = $(char ',') >> ws numcsv    = numeral >> many_ (comma >> numeral) >> eof runNumcsv = runParser numcsv
bench/FPStateful.hs view
@@ -9,7 +9,7 @@ ws      = many_ $(switch [| case _ of " " -> pure (); "\n" -> pure () |]) open    = $(char '(') >> ws close   = $(char ')') >> ws-ident   = some_ (satisfyASCII isLatinLetter) >> ws+ident   = some_ (satisfyASCII_ isLatinLetter) >> ws sexp    = branch open (some_ sexp >> close) ident src     = sexp >> eof runSexp = runParser src 0 0@@ -18,7 +18,7 @@ longws    = some_ (longw >> ws) >> eof runLongws = runParser longws 0 0 -numeral   = some_ (satisfyASCII isDigit) >> ws+numeral   = some_ (satisfyASCII_ isDigit) >> ws comma     = $(char ',') >> ws numcsv    = numeral >> many_ (comma >> numeral) >> eof runNumcsv = runParser numcsv 0 0
flatparse.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           flatparse-version:        0.3.0.3+version:        0.3.1.0 synopsis:       High-performance parsing from strict bytestrings description:    @Flatparse@ is a high-performance parsing library, focusing on programming languages and                 human-readable data formats. See the README for more information:
src/FlatParse/Basic.hs view
@@ -41,13 +41,19 @@   , switchWithPost   , rawSwitchWithPost   , satisfy+  , satisfy_   , satisfyASCII   , satisfyASCII_   , fusedSatisfy+  , fusedSatisfy_   , anyWord8+  , anyWord8_   , anyWord16+  , anyWord16_   , anyWord32+  , anyWord32_   , anyWord+  , anyWord_   , anyChar   , anyChar_   , anyCharASCII@@ -419,6 +425,13 @@   _             -> Fail# {-#  inline satisfy #-} +-- | Skip a UTF-8 `Char` for which a predicate holds.+satisfy_ :: (Char -> Bool) -> Parser e ()+satisfy_ f = Parser \fp eob s -> case runParser# anyChar fp eob s of+  OK# c s | f c -> OK# () s+  _             -> Fail#+{-#  inline satisfy_ #-}+ -- | Parse an ASCII `Char` for which a predicate holds. Assumption: the predicate must only return --   `True` for ASCII-range characters. Otherwise this function might read a 128-255 range byte, --   thereby breaking UTF-8 decoding.@@ -430,10 +443,15 @@        | otherwise -> Fail# {-#  inline satisfyASCII #-} --- | Parse an ASCII `Char` for which a predicate holds.+-- | Skip an ASCII `Char` for which a predicate holds. Assumption: the predicate+--   must only return `True` for ASCII-range characters. satisfyASCII_ :: (Char -> Bool) -> Parser e ()-satisfyASCII_ f = () <$ satisfyASCII f-{-# inline satisfyASCII_ #-}+satisfyASCII_ f = Parser \fp eob s -> case eqAddr# eob s of+  1# -> Fail#+  _  -> case derefChar8# s of+    c1 | f (C# c1) -> OK# () (plusAddr# s 1#)+       | otherwise -> Fail#+{-#  inline satisfyASCII_ #-}  -- | This is a variant of `satisfy` which allows more optimization. We can pick four testing --   functions for the four cases for the possible number of bytes in the UTF-8 character. So in@@ -486,6 +504,11 @@                              _    -> Fail# {-# inline fusedSatisfy #-} +-- | Skipping variant of `fusedSatisfy`.+fusedSatisfy_ :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> Parser e ()+fusedSatisfy_ f1 f2 f3 f4 = () <$ fusedSatisfy f1 f2 f3 f4+{-# inline fusedSatisfy_ #-}+ -- | Parse any `Word8`. anyWord8 :: Parser e Word8 anyWord8 = Parser \fp eob buf -> case eqAddr# eob buf of@@ -494,6 +517,11 @@     w -> OK# (W8# w) (plusAddr# buf 1#) {-# inline anyWord8 #-} +-- | Skip any `Word8`.+anyWord8_ :: Parser e ()+anyWord8_ = () <$ anyWord8+{-# inline anyWord8_ #-}+ -- | Parse any `Word16`. anyWord16 :: Parser e Word16 anyWord16 = Parser \fp eob buf -> case 2# <=# minusAddr# eob buf of@@ -502,6 +530,11 @@     w -> OK# (W16# w) (plusAddr# buf 2#) {-# inline anyWord16 #-} +-- | Skip any `Word16`.+anyWord16_ :: Parser e ()+anyWord16_ = () <$ anyWord16+{-# inline anyWord16_ #-}+ -- | Parse any `Word32`. anyWord32 :: Parser e Word32 anyWord32 = Parser \fp eob buf -> case 4# <=# minusAddr# eob buf of@@ -510,6 +543,11 @@     w -> OK# (W32# w) (plusAddr# buf 4#) {-# inline anyWord32 #-} +-- | Skip any `Word32`.+anyWord32_ :: Parser e ()+anyWord32_ = () <$ anyWord32+{-# inline anyWord32_ #-}+ -- | Parse any `Word`. anyWord :: Parser e Word anyWord = Parser \fp eob buf -> case 8# <=# minusAddr# eob buf of@@ -517,6 +555,11 @@   _  -> case indexWordOffAddr# buf 0# of     w -> OK# (W# w) (plusAddr# buf 8#) {-# inline anyWord #-}++-- | Skip any `Word`.+anyWord_ :: Parser e ()+anyWord_ = () <$ anyWord+{-# inline anyWord_ #-}  -- | Parse any UTF-8-encoded `Char`. anyChar :: Parser e Char
src/FlatParse/Stateful.hs view
@@ -47,13 +47,19 @@   , switchWithPost   , rawSwitchWithPost   , satisfy+  , satisfy_   , satisfyASCII   , satisfyASCII_   , fusedSatisfy+  , fusedSatisfy_   , anyWord8+  , anyWord8_   , anyWord16+  , anyWord16_   , anyWord32+  , anyWord32_   , anyWord+  , anyWord_   , anyChar   , anyChar_   , anyCharASCII@@ -454,6 +460,13 @@   _               -> Fail# {-#  inline satisfy #-} +-- | Skip a UTF-8 `Char` for which a predicate holds.+satisfy_ :: (Char -> Bool) -> Parser e ()+satisfy_ f = Parser \fp !r eob s n -> case runParser# anyChar fp r eob s n of+  OK# c s n | f c -> OK# () s n+  _               -> Fail#+{-#  inline satisfy_ #-}+ -- | Parse an ASCII `Char` for which a predicate holds. Assumption: the predicate must only return --   `True` for ASCII-range characters. Otherwise this function might read a 128-255 range byte, --   thereby breaking UTF-8 decoding.@@ -465,7 +478,8 @@        | otherwise -> Fail# {-#  inline satisfyASCII #-} --- | Parse an ASCII `Char` for which a predicate holds.+-- | Skip an ASCII `Char` for which a predicate holds.  Assumption: the+--   predicate must only return `True` for ASCII-range characters. satisfyASCII_ :: (Char -> Bool) -> Parser e () satisfyASCII_ f = () <$ satisfyASCII f {-# inline satisfyASCII_ #-}@@ -521,6 +535,11 @@                              _    -> Fail# {-# inline fusedSatisfy #-} +-- | Skipping variant of `fusedSatisfy`.+fusedSatisfy_ :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> Parser e ()+fusedSatisfy_ f1 f2 f3 f4 = () <$ fusedSatisfy f1 f2 f3 f4+{-# inline fusedSatisfy_ #-}+ -- | Parse any `Word8`. anyWord8 :: Parser e Word8 anyWord8 = Parser \fp !r eob buf n -> case eqAddr# eob buf of@@ -529,6 +548,11 @@     w -> OK# (W8# w) (plusAddr# buf 1#) n {-# inline anyWord8 #-} +-- | Skip any `Word8`.+anyWord8_ :: Parser e ()+anyWord8_ = () <$ anyWord8+{-# inline anyWord8_ #-}+ -- | Parse any `Word16`. anyWord16 :: Parser e Word16 anyWord16 = Parser \fp !r eob buf n -> case 2# <=# minusAddr# eob buf of@@ -537,6 +561,11 @@     w -> OK# (W16# w) (plusAddr# buf 2#) n {-# inline anyWord16 #-} +-- | Skip any `Word16`.+anyWord16_ :: Parser e ()+anyWord16_ = () <$ anyWord16+{-# inline anyWord16_ #-}+ -- | Parse any `Word32`. anyWord32 :: Parser e Word32 anyWord32 = Parser \fp !r eob buf n -> case 4# <=# minusAddr# eob buf of@@ -545,6 +574,11 @@     w -> OK# (W32# w) (plusAddr# buf 4#) n {-# inline anyWord32 #-} +-- | Skip any `Word32`.+anyWord32_ :: Parser e ()+anyWord32_ = () <$ anyWord32+{-# inline anyWord32_ #-}+ -- | Parse any `Word`. anyWord :: Parser e Word anyWord = Parser \fp !r eob buf n -> case 8# <=# minusAddr# eob buf of@@ -552,6 +586,11 @@   _  -> case indexWordOffAddr# buf 0# of     w -> OK# (W# w) (plusAddr# buf 8#) n {-# inline anyWord #-}++-- | Skip any `Word`.+anyWord_ :: Parser e ()+anyWord_ = () <$ anyWord+{-# inline anyWord_ #-}  -- | Parse any UTF-8-encoded `Char`. anyChar :: Parser e Char