Portability | portable |
---|---|

Stability | experimental |

Maintainer | grantslatton@gmail.com |

Safe Haskell | Safe |

The bread and butter of combinatory parsing.

- assert :: Stream s t => Bool -> Parser s ()
- eof :: Stream s t => Parser s ()
- eitherP :: Stream s t => Parser s a -> Parser s b -> Parser s (Either a b)
- greedy :: Stream s t => Parser s a -> Parser s a
- guard :: Stream s t => Bool -> Parser s ()
- lookAhead :: Stream s t => Parser s a -> Parser s a
- notFollowedBy :: Stream s t => Parser s a -> Parser s ()
- option :: Stream s t => a -> Parser s a -> Parser s a
- optional :: Stream s t => Parser s a -> Parser s (Maybe a)
- test :: Stream s t => Parser s a -> Parser s Bool
- try :: Stream s t => Parser s a -> Parser s a
- (<|>) :: Stream s t => Parser s a -> Parser s a -> Parser s a
- anyToken :: Stream s t => Parser s t
- noneOf :: (Eq t, Stream s t) => [t] -> Parser s t
- oneOf :: (Eq t, Stream s t) => [t] -> Parser s t
- satisfy :: Stream s t => (t -> Bool) -> Parser s t
- token :: (Eq t, Stream s t) => t -> Parser s t
- chainl :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s a
- chainl1 :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s a
- chainr :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s a
- chainr1 :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s a
- count :: Stream s t => Int -> Parser s a -> Parser s [a]
- endBy :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- endBy1 :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- exactly :: Stream s t => Int -> Parser s a -> Parser s [a]
- many :: Stream s t => Parser s a -> Parser s [a]
- many1 :: Stream s t => Parser s a -> Parser s [a]
- manyTill :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- mN :: Stream s t => Int -> Int -> Parser s a -> Parser s [a]
- sepBy :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- sepBy1 :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- skipMany :: Stream s t => Parser s a -> Parser s ()
- skipMany1 :: Stream s t => Parser s a -> Parser s ()
- sepEndBy :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- sepEndBy1 :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- takeWhile :: Stream s t => (t -> Bool) -> Parser s [t]
- takeWhile1 :: Stream s t => (t -> Bool) -> Parser s [t]
- choice :: Stream s t => [Parser s a] -> Parser s a
- perm :: Stream s t => [Parser s a] -> Parser s [a]
- select :: Stream s t => [Parser s a] -> Parser s (Int, a)
- branch :: Parser s a -> Parser s a -> Parser s a
- (<||>) :: Parser s a -> Parser s a -> Parser s a
- chainl_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s a
- chainr_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s a
- chainl1_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s a
- chainr1_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s a
- choice_ :: Stream s t => [Parser s a] -> Parser s a
- eitherP_ :: Stream s t => Parser s a -> Parser s b -> Parser s (Either a b)
- endBy_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- endBy1_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- many_ :: Parser s a -> Parser s [a]
- many1_ :: Parser s a -> Parser s [a]
- mN_ :: Stream s t => Int -> Int -> Parser s a -> Parser s [a]
- option_ :: Stream s t => a -> Parser s a -> Parser s a
- optional_ :: Stream s t => Parser s a -> Parser s (Maybe a)
- perm_ :: Stream s t => [Parser s a] -> Parser s [a]
- select_ :: Stream s t => [Parser s a] -> Parser s (Int, a)
- sepBy_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- sepBy1_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- sepEndBy_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- sepEndBy1_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]
- skipMany_ :: Stream s t => Parser s a -> Parser s ()
- skipMany1_ :: Stream s t => Parser s a -> Parser s ()
- takeWhile_ :: Stream s t => (t -> Bool) -> Parser s [t]
- takeWhile1_ :: Stream s t => (t -> Bool) -> Parser s [t]

# Utility Parsers

greedy :: Stream s t => Parser s a -> Parser s aSource

Modifies a parser so that it will ony return the most consumptive succesful results.

lookAhead :: Stream s t => Parser s a -> Parser s aSource

Applies the parser and returns its result, but resets
the `Stream`

as if it consumed nothing.

notFollowedBy :: Stream s t => Parser s a -> Parser s ()Source

Only succeeds when the given parser fails. Consumes no input.

option :: Stream s t => a -> Parser s a -> Parser s aSource

Attempts to apply a parser and returns a default value if it fails.

try :: Stream s t => Parser s a -> Parser s aSource

Does nothing -- only used for `Parsec`

compatability.

(<|>) :: Stream s t => Parser s a -> Parser s a -> Parser s aSource

`a <|> b`

is equivalent to

. That is, first `choice`

[a,b]`a`

is
tried, and if it yields no results, `b`

is tried.

# Token Parsers

noneOf :: (Eq t, Stream s t) => [t] -> Parser s tSource

