| Copyright | (c) Henry J. Wylde, 2015 |
|---|---|
| License | BSD3 |
| Maintainer | public@hjwylde.com |
| Safe Haskell | None |
| Language | Haskell2010 |
Language.Qux.Annotated.Parser
Description
A Text.Parsec indentation-based parser for generating a Program.
- type Parser a = ParsecT String () (State SourcePos) a
- data ParseError :: *
- parse :: Parser a -> SourceName -> String -> Except ParseError a
- data SourcePos :: *
- sourceName :: SourcePos -> SourceName
- sourceLine :: SourcePos -> Line
- sourceColumn :: SourcePos -> Column
- id_ :: Parser (Id SourcePos)
- program :: Parser (Program SourcePos)
- decl :: Parser (Decl SourcePos)
- stmt :: Parser (Stmt SourcePos)
- expr :: Parser (Expr SourcePos)
- value :: Parser Value
- type_ :: Parser (Type SourcePos)
Parser type
type Parser a = ParsecT String () (State SourcePos) a Source
A ParsecT that retains indentation information.
data ParseError :: *
The abstract data type ParseError represents parse errors. It
provides the source position (SourcePos) of the error
and a list of error messages (Message). A ParseError
can be returned by the function parse. ParseError is an
instance of the Show and Eq classes.
Instances
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.
Source position type
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.