Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Slab.Parse
provides parsers to read text and construct an abstract syntax
tree, as represented by Slab.Syntax.
Parsers are written using the megaparsec
library.
Synopsis
- parseFile :: FilePath -> IO (Either Error [Block])
- parseFileE :: FilePath -> ExceptT Error IO [Block]
- parse :: FilePath -> Text -> Either (ParseErrorBundle Text Void) [Block]
- parseExpr :: Text -> Either (ParseErrorBundle Text Void) Expr
- parserTextInclude :: Text -> Block
- type InterpolationContext f = Text -> f Text
- parse' :: Text -> Either (ParseErrorBundle Text Void) [Inline]
- parseInlines :: Parser [Inline]
Documentation
parseExpr :: Text -> Either (ParseErrorBundle Text Void) Expr Source #
We expose the expression parser for development:
Parse.parseExpr "1 + 2 * a"
parserTextInclude :: Text -> Block Source #
A parser to convert the content of an include
d to Syntax
. The
behavior w.r.t. to newlines should be the same as having each line
directly preceded by a |
in the including file.
The InterpolationContext
type
type InterpolationContext f = Text -> f Text Source #
Basic interface
parse' :: Text -> Either (ParseErrorBundle Text Void) [Inline] Source #
Create a template from a template string. A malformed template
string will cause parse
to return a parse error.
parseInlines :: Parser [Inline] Source #