| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Language.Ltml.Parser.MiTree
Description
Parsing Mixed Indentation Trees---trees that may both be represented by indentation, or by bracketing tokens, where the latter nodes may span multiple lines, while empty lines are disallowed.
Synopsis
- data MiElementConfig = MiElementConfig {}
- data InlineParser (m :: Type -> Type) a
- = LeafParser (m (MiElementConfig, [a]))
- | BracketingParser (m ([a] -> (MiElementConfig, [a]))) (m ())
- data Restricted a
- unrestricted :: a -> Restricted a
- unbracketed :: a -> Restricted a
- miForest :: (MonadParser m, FromWhitespace [a]) => [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m [a]
- hangingBlock :: (MonadParser m, FromWhitespace [a]) => m ([a] -> b) -> [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m b
- hangingBlock' :: (MonadParser m, FromWhitespace [a]) => m b -> [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m (b, [a])
- hangingBlock_ :: (MonadParser m, FromWhitespace [a]) => m () -> [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m [a]
- pipeSeparated :: (MonadParser m, FromWhitespace [a]) => [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m [[a]]
Documentation
data MiElementConfig Source #
Configuration on how to handle an element (node in a mi-tree).
Constructors
| MiElementConfig | |
Fields
| |
data InlineParser (m :: Type -> Type) a Source #
An in-line element parser (constructor). Involved parsers must not consume whitespace (ASCII spaces, newlines) and must not accept the empty input.
Constructors
| LeafParser (m (MiElementConfig, [a])) | |
| BracketingParser (m ([a] -> (MiElementConfig, [a]))) (m ()) | Bracketing parser, composed of two parsers, one for the opening
bracket, one for the closing bracket.
The closing bracket parser is only used if possible
(via |
data Restricted a Source #
unrestricted :: a -> Restricted a Source #
unbracketed :: a -> Restricted a Source #
Arguments
| :: (MonadParser m, FromWhitespace [a]) | |
| => [Restricted (InlineParser m a)] | In-line element parsers. They are tried in the given order. |
| -> (Maybe Pos -> m a) | Block element parser. The block parser is only attempted at the start of a line, and takes precedence over in-line parsers there. Unlike the in-line parsers, the block parser must take care of indentation itself--except at the very beginning, where it may expect that any indentation has been consumed and the indentation is correct. The supplied indentation is the parent's, and indentation is acceptable iff strictly larger than that. Further, the block parser must only succeed after a final newline (plus indentation). Typically, a block parser is constructed via |
| -> m [a] |
Parse a list of mixed indentation trees (a forest), terminated by a newline (plus indentation).
At least one element is parsed.
This is expected to be run at the start of a non-empty line, after any indentation.
The initial (minimum) indentation is set to none.
Arguments
| :: (MonadParser m, FromWhitespace [a]) | |
| => m ([a] -> b) | Keyword parser. Result is applied to the parsed mi-forest. This is expected not to consume any whitespace. |
| -> [Restricted (InlineParser m a)] | |
| -> (Maybe Pos -> m a) | |
| -> m b |
Parse a mi-forest headed by a keyword, with all lines but the first indented further than the first.
Text may begin on the line of the keyword or on the next (indented) line.
The documentation on miForest generally applies.
hangingBlock' :: (MonadParser m, FromWhitespace [a]) => m b -> [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m (b, [a]) Source #
Version of hangingBlock where the keyword parser may yield any value,
which is paired with the parsed mi-forest.
hangingBlock_ :: (MonadParser m, FromWhitespace [a]) => m () -> [Restricted (InlineParser m a)] -> (Maybe Pos -> m a) -> m [a] Source #
Version of hangingBlock where the keyword parser does not return a
value.
Arguments
| :: (MonadParser m, FromWhitespace [a]) | |
| => [Restricted (InlineParser m a)] | |
| -> (Maybe Pos -> m a) | Block parser. Documentation of |
| -> m [[a]] |
Parse a list of '|' seperated TextForests. At least one element will be parsed. The list can also be defined across multiple lines and contain empty lines. The initial (minimum) indentation is set to none.