[project @ 2001-01-30 12:13:34 by simonmar]
[ghc-hetmet.git] / ghc / compiler / parser / Lex.lhs
index def163d..62d1e5e 100644 (file)
@@ -16,7 +16,7 @@ An example that provokes the error is
 --------------------------------------------------------
 
 \begin{code}
-
+{-# OPTIONS -#include "hs_ctype.h" #-}
 module Lex (
 
        ifaceParseErr, srcParseErr,
@@ -110,7 +110,7 @@ data Token
   | ITthen
   | ITtype
   | ITwhere
-  | ITscc
+  | ITscc                      -- ToDo: remove (we use {-# SCC "..." #-} now)
 
   | ITforall                   -- GHC extension keywords
   | ITforeign
@@ -123,7 +123,6 @@ data Token
   | ITccallconv
 
   | ITinterface                        -- interface keywords
-  | ITexpr
   | IT__export
   | ITdepends
   | IT__forall
@@ -165,6 +164,7 @@ data Token
   | ITrules_prag
   | ITdeprecated_prag
   | ITline_prag
+  | ITscc_prag
   | ITclose_prag
 
   | ITdotdot                   -- reserved symbols
@@ -244,6 +244,7 @@ pragmaKeywordsFM = listToUFM $
        ( "LINE",       ITline_prag ),
        ( "RULES",      ITrules_prag ),
        ( "RULEZ",      ITrules_prag ), -- american spelling :-)
+       ( "SCC",        ITscc_prag ),
        ( "DEPRECATED", ITdeprecated_prag )
        ]
 
@@ -274,7 +275,7 @@ haskellKeywordsFM = listToUFM $
        ( "then",       ITthen ),     
        ( "type",       ITtype ),     
        ( "where",      ITwhere ),
-       ( "_scc_",      ITscc )
+       ( "_scc_",      ITscc )         -- ToDo: remove
      ]
 
 isSpecial :: Token -> Bool
@@ -313,7 +314,6 @@ ghcExtensionKeywordsFM = listToUFM $
 
        -- interface keywords
         ("__interface",                ITinterface),
-        ("__expr",             ITexpr),
        ("__export",            IT__export),
        ("__depends",           ITdepends),
        ("__forall",            IT__forall),
@@ -448,7 +448,11 @@ lexer cont buf s@(PState{
 
                -- special GHC extension: we grok cpp-style #line pragmas
            '#'# | lexemeIndex buf ==# bol ->   -- the '#' must be in column 0
-               line_prag next_line (stepOn buf) s'
+               case expandWhile# is_space (stepOn buf) of { buf1 ->
+               if is_digit (currentChar# buf1) 
+                       then line_prag next_line buf1 s'
+                       else is_a_token
+               }
                where
                next_line buf = lexer cont (stepOnUntilChar# buf '\n'#)