| License | BSD-3-Clause |
|---|---|
| Maintainer | Jamie Willis, Gigaparsec Maintainers |
| Stability | stable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Text.Gigaparsec.Combinator.NonEmpty
Description
This module contains variants of combinators that return non-empty lists of results, modifying the result type to NonEmpty.
These allow for stronger guarantees of parsed results to be baked into their types.
Since: 0.3.0.0
Documentation
Arguments
| :: Parsec a | the parser |
| -> Parsec (NonEmpty a) | a parser that parses |
This combinator repeatedly parses a given parser one or more times, collecting the results into a non-empty list.
Parses a given parser, p, repeatedly until it fails. If p failed having consumed input,
this combinator fails.
Otherwise, when p fails without consuming input, this combinator
will return all of the results, x₁ through xₙ (with n ≥ 1), in a non-empty list: x₁ :| [x₂, .., xₙ].
Requires at least one p to have been parsed.
Since: 0.3.0.0
Arguments
| :: Parsec a |
|
| -> Parsec end |
|
| -> Parsec (NonEmpty a) | a parser that parses |
This combinator repeatedly parses a given parser one or more times, until the end parser succeeds, collecting the results into a non-empty list.
First ensures that trying to parse end fails, then tries to parse p. If it succeeds then it will repeatedly: try to parse end, if it fails
without consuming input, then parses p, which must succeed.
When end does succeed, this combinator will return all of the results
generated by p, x₁ through xₙ (with n ≥ 1), in a non-empty list: x₁ :| [x₂, .., xₙ].
The parser p must succeed at least once before end succeeds.
Since: 0.3.0.0
Arguments
| :: Parsec a |
|
| -> Parsec sep |
|
| -> Parsec (NonEmpty a) | a parser that parses |
This combinator parses one or more occurrences of p, separated by sep.
First parses a p. Then parses sep followed by p until there are no more seps.
The results of the p's, x₁ through xₙ, are returned as x₁ :| [x₂, .., xₙ].
If p or sep fails having consumed input, the whole parser fails.
Requires at least one p to have been parsed.
Since: 0.3.0.0
Arguments
| :: Parsec a |
|
| -> Parsec sep |
|
| -> Parsec (NonEmpty a) | a parser that parses |
This combinator parses one or more occurrences of p, separated and optionally ended by sep,
collecting the results in a non-empty list.
First parses a p. Then parses sep followed by p until there are no more: if a final sep exists, this is parsed.
The results of the p's, x₁ through xₙ, are returned as x₁ :| [x₂, .., xₙ].
If p or sep fails having consumed input, the whole parser fails.
Requires at least one p to have been parsed.
Since: 0.3.0.0
Arguments
| :: Parsec a |
|
| -> Parsec sep |
|
| -> Parsec (NonEmpty a) | a parser that parses |
This combinator parses one or more occurrences of p, separated and ended by sep.
Parses p followed by sep one or more times.
The results of the p's, x₁ through xₙ, are returned as x₁ :| [x₂, .., xₙ].
If p or sep fails having consumed input, the whole parser fails.
Requires at least one p to have been parsed.
Since: 0.3.0.0