{- -*-haskell-*-
-----------------------------------------------------------------------------
-$Id: Parser.y,v 1.110 2002/10/11 14:46:04 simonpj Exp $
+$Id: Parser.y,v 1.114 2002/12/10 16:28:48 igloo Exp $
Haskell grammar.
import HsTypes ( mkHsTupCon )
import RdrHsSyn
-import HscTypes ( ParsedIface(..), IsBootInterface )
+import HscTypes ( ParsedIface(..), IsBootInterface, noDependencies )
import Lex
import RdrName
import PrelNames ( mAIN_Name, funTyConName, listTyConName,
pi_vers = 1, -- Module version
pi_orphan = False,
pi_exports = (1,[($2,mkIfaceExports $4)]),
+ pi_deps = noDependencies,
pi_usages = [],
pi_fixity = [],
pi_insts = [],
| {- empty -} { [] }
-wherebinds :: { RdrNameHsBinds }
- : where { cvBinds $1 }
+decllist :: { [RdrBinding] } -- Reversed
+ : '{' decls '}' { $2 }
+ | layout_on decls close { $2 }
where :: { [RdrBinding] } -- Reversed
+ -- No implicit parameters
: 'where' decllist { $2 }
| {- empty -} { [] }
-decllist :: { [RdrBinding] } -- Reversed
- : '{' decls '}' { $2 }
- | layout_on decls close { $2 }
+binds :: { RdrNameHsBinds } -- May have implicit parameters
+ : decllist { cvBinds $1 }
+ | '{' dbinds '}' { IPBinds $2 False{-not with-} }
+ | layout_on dbinds close { IPBinds $2 False{-not with-} }
-letbinds :: { RdrNameHsExpr -> RdrNameHsExpr }
- : decllist { HsLet (cvBinds $1) }
- | '{' dbinds '}' { \e -> HsWith e $2 False{-not with-} }
- | layout_on dbinds close { \e -> HsWith e $2 False{-not with-} }
+wherebinds :: { RdrNameHsBinds } -- May have implicit parameters
+ : 'where' binds { $2 }
+ | {- empty -} { EmptyBinds }
exp :: { RdrNameHsExpr }
: infixexp '::' sigtype { ExprWithTySig $1 $3 }
- | infixexp 'with' dbinding { HsWith $1 $3 True{-not a let-} }
+ | infixexp 'with' dbinding { HsLet (IPBinds $3 True{-not a let-}) $1 }
| infixexp { $1 }
infixexp :: { RdrNameHsExpr }
returnP (HsLam (Match ps $5
(GRHSs (unguardedRHS $8 $7)
EmptyBinds placeHolderType))) }
- | 'let' letbinds 'in' exp { $2 $4 }
+ | 'let' binds 'in' exp { HsLet $2 $4 }
| 'if' srcloc exp 'then' exp 'else' exp { HsIf $3 $5 $7 $2 }
| 'case' srcloc exp 'of' altslist { HsCase $3 $5 $2 }
| '-' fexp { mkHsNegApp $2 }
| srcloc '[t|' ctype '|]' { HsBracket (TypBr $3) $1 }
| srcloc '[p|' infixexp '|]' {% checkPattern $1 $3 `thenP` \p ->
returnP (HsBracket (PatBr p) $1) }
- | srcloc '[d|' cvtopdecls '|]' { HsBracket (DecBr (mkGroup $3)) $1 }
+ | srcloc '[d|' cvtopbody '|]' { HsBracket (DecBr (mkGroup $3)) $1 }
+cvtopbody :: { [RdrNameHsDecl] }
+ : '{' cvtopdecls '}' { $2 }
+ | layout_on cvtopdecls close { $2 }
texps :: { [RdrNameHsExpr] }
: texps ',' exp { $3 : $1 }
: srcloc infixexp '<-' exp {% checkPattern $1 $2 `thenP` \p ->
returnP (BindStmt p $4 $1) }
| srcloc exp { ExprStmt $2 placeHolderType $1 }
- | srcloc 'let' decllist { LetStmt (cvBinds $3) }
+ | srcloc 'let' binds { LetStmt $3 }
-----------------------------------------------------------------------------
-- Record Field Update/Construction