hpython-0.3: Python language tools

Safe HaskellNone
LanguageHaskell2010

Language.Python.Parse.Error

Contents

Synopsis

Documentation

data ParseError a Source #

Constructors

LexicalError (NonEmpty SourcePos) (Maybe (ErrorItem Char)) (Set (ErrorItem Char))

An error occured during tokenization (this is a re-packed megaparsec error)

ParseError (NonEmpty SourcePos) (Maybe (ErrorItem (PyToken a))) (Set (ErrorItem (PyToken a)))

An error occured during parsing (this is a re-packed megaparsec error)

TabError a

Tabs and spaces were used inconsistently

IncorrectDedent a

The dedent at the end of a block doesn't match and preceding indents

e.g.

def a():
    if b:
        pass
    else:
        pass
  pass

The final line will cause an IncorrectDedent error

InvalidUnpacking a

Unpacking ( *value ) was used in an invalid position

Classy Prisms

class AsTabError s a | s -> a where Source #

Methods

_TabError :: Prism' s a Source #

class AsIncorrectDedent s a | s -> a where Source #

Instances
AsIncorrectDedent (ParseError a) a Source # 
Instance details

Defined in Language.Python.Parse.Error

class AsIRError s a | s -> a where Source #

Instances
AsIRError (ParseError a) a Source # 
Instance details

Defined in Language.Python.Parse.Error

Megaparsec re-exports

data ErrorItem t #

Data type that is used to represent “unexpected/expected” items in ParseError. The data type is parametrized over the token type t.

Since: megaparsec-5.0.0

Constructors

Tokens (NonEmpty t)

Non-empty stream of tokens

Label (NonEmpty Char)

Label (cannot be empty)

EndOfInput

End of input

Instances
Functor ErrorItem 
Instance details

Defined in Text.Megaparsec.Error

Methods

fmap :: (a -> b) -> ErrorItem a -> ErrorItem b #

(<$) :: a -> ErrorItem b -> ErrorItem a #

Eq t => Eq (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Methods

(==) :: ErrorItem t -> ErrorItem t -> Bool #

(/=) :: ErrorItem t -> ErrorItem t -> Bool #

Data t => Data (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ErrorItem t -> c (ErrorItem t) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ErrorItem t) #

toConstr :: ErrorItem t -> Constr #

dataTypeOf :: ErrorItem t -> DataType #

dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (ErrorItem t)) #

dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (ErrorItem t)) #

gmapT :: (forall b. Data b => b -> b) -> ErrorItem t -> ErrorItem t #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ErrorItem t -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ErrorItem t -> r #

gmapQ :: (forall d. Data d => d -> u) -> ErrorItem t -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ErrorItem t -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ErrorItem t -> m (ErrorItem t) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ErrorItem t -> m (ErrorItem t) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ErrorItem t -> m (ErrorItem t) #

Ord t => Ord (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Read t => Read (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Show t => Show (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Generic (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Associated Types

type Rep (ErrorItem t) :: Type -> Type #

Methods

from :: ErrorItem t -> Rep (ErrorItem t) x #

to :: Rep (ErrorItem t) x -> ErrorItem t #

NFData t => NFData (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

Methods

rnf :: ErrorItem t -> () #

(Ord t, ShowToken t) => ShowErrorComponent (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

type Rep (ErrorItem t) 
Instance details

Defined in Text.Megaparsec.Error

type Rep (ErrorItem t) = D1 (MetaData "ErrorItem" "Text.Megaparsec.Error" "megaparsec-6.5.0-d919d8e9b2d559a41469a5f4cb583e9cc78df1a606e6731f314f6df926990c52" False) (C1 (MetaCons "Tokens" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NonEmpty t))) :+: (C1 (MetaCons "Label" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (NonEmpty Char))) :+: C1 (MetaCons "EndOfInput" PrefixI False) (U1 :: Type -> Type)))

data SourcePos #

The data type SourcePos represents source positions. It contains the name of the source file, a line number, and a column number. Source line and column positions change intensively during parsing, so we need to make them strict to avoid memory leaks.

Constructors

SourcePos 

Fields

Instances
Eq SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Data SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SourcePos -> c SourcePos #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SourcePos #

toConstr :: SourcePos -> Constr #

dataTypeOf :: SourcePos -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SourcePos) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SourcePos) #

gmapT :: (forall b. Data b => b -> b) -> SourcePos -> SourcePos #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SourcePos -> r #

gmapQ :: (forall d. Data d => d -> u) -> SourcePos -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SourcePos -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SourcePos -> m SourcePos #

Ord SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Read SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Show SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Generic SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Associated Types

type Rep SourcePos :: Type -> Type #

NFData SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

Methods

rnf :: SourcePos -> () #

type Rep SourcePos 
Instance details

Defined in Text.Megaparsec.Pos

type Rep SourcePos = D1 (MetaData "SourcePos" "Text.Megaparsec.Pos" "megaparsec-6.5.0-d919d8e9b2d559a41469a5f4cb583e9cc78df1a606e6731f314f6df926990c52" False) (C1 (MetaCons "SourcePos" PrefixI True) (S1 (MetaSel (Just "sourceName") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 FilePath) :*: (S1 (MetaSel (Just "sourceLine") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Pos) :*: S1 (MetaSel (Just "sourceColumn") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Pos))))