From ea788f0fc53000afd264f0452f23b597887df9f9 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 16 Dec 2014 22:16:42 +0000 Subject: Parser: use 'error' token in error reporting rules Summary: It exempts us from 11 reduce/reduce conflicts and 12 shift/reduce conflicts. Signed-off-by: Sergei Trofimovich Reviewers: simonpj, mikeizbicki, austin, simonmar Reviewed By: simonmar Subscribers: carter, thomie Differential Revision: https://phabricator.haskell.org/D571 --- compiler/parser/Parser.y | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 023ea46da3..e990abbb5c 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -87,6 +87,12 @@ import TysWiredIn ( unitTyCon, unitDataCon, tupleTyCon, tupleCon, nilDataC } {- +----------------------------------------------------------------------------- +14 Dec 2014 + +Conflicts: 48 shift/reduce + 1 reduce/reduce + ----------------------------------------------------------------------------- 20 Nov 2014 @@ -1969,33 +1975,34 @@ exp10 :: { LHsExpr RdrName } | fexp { $1 } -- parsing error messages go below here - | '\\' apat apats opt_asig '->' {% parseErrorSDoc (combineLocs $1 $5) $ text + | '\\' apat apats opt_asig '->' error {% parseErrorSDoc (combineLocs $1 $5) $ text "parse error in lambda: no expression after '->'" } - | '\\' {% parseErrorSDoc (getLoc $1) $ text + | '\\' error {% parseErrorSDoc (getLoc $1) $ text "parse error: naked lambda expression '\'" } - | 'let' binds 'in' {% parseErrorSDoc (combineLocs $1 $2) $ text + | 'let' binds 'in' error {% parseErrorSDoc (combineLocs $1 $2) $ text "parse error in let binding: missing expression after 'in'" } - | 'let' binds {% parseErrorSDoc (combineLocs $1 $2) $ text + | 'let' binds error {% parseErrorSDoc (combineLocs $1 $2) $ text "parse error in let binding: missing required 'in'" } - | 'let' {% parseErrorSDoc (getLoc $1) $ text + | 'let' error {% parseErrorSDoc (getLoc $1) $ text "parse error: naked let binding" } - | 'if' exp optSemi 'then' exp optSemi 'else' {% hintIf (combineLocs $1 $5) "else clause empty" } - | 'if' exp optSemi 'then' exp optSemi {% hintIf (combineLocs $1 $5) "missing required else clause" } - | 'if' exp optSemi 'then' {% hintIf (combineLocs $1 $2) "then clause empty" } - | 'if' exp optSemi {% hintIf (combineLocs $1 $2) "missing required then and else clauses" } - | 'if' {% hintIf (getLoc $1) "naked if statement" } - | 'case' exp 'of' {% parseErrorSDoc (combineLocs $1 $2) $ text + | 'if' exp optSemi 'then' exp optSemi + 'else' error {% hintIf (combineLocs $1 $5) "else clause empty" } + | 'if' exp optSemi 'then' exp optSemi error {% hintIf (combineLocs $1 $5) "missing required else clause" } + | 'if' exp optSemi 'then' error {% hintIf (combineLocs $1 $2) "then clause empty" } + | 'if' exp optSemi error {% hintIf (combineLocs $1 $2) "missing required then and else clauses" } + | 'if' error {% hintIf (getLoc $1) "naked if statement" } + | 'case' exp 'of' error {% parseErrorSDoc (combineLocs $1 $2) $ text "parse error in case statement: missing list after '->'" } - | 'case' exp {% parseErrorSDoc (combineLocs $1 $2) $ text + | 'case' exp error {% parseErrorSDoc (combineLocs $1 $2) $ text "parse error in case statement: missing required 'of'" } - | 'case' {% parseErrorSDoc (getLoc $1) $ text + | 'case' error {% parseErrorSDoc (getLoc $1) $ text "parse error: naked case statement" } optSemi :: { ([Located a],Bool) } -- cgit v1.2.1