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

Safe HaskellNone
LanguageHaskell2010

Text.Earley.Parser

Description

Parsing.

Synopsis

Documentation

data Report e i Source

A parsing report, which contains fields that are useful for presenting errors to the user if a parse is deemed a failure. Note however that we get a report even when we successfully parse something.

Constructors

Report 

Fields

position :: Int

The final position in the input (0-based) that the parser reached.

expected :: [e]

The named productions processed at the final position.

unconsumed :: i

The part of the input string that was not consumed, which may be empty.

Instances

(Show e, Show i) => Show (Report e i) Source 

data Result s e i a Source

The result of a parse.

Constructors

Ended (Report e i)

The parser ended.

Parsed a Int i (i -> ST s (Result s e i a))

The parser parsed something, namely an a. The Int is the position in the input where it did so, the i is the rest of the input, and the function is the parser continuation. This allows incrementally feeding the parser more input (e.g. when the i is empty).

Instances

parser :: ListLike i t => (forall r. Grammar r e (Prod r e t a)) -> i -> ST s (Result s e i a) Source

Create a parser from the given grammar.

allParses :: (forall s. ST s (Result s e i a)) -> ([(a, Int)], Report e i) Source

Return all parses from the result of a given parser. The result may contain partial parses. The Ints are the position at which a result was produced.

fullParses :: ListLike i t => (forall s. ST s (Result s e i a)) -> ([a], Report e i) Source

Return all parses that reached the end of the input from the result of a given parser.