X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fparser%2FLexer.x;h=2f2210619b796b9712df4494df36983a97614f5e;hp=b74a73262c826da46a113f09137d65c728fb3df9;hb=beea3d146a69be0986d8783c3de2864f62a88c79;hpb=3e7f0e7001f6506ca9e9dc8f77a5626bd7a47e11 diff --git a/compiler/parser/Lexer.x b/compiler/parser/Lexer.x index b74a732..2f22106 100644 --- a/compiler/parser/Lexer.x +++ b/compiler/parser/Lexer.x @@ -258,7 +258,10 @@ $tab+ { warn Opt_WarnTabs (text "Tab character") } "{-#" $whitechar* (CORE|core) { token ITcore_prag } "{-#" $whitechar* (UNPACK|unpack) { token ITunpack_prag } - "{-#" { nested_comment lexToken } + -- We ignore all these pragmas, but don't generate a warning for them + -- CFILES is a hugs-only thing. + "{-#" $whitechar* (OPTIONS_HUGS|options_hugs|OPTIONS_NHC98|options_nhc98|OPTIONS_JHC|options_jhc|CFILES|cfiles) + { nested_comment lexToken } -- ToDo: should only be valid inside a pragma: "#-}" { token ITclose_prag} @@ -276,12 +279,18 @@ $tab+ { warn Opt_WarnTabs (text "Tab character") } } <0> { + -- In the "0" mode we ignore these pragmas + "{-#" $whitechar* (OPTIONS|options|OPTIONS_GHC|options_ghc|OPTIONS_HADDOCK|options_haddock|LANGUAGE|language|INCLUDE|include) + { nested_comment lexToken } +} + +<0> { "-- #" .* ; } <0,option_prags> { - -- This is to catch things like {-# OPTIONS OPTIONS_HUGS ... - "{-#" $whitechar* $idchar+ { nested_comment lexToken } + "{-#" { warnThen Opt_WarnUnrecognisedPragmas (text "Unrecognised pragma") + (nested_comment lexToken) } } -- '0' state: ordinary lexemes @@ -1378,6 +1387,11 @@ warn option warning srcspan _buf _len = do addWarning option srcspan warning lexToken +warnThen :: DynFlag -> SDoc -> Action -> Action +warnThen option warning action srcspan buf len = do + addWarning option srcspan warning + action srcspan buf len + -- ----------------------------------------------------------------------------- -- The Parse Monad