gigaparsec-0.3.0.0: Refreshed parsec-style library for compatibility with Scala parsley
LicenseBSD-3-Clause
MaintainerJamie Willis, Gigaparsec Maintainers
Stabilitystable
Safe HaskellSafe
LanguageHaskell2010

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

Synopsis

Documentation

some Source #

Arguments

:: Parsec a

the parser p to execute multiple times

-> Parsec (NonEmpty a)

a parser that parses p until it fails, returning a non-empty list of the successful results.

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

someTill Source #

Arguments

:: Parsec a

p, the parser to execute multiple times, at least once.

-> Parsec end

end, the parser that stops the parsing of p.

-> Parsec (NonEmpty a)

a parser that parses p until end succeeds, returning the non-empty list of all the successful results.

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

sepBy1 Source #

Arguments

:: Parsec a

p, the parser whose results are collected into a non-empty list.

-> Parsec sep

sep, the delimiter that must be parsed between every p.

-> Parsec (NonEmpty a)

a parser that parses p delimited by sep, returning the non-empty list of p's results.

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

sepEndBy1 Source #

Arguments

:: Parsec a

p, the parser whose results are collected into a list.

-> Parsec sep

sep, the delimiter that must be parsed between every p.

-> Parsec (NonEmpty a)

a parser that parses p delimited by sep, returning the non-empty list of p's results.

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

endBy1 Source #

Arguments

:: Parsec a

p, the parser whose results are collected into a non-empty list.

-> Parsec sep

sep, the delimiter that must be parsed between every p.

-> Parsec (NonEmpty a)

a parser that parses p delimited by sep, returning the non-empty list of p's results.

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