[project @ 1999-06-28 16:42:22 by simonmar]
[ghc-hetmet.git] / ghc / compiler / parser / Lex.lhs
index 727039c..d705043 100644 (file)
@@ -96,13 +96,15 @@ Laziness, you know it makes sense :-)
 
 \begin{code}
 data Token
-  = ITcase                     -- Haskell keywords
+  = ITas                       -- Haskell keywords
+  | ITcase
   | ITclass
   | ITdata
   | ITdefault
   | ITderiving
   | ITdo
   | ITelse
+  | IThiding
   | ITif
   | ITimport
   | ITin
@@ -114,6 +116,7 @@ data Token
   | ITmodule
   | ITnewtype
   | ITof
+  | ITqualified
   | ITthen
   | ITtype
   | ITwhere
@@ -242,6 +245,7 @@ pragmaKeywordsFM = listToUFM $
 haskellKeywordsFM = listToUFM $
       map (\ (x,y) -> (_PK_ x,y))
        [( "_",         ITunderscore ),
+       ( "as",         ITas ),
        ( "case",       ITcase ),     
        ( "class",      ITclass ),    
        ( "data",       ITdata ),     
@@ -249,6 +253,7 @@ haskellKeywordsFM = listToUFM $
        ( "deriving",   ITderiving ), 
        ( "do",         ITdo ),       
        ( "else",       ITelse ),     
+       ( "hiding",     IThiding ),
        ( "if",         ITif ),       
        ( "import",     ITimport ),   
        ( "in",         ITin ),       
@@ -260,6 +265,7 @@ haskellKeywordsFM = listToUFM $
        ( "module",     ITmodule ),   
        ( "newtype",    ITnewtype ),  
        ( "of",         ITof ),       
+       ( "qualified",  ITqualified ),
        ( "then",       ITthen ),     
        ( "type",       ITtype ),     
        ( "where",      ITwhere ),
@@ -335,10 +341,6 @@ haskellKeySymsFM = listToUFM $
        ,("!",          ITbang)
        ,(".",          ITdot)          -- sadly, for 'forall a . t'
        ]
-
-not_special_op ITminus = False
-not_special_op ITbang  = False
-not_special_op _ = True
 \end{code}
 
 -----------------------------------------------------------------------------
@@ -977,11 +979,9 @@ lex_id3 cont glaexts mod buf just_a_conid
        -- real lexeme is M.<sym>
        new_buf = mergeLexemes buf buf'
      in
-     case lookupUFM haskellKeySymsFM lexeme of {
-       Just kwd_token | not_special_op kwd_token
-                       -> just_a_conid;        -- avoid M.::, but not M.!
-       other -> cont (mk_qvar_token mod lexeme) new_buf
-     }}
+     cont (mk_qvar_token mod lexeme) new_buf
+       -- wrong, but arguably morally right: M... is now a qvarsym
+     }
 
   | otherwise   =
      let 
@@ -1002,6 +1002,8 @@ lex_id3 cont glaexts mod buf just_a_conid
      case _scc_ "Lex.haskellKeyword" lookupUFM haskellKeywordsFM lexeme of {
            Just kwd_token -> just_a_conid; -- avoid M.where etc.
            Nothing        -> is_a_qvarid
+       -- TODO: special ids (as, qualified, hiding) shouldn't be
+       -- recognised as keywords here.  ie.  M.as is a qualified varid.
      }}}