[project @ 2000-03-08 22:05:43 by andy]
[ghc-hetmet.git] / ghc / interpreter / input.c
index 501b5c7..0bbc280 100644 (file)
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: input.c,v $
- * $Revision: 1.15 $
- * $Date: 1999/12/01 11:50:34 $
+ * $Revision: 1.18 $
+ * $Date: 1999/12/10 15:59:45 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
@@ -121,7 +121,7 @@ static Void local skipWhitespace  Args((Void));
 static Int  local yylex           Args((Void));
 static Int  local repeatLast      Args((Void));
 
-static Void local parseInput      Args((Int));
+static Cell local parseInput      Args((Int));
 
 static Bool local doesNotExceed   Args((String,Int,Int));
 static Int  local stringToInt     Args((String,Int));
@@ -147,7 +147,7 @@ static Text textWildcard;
 static Text textModule,  textImport,    textInterface,  textInstImport;
 static Text textHiding,  textQualified, textAsMod;
 static Text textExport,  textDynamic,   textUUExport;
-static Text textUnsafe,  textUUAll;
+static Text textUnsafe,  textUUAll,     textUUUsage;
 
 Text   textCcall;                       /* ccall                           */
 Text   textStdcall;                     /* stdcall                         */
@@ -253,7 +253,7 @@ static Void local initCharTab() {       /* Initialize char decode table    */
  *
  * At the lowest level of input, characters are read one at a time, with the
  * current character held in c0 and the following (lookahead) character in
- * c1.  The corrdinates of c0 within the file are held in (column,row).
+ * c1.  The coordinates of c0 within the file are held in (column,row).
  * The input stream is advanced by one character using the skip() function.
  * ------------------------------------------------------------------------*/
 
@@ -1400,6 +1400,11 @@ static Int local yylex() {             /* Read next input token ...        */
      * Now try to identify token type:
      * --------------------------------------------------------------------*/
 
+    if (readingInterface) {
+       if (c0 == '(' && c1 == '#') { skip(); skip(); return UTL; };
+       if (c0 == '#' && c1 == ')') { skip(); skip(); return UTR; };
+    }
+
     switch (c0) {
         case EOF  : return 0;                   /* End of file/input       */
 
@@ -1522,6 +1527,7 @@ static Int local yylex() {             /* Read next input token ...        */
        if (it==textDlet && !haskell98) lookAhead(DLET);
 #endif
         if (it==textUUAll)             return ALL;
+        if (it==textUUUsage)           return UUUSAGE;
         if (it==textRepeat && reading==KEYBOARD)
             return repeatLast();
 
@@ -1589,9 +1595,10 @@ Name n; {
  * main entry points to parser/lexer:
  * ------------------------------------------------------------------------*/
 
-static Void local parseInput(startWith)/* Parse input with given first tok,*/
+static Cell local parseInput(startWith)/* Parse input with given first tok,*/
 Int startWith; {                       /* determining whether to read a    */
-    firstToken   = TRUE;               /* script or an expression          */
+    Cell final   = NIL;                /* script or an expression          */
+    firstToken   = TRUE;
     firstTokenIs = startWith;
     if (startWith==INTERFACE) {
        offsideON = FALSE; readingInterface = TRUE; 
@@ -1604,9 +1611,10 @@ Int startWith; {                       /* determining whether to read a    */
         ERRMSG(row) "Parser overflow"  /* as all syntax errors are caught  */
         EEND;                          /* in the parser...                 */
     }
-    drop();
+    final = pop();
     if (!stackEmpty())                 /* stack should now be empty        */
         internal("parseInput");
+    return final;
 }
 
 #ifdef HSCRIPT
@@ -1669,12 +1677,12 @@ Void parseContext() {                  /* Read a context to prove   */
 }
 #endif
 
-Void parseInterface(nm,len)            /* Read a GHC interface file        */
+Cell parseInterface(nm,len)            /* Read a GHC interface file        */
 String nm;
 Long   len; {                          /* Used to set a target for reading */
-    input(RESET);
-    fileInput(nm,len);
-    parseInput(INTERFACE);
+   input(RESET);
+   fileInput(nm,len);
+   return parseInput(INTERFACE);
 }
 
 
@@ -1685,7 +1693,9 @@ Long   len; {                          /* Used to set a target for reading */
 Void input(what)
 Int what; {
     switch (what) {
-        case INSTALL : initCharTab();
+        case POSTPREL: break;
+
+        case PREPREL : initCharTab();
                        textCase       = findText("case");
                        textOfK        = findText("of");
                        textData       = findText("data");
@@ -1742,6 +1752,7 @@ Int what; {
                        textWildcard   = findText("_");
                        textAll        = findText("forall");
                        textUUAll      = findText("__forall");
+                       textUUUsage    = findText("__u");
                        varMinus       = mkVar(textMinus);
                        varPlus        = mkVar(textPlus);
                        varBang        = mkVar(textBang);
@@ -1763,7 +1774,6 @@ Int what; {
                        instDefns    = NIL;
                        selDefns     = NIL;
                        genDefns     = NIL;
-                       //primDefns    = NIL;
                        unqualImports= NIL;
                        foreignImports= NIL;
                        foreignExports= NIL;
@@ -1785,7 +1795,6 @@ Int what; {
                        mark(instDefns);
                        mark(selDefns);
                        mark(genDefns);
-                       //mark(primDefns);
                        mark(unqualImports);
                        mark(foreignImports);
                        mark(foreignExports);