1----------------------------------------------------------------------------- 2-- | 3-- Module : Language.JavaScript.ParseError 4-- Based on language-python version by Bernie Pope 5-- Copyright : (c) 2009 Bernie Pope 6-- License : BSD-style 7-- Stability : experimental 8-- Portability : ghc 9-- 10-- Error values for the lexer and parser. 11----------------------------------------------------------------------------- 12 13module Language.JavaScript.Parser.ParseError 14 ( Error (..) 15 , ParseError (..) 16 ) where 17 18--import Language.JavaScript.Parser.Pretty 19-- import Control.Monad.Error.Class -- Control.Monad.Trans.Except 20import Language.JavaScript.Parser.Lexer 21import Language.JavaScript.Parser.SrcLocation (TokenPosn) 22-- import Language.JavaScript.Parser.Token (Token) 23 24data ParseError 25 = UnexpectedToken Token 26 -- ^ An error from the parser. Token found where it should not be. 27 -- Note: tokens contain their own source span. 28 | UnexpectedChar Char TokenPosn 29 -- ^ An error from the lexer. Character found where it should not be. 30 | StrError String 31 -- ^ A generic error containing a string message. No source location. 32 deriving (Eq, {- Ord,-} Show) 33 34class Error a where 35 -- | Creates an exception without a message. 36 -- The default implementation is @'strMsg' \"\"@. 37 noMsg :: a 38 -- | Creates an exception with a message. 39 -- The default implementation of @'strMsg' s@ is 'noMsg'. 40 strMsg :: String -> a 41 42instance Error ParseError where 43 noMsg = StrError "" 44 strMsg = StrError 45 46