From 996b8fbf30004d0fa4c79919a547e7253abda22d Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Thu, 20 Jul 2017 11:39:07 -0700 Subject: [PATCH] Fix python assignment for multiple statements in if body --- src/Language/Python/Syntax.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index cdf316b61..911a2eff0 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -133,6 +133,9 @@ statement = assertStatement <|> withStatement <|> parseError +statements :: Assignment +statements = makeTerm <$> location <*> many statement + literal :: Assignment literal = boolean <|> concatenatedString @@ -400,7 +403,7 @@ raiseStatement :: Assignment raiseStatement = makeTerm <$> symbol RaiseStatement <*> children (Statement.Throw <$> (makeTerm <$> location <*> many expression)) ifStatement :: Assignment -ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> expression <*> statement <*> (flip (foldr makeElif) <$> many elifClause <*> optionalElse)) +ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> expression <*> statements <*> (flip (foldr makeElif) <$> many elifClause <*> optionalElse)) where elseClause = symbol ElseClause *> children statement elifClause = (,) <$ symbol ElifClause <*> location <*> children (Statement.If <$> expression <*> statement) optionalElse = fromMaybe <$> emptyTerm <*> optional elseClause