Copyright | (C) CSIRO 2017-2019 |
---|---|
License | BSD3 |
Maintainer | Isaac Elliott <isaace71295@gmail.com> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type Parser = Parsec Void PyTokens
- runParser :: AsParseError e (PyToken SrcInfo) => FilePath -> Parser a -> [PyToken SrcInfo] -> Either e a
- newtype PyTokens = PyTokens {
- unPyTokens :: [PyToken SrcInfo]
- class AsParseError s t | s -> t where
- unsafeFromParseError :: (HasCallStack, AsParseError s t) => ParseError t e -> s
- token :: MonadParsec e PyTokens m => m Whitespace -> (PyToken SrcInfo -> Bool) -> String -> m (PyToken SrcInfo, [Whitespace])
- at :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, At)
- colon :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Colon)
- comma :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Comma)
- dot :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Dot)
- doubleStar :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, [Whitespace])
- equals :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Equals)
- rightParen :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, [Whitespace])
- semicolon :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Semicolon SrcInfo)
- star :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, [Whitespace])
- identifier :: MonadParsec e PyTokens m => m Whitespace -> m (Ident '[] SrcInfo)
- bool :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- none :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- ellipsis :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- integer :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- float :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- imag :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- stringOrBytes :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- arg :: MonadParsec e PyTokens m => m (Arg SrcInfo)
- binOp :: MonadParsec e PyTokens m => m (BinOp SrcInfo) -> m (Expr SrcInfo) -> m (Expr SrcInfo)
- commaSep :: MonadParsec e PyTokens m => m Whitespace -> m a -> m (CommaSep a)
- commaSep1 :: MonadParsec e PyTokens m => m Whitespace -> m a -> m (CommaSep1 a)
- commaSep1' :: MonadParsec e PyTokens m => m Whitespace -> m a -> m (CommaSep1' a)
- commaSepRest :: MonadParsec e PyTokens m => m b -> m ([(Comma, b)], Maybe Comma)
- compIf :: MonadParsec e PyTokens m => m (CompIf SrcInfo)
- compFor :: MonadParsec e PyTokens m => m (CompFor SrcInfo)
- compoundStatement :: MonadParsec e PyTokens m => m (Indents SrcInfo) -> Indents SrcInfo -> m (CompoundStatement SrcInfo)
- decorator :: MonadParsec e PyTokens m => Indents SrcInfo -> m (Decorator SrcInfo)
- decoratorValue :: MonadParsec e PyTokens m => m (Expr SrcInfo)
- decorators :: MonadParsec e PyTokens m => m (Indents SrcInfo) -> Indents SrcInfo -> m [Decorator SrcInfo]
- expr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- exprList :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- exprListComp :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- exprNoCond :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- exprComp :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- exprOrStarList :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- lambda :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- lambdaNoCond :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- module_ :: MonadParsec e PyTokens m => m (Module SrcInfo)
- orExpr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- orExprList :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- orTest :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- smallStatement :: MonadParsec e PyTokens m => m (SmallStatement SrcInfo)
- someParams :: MonadParsec e PyTokens m => m (Param SrcInfo) -> m (Param SrcInfo) -> m (Param SrcInfo) -> m (CommaSep (Param SrcInfo))
- simpleStatement :: MonadParsec e PyTokens m => m (SimpleStatement SrcInfo)
- starExpr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- statement :: (Alternative m, MonadParsec e PyTokens m) => m (Indents SrcInfo) -> Indents SrcInfo -> m (Statement SrcInfo)
- suite :: MonadParsec e PyTokens m => m (Suite SrcInfo)
- tpPositional :: MonadParsec e PyTokens m => m (Param SrcInfo)
- tpStar :: MonadParsec e PyTokens m => m (Param SrcInfo)
- tpDoubleStar :: MonadParsec e PyTokens m => m (Param SrcInfo)
- tyAnn :: MonadParsec e PyTokens m => m (Colon, Expr SrcInfo)
- typedParams :: MonadParsec e PyTokens m => m (CommaSep (Param SrcInfo))
- untypedParams :: MonadParsec e PyTokens m => m Whitespace -> m (CommaSep (Param SrcInfo))
- upPositional :: MonadParsec e PyTokens m => m Whitespace -> m (Param SrcInfo)
- upStar :: MonadParsec e PyTokens m => m Whitespace -> m (Param SrcInfo)
- upDoubleStar :: MonadParsec e PyTokens m => m Whitespace -> m (Param SrcInfo)
- yieldExpr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo)
- anySpace :: MonadParsec e PyTokens m => m Whitespace
- space :: MonadParsec e PyTokens m => m Whitespace
- eol :: MonadParsec e PyTokens m => m Newline
- continued :: MonadParsec e PyTokens m => m Whitespace
- newline :: MonadParsec e PyTokens m => m Newline
- indent :: MonadParsec e PyTokens m => m (Indents SrcInfo)
- dedent :: MonadParsec e PyTokens m => m ()
- level :: MonadParsec s PyTokens m => m (Indents SrcInfo)
- blank :: MonadParsec e PyTokens m => m (Blank SrcInfo)
- comment :: MonadParsec e PyTokens m => m (Comment SrcInfo)
- sepBy1' :: MonadParsec e PyTokens m => m a -> m sep -> m (a, [(sep, a)], Maybe sep)
Documentation
:: AsParseError e (PyToken SrcInfo) | |
=> FilePath | File name |
-> Parser a | Parser |
-> [PyToken SrcInfo] | Input to parse |
-> Either e a |
Run a parser on some input
Stream type
PyTokens | |
|
Instances
Errors
class AsParseError s t | s -> t where Source #
Instances
AsParseError (ParseError a) (PyToken a) Source # | |
Defined in Language.Python.Parse.Error |
unsafeFromParseError :: (HasCallStack, AsParseError s t) => ParseError t e -> s Source #
Convert a concrete ParseError
to a value that has an instance of AsParseError
This function is partial because our parser will never use FancyError
Parsers
token :: MonadParsec e PyTokens m => m Whitespace -> (PyToken SrcInfo -> Bool) -> String -> m (PyToken SrcInfo, [Whitespace]) Source #
Symbols
at :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, At) Source #
colon :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Colon) Source #
comma :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Comma) Source #
dot :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Dot) Source #
doubleStar :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, [Whitespace]) Source #
equals :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Equals) Source #
rightParen :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, [Whitespace]) Source #
semicolon :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, Semicolon SrcInfo) Source #
star :: MonadParsec e PyTokens m => m Whitespace -> m (PyToken SrcInfo, [Whitespace]) Source #
Atomic forms
identifier :: MonadParsec e PyTokens m => m Whitespace -> m (Ident '[] SrcInfo) Source #
bool :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
none :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
ellipsis :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
integer :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
float :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
imag :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
stringOrBytes :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
Compound forms
binOp :: MonadParsec e PyTokens m => m (BinOp SrcInfo) -> m (Expr SrcInfo) -> m (Expr SrcInfo) Source #
commaSep :: MonadParsec e PyTokens m => m Whitespace -> m a -> m (CommaSep a) Source #
commaSep1 :: MonadParsec e PyTokens m => m Whitespace -> m a -> m (CommaSep1 a) Source #
commaSep1' :: MonadParsec e PyTokens m => m Whitespace -> m a -> m (CommaSep1' a) Source #
commaSepRest :: MonadParsec e PyTokens m => m b -> m ([(Comma, b)], Maybe Comma) Source #
compoundStatement :: MonadParsec e PyTokens m => m (Indents SrcInfo) -> Indents SrcInfo -> m (CompoundStatement SrcInfo) Source #
decoratorValue :: MonadParsec e PyTokens m => m (Expr SrcInfo) Source #
decorators :: MonadParsec e PyTokens m => m (Indents SrcInfo) -> Indents SrcInfo -> m [Decorator SrcInfo] Source #
expr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
exprList :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
exprListComp :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
exprNoCond :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
exprComp :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
exprOrStarList :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
lambda :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
lambdaNoCond :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
orExpr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
orExprList :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
orTest :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
smallStatement :: MonadParsec e PyTokens m => m (SmallStatement SrcInfo) Source #
someParams :: MonadParsec e PyTokens m => m (Param SrcInfo) -> m (Param SrcInfo) -> m (Param SrcInfo) -> m (CommaSep (Param SrcInfo)) Source #
simpleStatement :: MonadParsec e PyTokens m => m (SimpleStatement SrcInfo) Source #
starExpr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
statement :: (Alternative m, MonadParsec e PyTokens m) => m (Indents SrcInfo) -> Indents SrcInfo -> m (Statement SrcInfo) Source #
tpPositional :: MonadParsec e PyTokens m => m (Param SrcInfo) Source #
tpDoubleStar :: MonadParsec e PyTokens m => m (Param SrcInfo) Source #
typedParams :: MonadParsec e PyTokens m => m (CommaSep (Param SrcInfo)) Source #
untypedParams :: MonadParsec e PyTokens m => m Whitespace -> m (CommaSep (Param SrcInfo)) Source #
upPositional :: MonadParsec e PyTokens m => m Whitespace -> m (Param SrcInfo) Source #
upStar :: MonadParsec e PyTokens m => m Whitespace -> m (Param SrcInfo) Source #
upDoubleStar :: MonadParsec e PyTokens m => m Whitespace -> m (Param SrcInfo) Source #
yieldExpr :: MonadParsec e PyTokens m => m Whitespace -> m (Expr SrcInfo) Source #
Formatting
anySpace :: MonadParsec e PyTokens m => m Whitespace Source #
space :: MonadParsec e PyTokens m => m Whitespace Source #
continued :: MonadParsec e PyTokens m => m Whitespace Source #
dedent :: MonadParsec e PyTokens m => m () Source #