summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <siarheit@google.com>2014-12-16 22:16:42 +0000
committerSergei Trofimovich <siarheit@google.com>2014-12-16 22:16:42 +0000
commitea788f0fc53000afd264f0452f23b597887df9f9 (patch)
treea26e44ff53d28c2e065e9593e11df320bbbfbf6b
parent5444560b26a14750ae59578d354d98eaff9c7a41 (diff)
downloadhaskell-ea788f0fc53000afd264f0452f23b597887df9f9.tar.gz
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 <siarheit@google.com> Reviewers: simonpj, mikeizbicki, austin, simonmar Reviewed By: simonmar Subscribers: carter, thomie Differential Revision: https://phabricator.haskell.org/D571
-rw-r--r--compiler/parser/Parser.y33
1 files 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
@@ -88,6 +88,12 @@ import TysWiredIn ( unitTyCon, unitDataCon, tupleTyCon, tupleCon, nilDataC
{-
-----------------------------------------------------------------------------
+14 Dec 2014
+
+Conflicts: 48 shift/reduce
+ 1 reduce/reduce
+
+-----------------------------------------------------------------------------
20 Nov 2014
Conflicts: 60 shift/reduce
@@ -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) }