language-python-0.5.6: Parsing and pretty printing of Python code.
Copyright(c) 2009 Bernie Pope
LicenseBSD-style
Maintainerbjpop@csse.unimelb.edu.au
Stabilityexperimental
Portabilityghc
Safe HaskellSafe
LanguageHaskell98

Language.Python.Common.ParserMonad

Description

Monad support for Python parser and lexer.

Documentation

type P a = StateT ParseState (Either ParseError) a Source #

thenP :: P a -> (a -> P b) -> P b Source #

returnP :: a -> P a Source #

getInput :: P String Source #

setInput :: String -> P () Source #

data ParseError Source #

Constructors

UnexpectedToken Token

An error from the parser. Token found where it should not be. Note: tokens contain their own source span.

UnexpectedChar Char SrcLocation

An error from the lexer. Character found where it should not be.

StrError String

A generic error containing a string message. No source location.

Instances

Instances details
Eq ParseError Source # 
Instance details

Defined in Language.Python.Common.ParseError

Methods

(==) :: ParseError -> ParseError -> Bool

(/=) :: ParseError -> ParseError -> Bool

Ord ParseError Source # 
Instance details

Defined in Language.Python.Common.ParseError

Show ParseError Source # 
Instance details

Defined in Language.Python.Common.ParseError

Methods

showsPrec :: Int -> ParseError -> ShowS

show :: ParseError -> String

showList :: [ParseError] -> ShowS

Error ParseError Source # 
Instance details

Defined in Language.Python.Common.ParseError

Methods

noMsg :: ParseError #

strMsg :: String -> ParseError #

Pretty ParseError Source # 
Instance details

Defined in Language.Python.Common.PrettyParseError

Methods

pretty :: ParseError -> Doc Source #

data ParseState Source #

Constructors

ParseState 

Fields

Instances

Instances details
Show ParseState Source # 
Instance details

Defined in Language.Python.Common.ParserMonad

Methods

showsPrec :: Int -> ParseState -> ShowS

show :: ParseState -> String

showList :: [ParseState] -> ShowS

initialState :: SrcLocation -> String -> [Int] -> ParseState Source #

pushStartCode :: Int -> P () Source #

pushIndent :: Int -> P () Source #

getParen :: P (Maybe Token) Source #

spanError :: Span a => a -> String -> P b Source #