[commit: ghc] master: Parser: use 'error' token in error reporting rules (ea788f0)
git at git.haskell.org
git at git.haskell.org
Tue Dec 16 22:46:04 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ea788f0fc53000afd264f0452f23b597887df9f9/ghc
>---------------------------------------------------------------
commit ea788f0fc53000afd264f0452f23b597887df9f9
Author: Sergei Trofimovich <siarheit at google.com>
Date: Tue Dec 16 22:16:42 2014 +0000
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 at google.com>
Reviewers: simonpj, mikeizbicki, austin, simonmar
Reviewed By: simonmar
Subscribers: carter, thomie
Differential Revision: https://phabricator.haskell.org/D571
>---------------------------------------------------------------
ea788f0fc53000afd264f0452f23b597887df9f9
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 023ea46..e990abb 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) }
More information about the ghc-commits
mailing list