Portability | ghc |
---|---|
Stability | experimental |
Maintainer | bjpop@csse.unimelb.edu.au |
A parser for Python version 3 programs. Parsers are provided for modules, statements, and expressions.
See:
- http://docs.python.org/dev/3.0/reference/index.html for an overview of the language.
- http://docs.python.org/dev/3.0/reference/grammar.html for the full grammar.
- http://docs.python.org/dev/3.0/reference/toplevel_components.html for a description of the various Python top-levels, which correspond to the parsers provided here.
- parseModule :: String -> String -> Either ParseError Module
- parseStmt :: String -> String -> Either ParseError [Statement]
- parseExpr :: String -> String -> Either ParseError Expr
- newtype ParseError = ParseError ([String], SrcLocation)
Parsing modules
:: String | The input stream (python module source code). |
-> String | The name of the python source (filename or input device). |
-> Either ParseError Module | An error or the abstract syntax tree (AST) of the python module. |
Parse a whole Python source file.
Parsing statements
:: String | The input stream (python statement source code). |
-> String | The name of the python source (filename or input device). |
-> Either ParseError [Statement] | An error or maybe the abstract syntax tree (AST) of zero or more python statements. |
Parse one compound statement, or a sequence of simple statements. Generally used for interactive input, such as from the command line of an interpreter.
Parsing expressions
:: String | The input stream (python statement source code). |
-> String | The name of the python source (filename or input device). |
-> Either ParseError Expr | An error or maybe the abstract syntax tree (AST) of the python expression. |
Parse an expression. Generally used as input for the 'eval' primitive.
Parse errors
newtype ParseError Source
Parse error. A list of error messages and a source location.
ParseError ([String], SrcLocation) |