[project @ 1997-06-18 23:52:36 by simonpj]
[ghc-hetmet.git] / ghc / compiler / parser / hsparser.y
index 4ca10ea..58db2df 100644 (file)
@@ -185,7 +185,8 @@ BOOLEAN inpat;
 
 %token  INTERFACE_UPRAGMA SPECIALISE_UPRAGMA
 %token  INLINE_UPRAGMA MAGIC_UNFOLDING_UPRAGMA
-%token  DEFOREST_UPRAGMA END_UPRAGMA
+%token  DEFOREST_UPRAGMA END_UPRAGMA 
+%token  SOURCE_UPRAGMA
 
 /**********************************************************************
 *                                                                     *
@@ -283,7 +284,7 @@ BOOLEAN inpat;
 
 %type <uentid>   export import
 
-%type <ulong>     commas
+%type <ulong>     commas importkey
 
 /**********************************************************************
 *                                                                     *
@@ -380,11 +381,11 @@ impdecls:  impdecl                                { $$ = $1; }
 
 
 impdecl        :  importkey modid impspec
-               { $$ = lsing(mkimport($2,0,mknothing(),$3,startlineno)); }
+               { $$ = lsing(mkimport($2,0,mknothing(),$3,$1,startlineno)); }
        |  importkey QUALIFIED modid impspec
-               { $$ = lsing(mkimport($3,1,mknothing(),$4,startlineno)); }
+               { $$ = lsing(mkimport($3,1,mknothing(),$4,$1,startlineno)); }
        |  importkey QUALIFIED modid AS modid impspec
-               { $$ = lsing(mkimport($3,1,mkjust($5),$6,startlineno)); }
+               { $$ = lsing(mkimport($3,1,mkjust($5),$6,$1,startlineno)); }
        ;
 
 impspec        :  /* empty */                            { $$ = mknothing(); }
@@ -474,12 +475,12 @@ topdecls:  topdecl
                }
         ;
 
-topdecl        :  typed                                { $$ = $1; }
-       |  datad                                { $$ = $1; }
-       |  newtd                                { $$ = $1; }
-       |  classd                               { $$ = $1; }
-       |  instd                                { $$ = $1; }
-       |  defaultd                             { $$ = $1; }
+topdecl        :  typed                                { $$ = $1; FN = NULL; SAMEFN = 0; }
+       |  datad                                { $$ = $1; FN = NULL; SAMEFN = 0; }
+       |  newtd                                { $$ = $1; FN = NULL; SAMEFN = 0; }
+       |  classd                               { $$ = $1; FN = NULL; SAMEFN = 0; }
+       |  instd                                { $$ = $1; FN = NULL; SAMEFN = 0; }
+       |  defaultd                             { $$ = $1; FN = NULL; SAMEFN = 0; }
        |  decl                                 { $$ = $1; }
        ;
 
@@ -1009,9 +1010,11 @@ kexp     :  kexpL
        |  kexpLno
        ;
 
+/* kexpL = a let expression */
 kexpL  :  letdecls IN exp                      { $$ = mklet($1,$3); }
        ;
 
+/* kexpLno = any other expression more tightly binding than operator application */
 kexpLno        :  LAMBDA
                { hsincindent();        /* push new context for FN = NULL;        */
                  FN = NULL;            /* not actually concerned about indenting */
@@ -1199,7 +1202,7 @@ stmts     :  stmt                                 { $$ = $1; }
 
 stmt   :  /* empty */                          { $$ = Lnil; }
        |  letdecls                             { $$ = lsing(mkseqlet($1)); }
-       |  expL                                 { $$ = lsing($1); }
+       |  expL                                 { $$ = lsing(mkdoexp($1,hsplineno)); }
        |  {inpat=TRUE;} expLno {inpat=FALSE;} leftexp
                { if ($4 == NULL) {
                      expORpat(LEGIT_EXPR,$2);
@@ -1339,7 +1342,8 @@ gconk     :  qconk
 *                                                                     *
 **********************************************************************/
 
-importkey:  IMPORT     { setstartlineno(); }
+importkey: IMPORT               { setstartlineno(); $$ = 0; }
+        |  IMPORT SOURCE_UPRAGMA { setstartlineno(); $$ = 1; }
        ;
 
 datakey        :   DATA        { setstartlineno();