Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module exposes the internals of the package: its API may change independently of the PVP-compliant version number.
- data Rule s r e t a = Rule {}
- mkRule :: ProdR s r e t a -> ST s (Rule s r e t a)
- prodNulls :: ProdR s r e t a -> Results s a
- removeNulls :: ProdR s r e t a -> ProdR s r e t a
- type ProdR s r e t a = Prod (Rule s r) e t a
- resetConts :: Rule s r e t a -> ST s ()
- newtype Results s a = Results {}
- lazyResults :: ST s [a] -> ST s (Results s a)
- data BirthPos
- data State s r e t a where
- data Cont s r e t a b where
- data Conts s r e t a c = Conts {}
- newConts :: STRef s [Cont s r e t a c] -> ST s (Conts s r e t a c)
- contraMapCont :: (b -> Results s a) -> Cont s r e t a c -> Cont s r e t b c
- contToState :: BirthPos -> Results s a -> Cont s r e t a c -> State s r e t c
- simplifyCont :: Conts s r e t b a -> ST s [Cont s r e t b a]
- initialState :: ProdR s a e t a -> ST s (State s a e t a)
- data Report e i = Report {
- position :: Int
- expected :: [e]
- unconsumed :: i
- data Result s e i a
- safeHead :: ListLike i t => i -> Maybe t
- data ParseEnv s e i t a = ParseEnv {}
- emptyParseEnv :: i -> ParseEnv s e i t a
- parse :: ListLike i t => [State s a e t a] -> ParseEnv s e i t a -> ST s (Result s e i a)
- type Parser e i a = forall s. i -> ST s (Result s e i a)
- parser :: ListLike i t => (forall r. Grammar r (Prod r e t a)) -> Parser e i a
- allParses :: Parser e i a -> i -> ([(a, Int)], Report e i)
- fullParses :: ListLike i t => Parser e i a -> i -> ([a], Report e i)
- report :: Parser e i a -> i -> Report e i
Concrete rules and productions
The concrete rule type that the parser uses
removeNulls :: ProdR s r e t a -> ProdR s r e t a Source #
Remove (some) nulls from a production
resetConts :: Rule s r e t a -> ST s () Source #
Delayed results
States and continuations
simplifyCont :: Conts s r e t b a -> ST s [Cont s r e t b a] Source #
Strings of non-ambiguous continuations can be optimised by removing indirections.
Grammars
initialState :: ProdR s a e t a -> ST s (State s a e t a) Source #
Given a grammar, construct an initial state.
Parsing
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.
Report | |
|
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 |
data ParseEnv s e i t a Source #
ParseEnv | |
|
emptyParseEnv :: i -> ParseEnv s e i t a Source #
:: ListLike i t | |
=> [State s a e t a] | States to process at this position |
-> ParseEnv s e i t a | |
-> ST s (Result s e i a) |
The internal parsing routine
parser :: ListLike i t => (forall r. Grammar r (Prod r e t a)) -> Parser e i a Source #
Create a parser from the given grammar.
allParses :: Parser e i a -> i -> ([(a, Int)], Report e i) Source #
Return all parses from the result of a given parser. The result may
contain partial parses. The Int
s are the position at which a result was
produced.
The elements of the returned list of results are sorted by their position in ascending order. If there are multiple results at the same position they are returned in an unspecified order.