Earley-0.12.0.0: Parsing all context-free grammars using Earley's algorithm.

Text.Earley.Generator

Synopsis

# Documentation

data Result s t a Source #

The result of a generator.

Constructors

 Ended (ST s [(a, [t])]) The generator ended. Generated (ST s [(a, [t])]) (ST s (Result s t a)) The generator produced a number of as. These are given as a computation, ST s [a] that constructs the as when run. The Int is the position in the input where these results were obtained, and the last component is the continuation.

Instances

 Functor (Result s t) Source # Methodsfmap :: (a -> b) -> Result s t a -> Result s t b #(<\$) :: a -> Result s t b -> Result s t a #

type Generator t a = forall s. ST s (Result s t a) Source #

generator :: (forall r. Grammar r (Prod r e t a)) -> [t] -> Generator t a Source #

Create a language generator for given grammar and list of allowed tokens.

language :: Generator t a -> [(a, [t])] Source #

Run a generator, returning all members of the language.

The members are returned as parse results paired with the list of tokens used to produce the result. The elements of the returned list of results are sorted by their length in ascending order. If there are multiple results of the same length they are returned in an unspecified order.

upTo :: Int -> Generator t a -> [(a, [t])] Source #

upTo n gen runs the generator gen, returning all members of the language that are of length less than or equal to n.

The members are returned as parse results paired with the list of tokens used to produce the result. The elements of the returned list of results are sorted by their length in ascending order. If there are multiple results of the same length they are returned in an unspecified order.

exactly :: Int -> Generator t a -> [(a, [t])] Source #

exactly n gen runs the generator gen, returning all members of the language that are of length equal to n.

The members are returned as parse results paired with the list of tokens used to produce the result. If there are multiple results they are returned in an unspecified order.