Copyright | (c) Henry J. Wylde, 2015 |
---|---|
License | BSD3 |
Maintainer | public@hjwylde.com |
Safe Haskell | None |
Language | Haskell2010 |
A Text.Parsec indentation-based parser for generating a Program
.
- type Parser a = ParsecT String () (State SourcePos) a
- data ParseError :: *
- data SourcePos :: *
- sourceName :: SourcePos -> SourceName
- sourceLine :: SourcePos -> Line
- sourceColumn :: SourcePos -> Column
- parse :: Parser a -> SourceName -> String -> Except ParseError a
- program :: Parser (Program SourcePos)
- decl :: Parser (Decl SourcePos)
- stmt :: Parser (Stmt SourcePos)
- expr :: Parser (Expr SourcePos)
- value :: Parser Value
- type_ :: Parser (Type SourcePos)
Types
type Parser a = ParsecT String () (State SourcePos) a Source
A ParsecT
that retains indentation information.
data ParseError :: *
data SourcePos :: *
sourceName :: SourcePos -> SourceName
Extracts the name of the source from a source position.
sourceLine :: SourcePos -> Line
Extracts the line number from a source position.
sourceColumn :: SourcePos -> Column
Extracts the column number from a source position.
Parsing
parse :: Parser a -> SourceName -> String -> Except ParseError a Source
parse parser sourceName input
parses input
using parser
.
Returns either a ParseError
or a
.
This method wraps runParserT
by running the indentation resolver over the parser's state.