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 {}
- 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 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 :: 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]
- mkRule :: ProdR s r e t a -> ST s (Rule s r e t a)
- grammar :: Grammar (Rule s r) a -> ST s 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)
- parser :: ListLike i t => (forall r. Grammar r (Prod r e t a)) -> ST s (i -> ST s (Result s e i a))
- allParses :: (forall s. ST s (i -> ST s (Result s e i a))) -> i -> ([(a, Int)], Report e i)
- fullParses :: ListLike i t => (forall s. ST s (i -> ST s (Result s e i a))) -> i -> ([a], Report e i)
- report :: ListLike i t => (forall s. ST s (i -> ST s (Result s e i a))) -> i -> Report e i
Concrete rules and productions
The concrete rule type that the parser uses
resetConts :: Rule s r e t a -> ST s () Source
Delayed results
lazyResults :: ST s [a] -> ST s (Results s a) Source
States and continuations
contraMapCont :: (b -> Results s a) -> Cont s r e t a c -> Cont s r e t b c Source
contToState :: Results s a -> Cont s r e t a c -> State s r e t c Source
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)) -> ST s (i -> ST s (Result s e i a)) Source
Create a parser from the given grammar.
allParses :: (forall s. ST s (i -> ST s (Result s 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.