X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fparser%2FLexer.x;h=8ef2071b482cbef5c905e599c3f73d3222106f7a;hb=33989e6eb745ca9d54ba638bc89bec7660cba4be;hp=5015ca7059d40e00118eb1175a0dcca1cd14c422;hpb=543a890b3de87c2535072c894035996661bf106c;p=ghc-hetmet.git diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index 5015ca7..8ef2071 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -216,6 +216,11 @@ $white_no_nl+ ; "{-#" $whitechar* (INCLUDE|include) { lex_string_prag ITinclude_prag } } +<0,option_prags,glaexts> { + -- This is to catch things like {-# OPTIONS OPTIONS_HUGS ... + "{-#" $whitechar* $idchar+ { nested_comment } +} + -- '0' state: ordinary lexemes -- 'glaexts' state: glasgow extensions (postfix '#', etc.) @@ -1445,15 +1450,13 @@ lexToken = do span `seq` setLastToken span bytes t span buf bytes --- ToDo: Alex reports the buffer at the start of the erroneous lexeme, --- but it would be more informative to report the location where the --- error was actually discovered, especially if this is a decoding --- error. -reportLexError loc1 loc2 buf str = +reportLexError loc1 loc2 buf str + | atEnd buf = failLocMsgP loc1 loc2 (str ++ " at end of input") + | otherwise = let c = fst (nextChar buf) in if c == '\0' -- decoding errors are mapped to '\0', see utf8DecodeChar# - then failLocMsgP loc2 loc2 "UTF-8 decoding error" + then failLocMsgP loc2 loc2 (str ++ " (UTF-8 decoding error)") else failLocMsgP loc1 loc2 (str ++ " at character " ++ show c) }