Portability | unknown |
---|---|
Stability | experimental |
Maintainer | bos@serpentine.com |
Simple, efficient parser combinators for lazy ByteString
strings, loosely based on Text.ParserCombinators.Parsec
.
- type ParseError = String
- data Parser a
- parse :: Parser a -> ByteString -> (ByteString, Either ParseError a)
- parseAt :: Parser a -> ByteString -> Int64 -> (ByteString, Either ParseError (a, Int64))
- parseTest :: Show a => Parser a -> ByteString -> IO ()
- (<?>) :: Parser a -> String -> Parser a
- try :: Parser a -> Parser a
- module Data.Attoparsec.Combinator
- anyWord8 :: Parser Word8
- notWord8 :: Word8 -> Parser Word8
- word8 :: Word8 -> Parser Word8
- satisfy :: (Word8 -> Bool) -> Parser Word8
- string :: ByteString -> Parser ByteString
- skipWhile :: (Word8 -> Bool) -> Parser ()
- stringTransform :: (ByteString -> ByteString) -> ByteString -> Parser ByteString
- takeAll :: Parser ByteString
- takeTill :: (Word8 -> Bool) -> Parser ByteString
- takeWhile :: (Word8 -> Bool) -> Parser ByteString
- takeWhile1 :: (Word8 -> Bool) -> Parser ByteString
- match :: Parser a -> Parser ByteString
- notEmpty :: Parser ByteString -> Parser ByteString
- endOfInput :: Parser ()
- getConsumed :: Parser Int64
- getInput :: Parser ByteString
- lookAhead :: Parser a -> Parser a
Parser types
type ParseError = StringSource
A description of a parsing error.
Running parsers
:: Parser a | parser to run |
-> ByteString | input to parse |
-> (ByteString, Either ParseError a) |
Run a parser.
:: Parser a | parser to run |
-> ByteString | input to parse |
-> Int64 | offset to count input from |
-> (ByteString, Either ParseError (a, Int64)) |
Run a parser. The Int64
value is used as a base to count the
number of bytes consumed.
Combinators
Name the parser, in case failure occurs.
module Data.Attoparsec.Combinator
Parsing individual bytes
Efficient string handling
string :: ByteString -> Parser ByteStringSource
Match a literal string exactly.
stringTransform :: (ByteString -> ByteString) -> ByteString -> Parser ByteStringSource
Match a literal string, after applying a transformation to both it and the matching text. Useful for e.g. case insensitive string comparison.
takeAll :: Parser ByteStringSource
Return all of the remaining input as a single string.
takeTill :: (Word8 -> Bool) -> Parser ByteStringSource
Consume bytes while the predicate fails. If the predicate never succeeds, the entire input string is returned.
takeWhile1 :: (Word8 -> Bool) -> Parser ByteStringSource
Consume bytes while the predicate is true. Fails if the predicate fails on the first byte.
Combinators
match :: Parser a -> Parser ByteStringSource
Parse some input with the given parser, and return the input it consumed as a string.
notEmpty :: Parser ByteString -> Parser ByteStringSource
Test that a parser returned a non-null ByteString
.
State observation functions
Succeed if we have reached the end of the input string.
getConsumed :: Parser Int64Source
Get number of bytes consumed so far.
getInput :: Parser ByteStringSource
Get remaining input.