Commit ea788f0f authored by Sergei Trofimovich's avatar Sergei Trofimovich

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: default avatarSergei Trofimovich <siarheit@google.com>

Reviewers: simonpj, mikeizbicki, austin, simonmar

Reviewed By: simonmar

Subscribers: carter, thomie

Differential Revision: https://phabricator.haskell.org/D571
parent 5444560b
......@@ -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) }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment