Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to using just Either instead of Error. #48

merged 1 commit into from Jul 10, 2019
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

@@ -14,7 +14,6 @@
module Language.Python.Common.LexerUtils where

import Control.Monad (liftM)
import Control.Monad.Error.Class (throwError)
import Data.List (foldl')
import Data.Word (Word8)
import Language.Python.Common.Token as Token
@@ -14,14 +14,9 @@ module Language.Python.Common.ParseError ( ParseError (..) ) where

import Language.Python.Common.SrcLocation (SrcLocation)
import Language.Python.Common.Token (Token)
import Control.Monad.Error.Class

data ParseError
= 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.
deriving (Eq, Ord, Show)

instance Error ParseError where
noMsg = StrError ""
strMsg = StrError
@@ -43,6 +43,7 @@ module Language.Python.Common.ParserMonad
, addComment
, getComments
, spanError
, throwError
) where

import Language.Python.Common.SrcLocation (SrcLocation (..), SrcSpan (..), Span (..))
@@ -51,7 +52,6 @@ import Language.Python.Common.ParseError (ParseError (..))
import Control.Applicative ((<$>))
import Control.Monad.State.Class
import Control.Monad.State.Strict as State
import Control.Monad.Error as Error
import Language.Python.Common.Pretty

internalError :: String -> P a
@@ -91,6 +91,9 @@ initialState initLoc inp scStack

type P a = StateT ParseState (Either ParseError) a

throwError :: ParseError -> P a
throwError = lift . Left

execParser :: P a -> ParseState -> Either ParseError a
execParser = evalStateT

@@ -15,7 +15,6 @@ module Language.Python.Common.ParserUtils where

import Data.List (foldl')
import Data.Maybe (isJust)
import Control.Monad.Error.Class (throwError)
import Language.Python.Common.AST as AST
import Language.Python.Common.Token as Token
import Language.Python.Common.ParserMonad hiding (location)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.