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

Safe HaskellNone






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.




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.


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

data Result s e i a Source

The result of a parse.


Ended (Report e i)

The parser ended.

Parsed (ST s [a]) Int i (ST s (Result s e i a))

The parser parsed a number of as. These are given as a computation, ST s [a] that constructs the as when run. We can thus save some work by ignoring this computation if we do not care about the results. The Int is the position in the input where these results were obtained, the i the rest of the input, and the last component is the continuation.


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.

report :: ListLike i t => (forall s. ST s (Result s e i a)) -> Report e i Source

See e.g. how far the parser is able to parse the input string before it fails. This can be much faster than getting the parse results for highly ambiguous grammars.