Parse a token that is not a member of the list of tokens.

oneOf :: (Eq t, Stream s t) => [t] -> Parser s tSource

Parse a token that is a member of the list of tokens.

# Repetetive Parsers

chainl :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s aSource

`chainr p o x`

parses zero or more occurences of `p`

separated by `o`

.
The result is the left associative application of the functions to the
values. If `p`

succeeds zero times, `x`

is returned.

chainl1 :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s aSource

Like `chainl`

, but a minimum of one occurence of `p`

must be parsed.

chainr :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s aSource

Like `chainl`

, but right associative.

chainr1 :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s aSource

Like `chainl1`

, but right associative.

count :: Stream s t => Int -> Parser s a -> Parser s [a]Source

`count n p`

parses exactly `n`

occurences of `p`

.

endBy :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`endBy p s`

parses multiple occurences of `p`

separated and ended by
`s`

.

endBy1 :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`endBy1 p s`

parses one or more occurences of `p`

separated and ended
by `s`

.

manyTill :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`manyTill a b`

parses multiple occurences of `a`

until `b`

would
succeed if tried.

mN :: Stream s t => Int -> Int -> Parser s a -> Parser s [a]Source

`mN m n p`

parses between `m`

and `n`

occurences of `p`

, inclusive.

sepBy :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`sepBy1 p s`

parses many occurences of `p`

separated by `s`

.

sepBy1 :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`sepBy1 p s`

parses one or more occurences of `p`

separated by `s`

.

skipMany :: Stream s t => Parser s a -> Parser s ()Source

Identical to `many`

except the result is discarded.

skipMany1 :: Stream s t => Parser s a -> Parser s ()Source

Identical to `many1`

except the result is discarded.

sepEndBy :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`sepEndBy p s`

parses multiple occurences of `p`

separated and
optionally ended by `s`

.

sepEndBy1 :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

`sepEndBy p s`

parses one or more occurences of `p`

separated and
optionally ended by `s`

.

takeWhile :: Stream s t => (t -> Bool) -> Parser s [t]Source

Parse tokens while a predicate remains true.

takeWhile1 :: Stream s t => (t -> Bool) -> Parser s [t]Source

Parse one or more tokens while a predicate remains true.

# Group Parsers

choice :: Stream s t => [Parser s a] -> Parser s aSource

Attempt to apply each parser in the list in order until one succeeds.

select :: Stream s t => [Parser s a] -> Parser s (Int, a)Source

Like `choice`

, but returns the index of the successful parser as well
as the result.

# Branching Parsers

branch :: Parser s a -> Parser s a -> Parser s aSource

Splits the current parse branch between the two parsers.

chainl_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s aSource

Branches every iteration where one branch stops and one branch continues.

chainr_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> a -> Parser s aSource

Branches every iteration where one branch stops and one branch continues.

chainl1_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s aSource

Branches every iteration where one branch stops and one branch continues.

chainr1_ :: Stream s t => Parser s a -> Parser s (a -> a -> a) -> Parser s aSource

Branches every iteration where one branch stops and one branch continues.

choice_ :: Stream s t => [Parser s a] -> Parser s aSource

Given a list of parsers, split off a branch for each one.

eitherP_ :: Stream s t => Parser s a -> Parser s b -> Parser s (Either a b)Source

Like `eitherP`

, but tries both `a`

and `b`

.

endBy_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

endBy1_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

many_ :: Parser s a -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

many1_ :: Parser s a -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

mN_ :: Stream s t => Int -> Int -> Parser s a -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

option_ :: Stream s t => a -> Parser s a -> Parser s aSource

Splits off two branches, one where the parse is attempted, and one where it is not.

optional_ :: Stream s t => Parser s a -> Parser s (Maybe a)Source

Splits off two branches, one where the parse is attempted, and one where it is not.

perm_ :: Stream s t => [Parser s a] -> Parser s [a]Source

Parses a sequence of parsers in all possible orders.

select_ :: Stream s t => [Parser s a] -> Parser s (Int, a)Source

Like `choice_`

, but returns the index of the successful parser.

sepBy_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

sepBy1_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

sepEndBy_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

sepEndBy1_ :: Stream s t => Parser s a -> Parser s b -> Parser s [a]Source

Branches every iteration where one branch stops and one branch continues.

skipMany_ :: Stream s t => Parser s a -> Parser s ()Source

Branches every iteration where one branch stops and one branch continues.

skipMany1_ :: Stream s t => Parser s a -> Parser s ()Source

Branches every iteration where one branch stops and one branch continues.

takeWhile_ :: Stream s t => (t -> Bool) -> Parser s [t]Source

Branches every iteration where one branch stops and one branch continues.

takeWhile1_ :: Stream s t => (t -> Bool) -> Parser s [t]Source

Branches every iteration where one branch stops and one branch continues.