License | BSD3 |
---|---|
Maintainer | The Idris Community. |
Safe Haskell | None |
Language | Haskell2010 |
- type Parser s = StateT s (WriterT FC (Parsec Void String))
- type Parsing m = (MonadParsec Void String m, MonadWriter FC m)
- runparser :: Parser st res -> st -> String -> String -> Either ParseError res
- data ParseError
- prettyError :: ParseError -> String
- type Mark = State String
- mark :: Parsing m => m Mark
- restore :: Parsing m => Mark -> m ()
- getFC :: Parsing m => m FC
- addExtent :: MonadWriter FC m => FC -> m ()
- trackExtent :: Parsing m => m a -> m a
- extent :: MonadWriter FC m => m a -> m FC
- withExtent :: MonadWriter FC m => m a -> m (a, FC)
- appExtent :: MonadWriter FC m => m (FC -> a) -> m a
Parsing
type Parser s = StateT s (WriterT FC (Parsec Void String)) Source #
Our parser stack with state of type s
type Parsing m = (MonadParsec Void String m, MonadWriter FC m) Source #
A constraint for parsing without state
runparser :: Parser st res -> st -> String -> String -> Either ParseError res Source #
Run the Idris parser stack
Parse errors
data ParseError Source #
prettyError :: ParseError -> String Source #
A fully formatted parse error, with caret and bar, etc.
Mark and restore
mark :: Parsing m => m Mark Source #
Retrieve the parser state so we can restart from this point later.
Tracking the extent of productions
getFC :: Parsing m => m FC Source #
Get the current parse position.
This is useful when the position is needed in a way unrelated to the
heirarchy of parsers. Prefer using withExtent
and friends.
addExtent :: MonadWriter FC m => FC -> m () Source #
Add an extent (widen) our current parsing context.
trackExtent :: Parsing m => m a -> m a Source #
Run a parser and track its extent.
Wrap bare Megaparsec parsers with this to make them "visible" in error
messages. Do not wrap whitespace or comment parsers. If you find an
extent is taking trailing whitespace, it's likely there's a double-wrapped
parser (usually via Idris.Parser.Helpers.token
).
extent :: MonadWriter FC m => m a -> m FC Source #
Run a parser, discard its value, and return its extent.
withExtent :: MonadWriter FC m => m a -> m (a, FC) Source #
Run a parser and return its value and extent.