@@ -18,8 +18,6 @@ import qualified AST.Literal as L
18import qualified AST.Pattern as P
18import qualified AST.Pattern as P
19import qualified AST.Variable as Var
19import qualified AST.Variable as Var
20import qualified Reporting.Annotation as A
20import qualified Reporting.Annotation as A
21−import qualified Reporting.Crash as Crash
22−import qualified Reporting.Region as R
25-------- Basic Terms --------
23-------- Basic Terms --------
@@ -197,8 +195,7 @@ appExpr =
198expr :: IParser Source.Expr
196expr :: IParser Source.Expr
200− addLocation (choice [ letExpr, caseExpr ])
198+ addLocation (choice [ letExpr, caseExpr, ifExpr ])
202 <|> lambdaExpr
199 <|> lambdaExpr
203 <|> binaryExpr
200 <|> binaryExpr
204 <?> "an expression"
201 <?> "an expression"
@@ -209,45 +206,23 @@ binaryExpr =
209 Binop.binops appExpr lastExpr anyOp
206 Binop.binops appExpr lastExpr anyOp
211 lastExpr =
208 lastExpr =
212− addLocation (choice [ letExpr, caseExpr ])
209+ addLocation (choice [ letExpr, caseExpr, ifExpr ])
214 <|> lambdaExpr
210 <|> lambdaExpr
215 <?> "an expression"
211 <?> "an expression"
218−ifExpr :: IParser Source.Expr
214+ifExpr :: IParser Source.Expr'
220− do start <- getMyPosition
221− try (reserved "if")
216+ do try (reserved "if")
222 whitespace
217 whitespace
223− makeExpr <- normal <|> multiIf
224− end <- getMyPosition
225− return (makeExpr (R.Region start end))
228− do condition <- expr
218+ condition <- expr
229− padded (reserved "then")
219+ padded (reserved "then")
230− thenBranch <- expr
220+ thenBranch <- expr
231− whitespace <?> "an 'else' branch"
221+ whitespace <?> "an 'else' branch"
232− reserved "else" <?> "an 'else' branch"
222+ reserved "else" <?> "an 'else' branch"
233− whitespace
223+ whitespace
234− elseBranch <- expr
224+ elseBranch <- expr
235− return $ \region -> A.A region (E.MultiIf [(condition, thenBranch)] elseBranch)
225+ return (E.If [(condition, thenBranch)] elseBranch)
238− do branches <- spaceSep1 multiBranch
239− return $ \region -> A.A region (E.MultiIf branches (crash region))
242− A.A region (E.Crash (Crash.IncompleteMultiIf region))
250− return (condition, branch)
253lambdaExpr :: IParser Source.Expr
228lambdaExpr :: IParser Source.Expr