From 10fb3679553f47d2015353a1d9ba06a9f0d582dc Mon Sep 17 00:00:00 2001 From: sewardj Date: Tue, 4 Apr 2000 17:35:04 +0000 Subject: [PATCH] [project @ 2000-04-04 17:35:04 by sewardj] Restore ability to load a script which doesn't have a module header, ie doesn't start module M where ... --- ghc/interpreter/connect.h | 7 +++++-- ghc/interpreter/hugs.c | 21 +++++++++------------ ghc/interpreter/parser.y | 16 ++++++++++++++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/ghc/interpreter/connect.h b/ghc/interpreter/connect.h index b1ead06..9f2c36b 100644 --- a/ghc/interpreter/connect.h +++ b/ghc/interpreter/connect.h @@ -9,8 +9,8 @@ * included in the distribution. * * $RCSfile: connect.h,v $ - * $Revision: 1.35 $ - * $Date: 2000/04/04 15:41:56 $ + * $Revision: 1.36 $ + * $Date: 2000/04/04 17:35:04 $ * ------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------- @@ -327,6 +327,9 @@ extern List diVars; /* deriving: cache of names */ extern Int diNum; /* also for deriving */ extern List cfunSfuns; /* List of (Cfun,[SelectorVar]) */ +extern Module moduleBeingParsed; /* so the parser (topModule) knows */ + + #if USE_PREPROCESSOR extern String preprocessor; /* preprocessor command */ #endif diff --git a/ghc/interpreter/hugs.c b/ghc/interpreter/hugs.c index a6c9878..55b39e4 100644 --- a/ghc/interpreter/hugs.c +++ b/ghc/interpreter/hugs.c @@ -9,8 +9,8 @@ * included in the distribution. * * $RCSfile: hugs.c,v $ - * $Revision: 1.56 $ - * $Date: 2000/04/04 17:07:15 $ + * $Revision: 1.57 $ + * $Date: 2000/04/04 17:35:04 $ * ------------------------------------------------------------------------*/ #include @@ -108,14 +108,9 @@ static Bool lastWasObject = FALSE; Bool debugSC = FALSE; Bool combined = FALSE; - char* currentFile; /* Name of current file, or NULL */ -static char currentFileName[1000]; /* name is stored here if it exists*/ - - - -static Text evalModule = 0; /* Name of module we eval exprs in */ -static String currProject = 0; /* Name of current project file */ -static Bool projectLoaded = FALSE; /* TRUE => project file loaded */ + Module moduleBeingParsed; /* so the parser (topModule) knows */ +static char* currentFile; /* Name of current file, or NULL */ +static char currentFileName[1000]; /* name is stored here if it exists*/ static Bool autoMain = FALSE; static String lastEdit = 0; /* Name of script to edit (if any) */ @@ -823,12 +818,14 @@ static void setCurrentFile ( Module mod ) assert(isModule(mod)); strncpy(currentFileName, textToStr(module(mod).text), 990); strcat(currentFileName, textToStr(module(mod).srcExt)); - currentFile = currentFileName; + currentFile = currentFileName; + moduleBeingParsed = mod; } static void clearCurrentFile ( void ) { - currentFile = NULL; + currentFile = NULL; + moduleBeingParsed = NIL; } static void ppMG ( void ) diff --git a/ghc/interpreter/parser.y b/ghc/interpreter/parser.y index a681b52..99900bf 100644 --- a/ghc/interpreter/parser.y +++ b/ghc/interpreter/parser.y @@ -12,8 +12,8 @@ * included in the distribution. * * $RCSfile: parser.y,v $ - * $Revision: 1.26 $ - * $Date: 2000/03/22 18:14:22 $ + * $Revision: 1.27 $ + * $Date: 2000/04/04 17:35:04 $ * ------------------------------------------------------------------------*/ %{ @@ -442,6 +442,14 @@ topModule : TMODULE modname expspec WHERE '{' modBody end $2, singleton(ap(MODULEENT,$2)), $5)));} + + | begin modBody end {ConId fakeNm = mkCon(module( + moduleBeingParsed).text); + $$ = gc2(ap(M_MODULE, + ztriple(fakeNm, + singleton(ap(MODULEENT,fakeNm)), + $2)));} + | TMODULE error {syntaxError("module definition");} ; @@ -1265,6 +1273,10 @@ varid1 : VARID {$$ = gc1($1);} /*- Tricks to force insertion of leading and closing braces ---------------*/ +begin : error {yyerrok; + if (offsideON) goOffside(startColumn);} + ; + end : '}' {$$ = $1;} | error {yyerrok; if (offsideON && canUnOffside()) { -- 1.7.10.4