diff options
author | lewie <unknown> | 2000-01-28 20:52:46 +0000 |
---|---|---|
committer | lewie <unknown> | 2000-01-28 20:52:46 +0000 |
commit | 266fadd93461d4317967df08cd641e965cd8769a (patch) | |
tree | 459d27caad93a293a12fb7b4d4b3fe48d483b90f /ghc/compiler/parser/Parser.y | |
parent | c39373f1371fd1e46ea91be262f00c277b31f8e5 (diff) | |
download | haskell-266fadd93461d4317967df08cd641e965cd8769a.tar.gz |
[project @ 2000-01-28 20:52:37 by lewie]
First pass at implicit parameters. Honest, I didn't really go in *intending*
to modify every file in the typechecker... ;-) The breadth of the change
is partly due to generalizing contexts so that they are not hardwired to
be (Class, [Type]) pairs. See types/Type.lhs for details (look for PredType).
Diffstat (limited to 'ghc/compiler/parser/Parser.y')
-rw-r--r-- | ghc/compiler/parser/Parser.y | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/ghc/compiler/parser/Parser.y b/ghc/compiler/parser/Parser.y index 87f6458f79..759c2dcff1 100644 --- a/ghc/compiler/parser/Parser.y +++ b/ghc/compiler/parser/Parser.y @@ -1,6 +1,6 @@ {- ----------------------------------------------------------------------------- -$Id: Parser.y,v 1.18 1999/12/01 17:01:36 simonmar Exp $ +$Id: Parser.y,v 1.19 2000/01/28 20:52:39 lewie Exp $ Haskell grammar. @@ -19,7 +19,7 @@ import Lex import ParseUtil import RdrName import PrelMods ( mAIN_Name ) -import OccName ( varName, dataName, tcClsName, tvName ) +import OccName ( varName, ipName, dataName, tcClsName, tvName ) import SrcLoc ( SrcLoc ) import Module import CallConv @@ -85,6 +85,7 @@ Conflicts: 14 shift/reduce 'then' { ITthen } 'type' { ITtype } 'where' { ITwhere } + 'with' { ITwith } '_scc_' { ITscc } 'forall' { ITforall } -- GHC extension keywords @@ -173,6 +174,7 @@ Conflicts: 14 shift/reduce QCONID { ITqconid $$ } QVARSYM { ITqvarsym $$ } QCONSYM { ITqconsym $$ } + IPVARID { ITipvarid $$ } PRAGMA { ITpragma $$ } @@ -633,6 +635,7 @@ gdrh :: { RdrNameGRHS } exp :: { RdrNameHsExpr } : infixexp '::' sigtype { ExprWithTySig $1 $3 } + | infixexp 'with' dbinding { HsWith $1 $3 } | infixexp { $1 } infixexp :: { RdrNameHsExpr } @@ -683,6 +686,7 @@ aexp :: { RdrNameHsExpr } aexp1 :: { RdrNameHsExpr } : qvar { HsVar $1 } + | IPVARID { HsIPVar (mkSrcUnqual ipName $1) } | gcon { HsVar $1 } | literal { HsLit $1 } | '(' exp ')' { HsPar $2 } @@ -816,6 +820,22 @@ fbind :: { (RdrName, RdrNameHsExpr, Bool) } : qvar '=' exp { ($1,$3,False) } ----------------------------------------------------------------------------- +-- Implicit Parameter Bindings + +dbinding :: { [(RdrName, RdrNameHsExpr)] } + : '{' dbinds '}' { $2 } + | layout_on dbinds close { $2 } + +dbinds :: { [(RdrName, RdrNameHsExpr)] } + : dbinds ';' dbind { $3 : $1 } + | dbinds ';' { $1 } + | dbind { [$1] } + | {- empty -} { [] } + +dbind :: { (RdrName, RdrNameHsExpr) } +dbind : IPVARID '=' exp { (mkSrcUnqual ipName $1, $3) } + +----------------------------------------------------------------------------- -- Variables, Constructors and Operators. gcon :: { RdrName } |