X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fparser%2FParser.y;h=ca4fafbdd64de80239f410d9fb889b15cb9da9f3;hb=43f425a47a7dc19bd4284112548ab51d230a0482;hp=b584fe864aef69aaabe6ffeeb455627c927287d4;hpb=5d9b0aa4904ea802616fa20e90e5353fcdc90fde;p=ghc-hetmet.git diff --git a/ghc/compiler/parser/Parser.y b/ghc/compiler/parser/Parser.y index b584fe8..ca4fafb 100644 --- a/ghc/compiler/parser/Parser.y +++ b/ghc/compiler/parser/Parser.y @@ -1,6 +1,6 @@ {- ----------------------------------------------------------------------------- -$Id: Parser.y,v 1.62 2001/05/08 16:25:30 simonpj Exp $ +$Id: Parser.y,v 1.63 2001/05/09 13:05:07 simonpj Exp $ Haskell grammar. @@ -697,7 +697,8 @@ exp10 :: { RdrNameHsExpr } | '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 'do' stmtlist { HsDo DoExpr $3 $1 } + | srcloc 'do' stmtlist {% checkDo $3 `thenP` \ stmts -> + returnP (HsDo DoExpr stmts $1) } | '_ccall_' ccallid aexps0 { HsCCall $2 $3 False False cbot } | '_ccall_GC_' ccallid aexps0 { HsCCall $2 $3 True False cbot } @@ -837,13 +838,22 @@ stmtlist :: { [RdrNameStmt] } : '{' stmts '}' { $2 } | layout_on_for_do stmts close { $2 } +-- do { ;; s ; s ; ; s ;; } +-- The last Stmt should be a ResultStmt, but that's hard to enforce +-- here, because we need too much lookahead if we see do { e ; } +-- So we use ExprStmts throughout, and switch the last one over +-- in ParseUtils.checkDo instead stmts :: { [RdrNameStmt] } + : stmt stmts_help { $1 : $2 } + | ';' stmts { $2 } + | {- empty -} { [] } + +stmts_help :: { [RdrNameStmt] } : ';' stmts { $2 } - | stmt ';' stmts { $1 : $3 } - | srcloc exp { [ResultStmt $2 $1] } + | {- empty -} { [] } --- for typing stmts at the GHCi prompt, where the input may consist of --- just comments. +-- For typing stmts at the GHCi prompt, where +-- the input may consist of just comments. maybe_stmt :: { Maybe RdrNameStmt } : stmt { Just $1 } | {- nothing -} { Nothing }