File tree Expand file tree Collapse file tree
src/Language/Python/Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414module Language.Python.Common.LexerUtils where
1515
1616import Control.Monad (liftM )
17- import Control.Monad.Error.Class (throwError )
1817import Data.List (foldl' )
1918import Data.Word (Word8 )
2019import Language.Python.Common.Token as Token
Original file line number Diff line number Diff line change @@ -14,14 +14,9 @@ module Language.Python.Common.ParseError ( ParseError (..) ) where
1414
1515import Language.Python.Common.SrcLocation (SrcLocation )
1616import Language.Python.Common.Token (Token )
17- import Control.Monad.Error.Class
1817
1918data ParseError
2019 = UnexpectedToken Token -- ^ An error from the parser. Token found where it should not be. Note: tokens contain their own source span.
2120 | UnexpectedChar Char SrcLocation -- ^ An error from the lexer. Character found where it should not be.
2221 | StrError String -- ^ A generic error containing a string message. No source location.
2322 deriving (Eq , Ord , Show )
24-
25- instance Error ParseError where
26- noMsg = StrError " "
27- strMsg = StrError
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ module Language.Python.Common.ParserMonad
4343 , addComment
4444 , getComments
4545 , spanError
46+ , throwError
4647 ) where
4748
4849import Language.Python.Common.SrcLocation (SrcLocation (.. ), SrcSpan (.. ), Span (.. ))
@@ -51,7 +52,6 @@ import Language.Python.Common.ParseError (ParseError (..))
5152import Control.Applicative ((<$>) )
5253import Control.Monad.State.Class
5354import Control.Monad.State.Strict as State
54- import Control.Monad.Error as Error
5555import Language.Python.Common.Pretty
5656
5757internalError :: String -> P a
@@ -91,6 +91,9 @@ initialState initLoc inp scStack
9191
9292type P a = StateT ParseState (Either ParseError ) a
9393
94+ throwError :: ParseError -> P a
95+ throwError = lift . Left
96+
9497execParser :: P a -> ParseState -> Either ParseError a
9598execParser = evalStateT
9699
Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ module Language.Python.Common.ParserUtils where
1515
1616import Data.List (foldl' )
1717import Data.Maybe (isJust )
18- import Control.Monad.Error.Class (throwError )
1918import Language.Python.Common.AST as AST
2019import Language.Python.Common.Token as Token
2120import Language.Python.Common.ParserMonad hiding (location )
You can’t perform that action at this time.
0 commit comments