License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis |
Stability | stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module contains the classic parser combinator operations specific to parsers themselves, excluding those that consume input.
Since: 0.1.0.0
Documentation
This parser succeeds only if there is no input left to consume, and fails without consuming input otherwise.
Since: 0.1.0.0
This parser succeeds if there is still input left to consume, and fails otherwise.
Since: 0.1.0.0
someTill :: Parser a -> Parser b -> Parser [a] Source #
The combinator someTill p end
will try and parse p
as many times as possible (but at least once)
so long as end
cannot be successfully parsed. It will return the results from the successful parses of p
.
Since: 0.1.0.0
try :: Parser a -> Parser a Source #
This combinator allows a parser to backtrack on failure, which is to say that it will
not have consumed any input if it were to fail. This is important since parsec
semantics demand
that the second branch of (
can only be taken if the first did not consume input on failure.<|>
)
Excessive use of try
will reduce the efficiency of the parser and effect the generated error
messages. It should only be used in one of two circumstances:
- When two branches of a parser share a common leading prefix (in which case, it is often better to try and factor this out).
- When a parser needs to be executed atomically (for example, tokens).
Since: 0.1.0.0
lookAhead :: Parser a -> Parser a Source #
This combinator will attempt to parse a given parser. If it succeeds, the result is returned without having consumed any input. If it fails, however, any consumed input remains consumed.
Since: 0.1.0.0
notFollowedBy :: Parser a -> Parser () Source #
This combinator will ensure that a given parser fails. If the parser does fail, a ()
is returned
and no input is consumed. If the parser succeeded, then this combinator will fail, however it will
not consume any input.
Since: 0.1.0.0
The line
combinator returns the current line number at this point in the parse. Line numbers
start from 1.
Since: 1.0.1.0
The col
combinator returns the current column number at this point in the parse. Column numbers
start from 1.
Since: 1.0.1.0