diff options
Diffstat (limited to 'src/Xeno/SAX.hs')
-rw-r--r-- | src/Xeno/SAX.hs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/Xeno/SAX.hs b/src/Xeno/SAX.hs index f61b46d..9580766 100644 --- a/src/Xeno/SAX.hs +++ b/src/Xeno/SAX.hs @@ -20,7 +20,6 @@ import qualified Data.ByteString as S import qualified Data.ByteString.Char8 as S8 import qualified Data.ByteString.Unsafe as SU import Data.Functor.Identity -import Data.Monoid import Data.Word import Xeno.Types @@ -148,7 +147,7 @@ process openF attrF endOpenF textF closeF cdataF str = findLT 0 this = S.drop index str findCommentEnd index = case elemIndexFrom commentChar str index of - Nothing -> throw (XenoParseError "Couldn't find the closing comment dash.") + Nothing -> throw $ XenoParseError index "Couldn't find the closing comment dash." Just fromDash -> if s_index this 0 == commentChar && s_index this 1 == closeTagChar then findLT (fromDash + 2) @@ -156,7 +155,7 @@ process openF attrF endOpenF textF closeF cdataF str = findLT 0 where this = S.drop index str findCDataEnd cdata_start index = case elemIndexFrom closeAngleBracketChar str index of - Nothing -> throw (XenoParseError "Couldn't find closing angle bracket for CDATA.") + Nothing -> throw $ XenoParseError index "Couldn't find closing angle bracket for CDATA." Just fromCloseAngleBracket -> if s_index str (fromCloseAngleBracket + 1) == closeAngleBracketChar then do @@ -169,7 +168,7 @@ process openF attrF endOpenF textF closeF cdataF str = findLT 0 let spaceOrCloseTag = parseName str index in if | s_index str index0 == questionChar -> case elemIndexFrom closeTagChar str spaceOrCloseTag of - Nothing -> throw (XenoParseError "Couldn't find the end of the tag.") + Nothing -> throw $ XenoParseError index "Couldn't find the end of the tag." Just fromGt -> do findLT (fromGt + 1) | s_index str spaceOrCloseTag == closeTagChar -> @@ -212,7 +211,8 @@ process openF attrF endOpenF textF closeF cdataF str = findLT 0 str (quoteIndex + 1) of Nothing -> - throw (XenoParseError "Couldn't find the matching quote character.") + throw + (XenoParseError index "Couldn't find the matching quote character.") Just endQuoteIndex -> do attrF (substring str index afterAttrName) @@ -221,8 +221,9 @@ process openF attrF endOpenF textF closeF cdataF str = findLT 0 (quoteIndex + 1) (endQuoteIndex)) findAttributes (endQuoteIndex + 1) - else throw (XenoParseError ("Expected ' or \", got: " <> S.singleton usedChar)) - else throw (XenoParseError ("Expected =, got: " <> S.singleton (s_index str afterAttrName) <> " at character index: " <> (S8.pack . show) afterAttrName)) + else throw + (XenoParseError index("Expected ' or \", got: " <> S.singleton usedChar)) + else throw (XenoParseError index ("Expected =, got: " <> S.singleton (s_index str afterAttrName) <> " at character index: " <> (S8.pack . show) afterAttrName)) where index = skipSpaces str index0 {-# INLINE process #-} @@ -249,8 +250,8 @@ process openF attrF endOpenF textF closeF cdataF str = findLT 0 -- | /O(1)/ 'ByteString' index (subscript) operator, starting from 0. s_index :: ByteString -> Int -> Word8 s_index ps n - | n < 0 = throw XenoStringIndexProblem - | n >= S.length ps = throw XenoStringIndexProblem + | n < 0 = throw (XenoStringIndexProblem n ps) + | n >= S.length ps = throw (XenoStringIndexProblem n ps) | otherwise = ps `SU.unsafeIndex` n {-# INLINE s_index #-} |