Emit a reasonable error message instead of crashing when there's an
unterminated literal-liberal in the source file.
})
-- first, start a new lexeme and lose all the whitespace
})
-- first, start a new lexeme and lose all the whitespace
- = tab line bol atbol (stepOverLexeme buf)
+ = _scc_ "Lexer"
+ tab line bol atbol (stepOverLexeme buf)
where
line = srcLocLine loc
where
line = srcLocLine loc
lexToken :: (Token -> P a) -> Int# -> P a
lexToken cont glaexts buf =
--trace "lexToken" $
lexToken :: (Token -> P a) -> Int# -> P a
lexToken cont glaexts buf =
--trace "lexToken" $
case currentChar# buf of
-- special symbols ----------------------------------------------------
case currentChar# buf of
-- special symbols ----------------------------------------------------
lex_cstring cont buf =
case expandUntilMatch (stepOverLexeme buf) "\'\'" of
lex_cstring cont buf =
case expandUntilMatch (stepOverLexeme buf) "\'\'" of
- buf' -> cont (ITlitlit (lexemeToFastString
+ Just buf' -> cont (ITlitlit (lexemeToFastString
(setCurrentPos# buf' (negateInt# 2#))))
(setCurrentPos# buf' (negateInt# 2#))))
- (mergeLexemes buf buf')
+ (mergeLexemes buf buf')
+ Nothing -> lexError "unterminated ``" buf
------------------------------------------------------------------------------
-- Character Classes
------------------------------------------------------------------------------
-- Character Classes
| otherwise -> (acc,StringBuffer fo l# s# c#)
| otherwise -> (acc,StringBuffer fo l# s# c#)
-expandUntilMatch :: StringBuffer -> String -> StringBuffer
+expandUntilMatch :: StringBuffer -> String -> Maybe StringBuffer
expandUntilMatch (StringBuffer fo l# s# c#) str =
loop c# str
where
expandUntilMatch (StringBuffer fo l# s# c#) str =
loop c# str
where
- loop c# [] = StringBuffer fo l# s# c#
- loop c# ((C# x#):xs)
- | indexCharOffAddr# fo c# `eqChar#` x#
- = loop (c# +# 1#) xs
- | otherwise
- = loop (c# +# 1#) str
+ loop c# [] = Just (StringBuffer fo l# s# c#)
+ loop c# ((C# x#):xs) =
+ case indexCharOffAddr# fo c# of
+ ch# | ch# `eqChar#` '\NUL'# && c# >=# l# -> Nothing
+ | ch# `eqChar#` x# -> loop (c# +# 1#) xs
+ | otherwise -> loop (c# +# 1#) str