* 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"
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));
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 */
*
* 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.
* ------------------------------------------------------------------------*/
* 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 */
if (it==textDlet && !haskell98) lookAhead(DLET);
#endif
if (it==textUUAll) return ALL;
+ if (it==textUUUsage) return UUUSAGE;
if (it==textRepeat && reading==KEYBOARD)
return repeatLast();
* 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;
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
}
#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);
}
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");
textWildcard = findText("_");
textAll = findText("forall");
textUUAll = findText("__forall");
+ textUUUsage = findText("__u");
varMinus = mkVar(textMinus);
varPlus = mkVar(textPlus);
varBang = mkVar(textBang);
instDefns = NIL;
selDefns = NIL;
genDefns = NIL;
- //primDefns = NIL;
unqualImports= NIL;
foreignImports= NIL;
foreignExports= NIL;
mark(instDefns);
mark(selDefns);
mark(genDefns);
- //mark(primDefns);
mark(unqualImports);
mark(foreignImports);
mark(foreignExports);