[project @ 2004-02-24 10:34:21 by simonmar]
[ghc-hetmet.git] / ghc / compiler / parser / Lexer.x
index 05537a9..2d01a18 100644 (file)
@@ -108,7 +108,8 @@ $white_no_nl+                               ;
 -- have to exclude those.
 -- The regex says: "munch all the characters after the dashes, as long as
 -- the first one is not a symbol".
-"--"\-* ([^$symbol] .*)?               ;
+"--"\-* [^$symbol] .*                  ;
+"--"\-* / { atEOL }                    ;
 
 -- 'bol' state: beginning of a line.  Slurp up all the whitespace (including
 -- blank lines) until we find a non-whitespace character, then do layout
@@ -159,7 +160,9 @@ $white_no_nl+                               ;
 --    {-# LINE <line> "<file>" #-}
 <line_prag2> $digit+                   { set_line line_prag2a }
 <line_prag2a> \" [$graphic \ ]* \"     { set_file line_prag2b }
-<line_prag2b> "#-}"                    { pop }
+<line_prag2b> "#-}"|"-}"               { pop }
+   -- NOTE: accept -} at the end of a LINE pragma, for compatibility
+   -- with older versions of GHC which generated these.
 
 <0,glaexts> {
   "{-#" $whitechar* (SPECIALI[SZ]E|speciali[sz]e)
@@ -580,6 +583,8 @@ notFollowedBy char _ _ _ (_,buf) = atEnd buf || currentChar buf /= char
 notFollowedBySymbol _ _ _ (_,buf)
   = atEnd buf || currentChar buf `notElem` "!#$%&*+./<=>?@\\^|-~"
 
+atEOL _ _ _ (_,buf) = atEnd buf || currentChar buf == '\n'
+
 ifExtension pred bits _ _ _ = pred bits
 
 {-