Safe Haskell | None |
---|---|
Language | Haskell2010 |
Scanner implementation
- newtype Scanner a = Scanner {
- run :: forall r. ByteString -> Next a r -> Result r
- type Next a r = ByteString -> a -> Result r
- data Result r
- = Done ByteString r
- | Fail ByteString String
- | More (ByteString -> Result r)
- scan :: Scanner r -> ByteString -> Result r
- anyWord8 :: Scanner Word8
- takeWhile :: (Word8 -> Bool) -> Scanner ByteString
- take :: Int -> Scanner ByteString
- endOfInput :: Scanner Bool
- string :: ByteString -> Scanner ()
- lookAhead :: Scanner (Maybe Word8)
Documentation
CPS scanner without backtracking
Scanner | |
|
type Next a r = ByteString -> a -> Result r Source
Scanner continuation
Scanner result
Done ByteString r | Successful result with the rest of input |
Fail ByteString String | Scanner failed with rest of input and error message |
More (ByteString -> Result r) | Need more input |
scan :: Scanner r -> ByteString -> Result r Source
Run scanner with the input
take :: Int -> Scanner ByteString Source
Take the specified number of bytes
endOfInput :: Scanner Bool Source
Returns True
when there is no more input
string :: ByteString -> Scanner () Source
Consume the specified string
Warning: it is not optimized yet, so for for small string it is better
to consume it byte-by-byte using word8