Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 7fc70fd

Browse files
committed
Nest lets.
1 parent 26cd38f commit 7fc70fd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Language/Python/Assignment.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,10 @@ argumentList :: Assignment Term
240240
argumentList = symbol ArgumentList *> children expressions
241241

242242
withStatement :: Assignment Term
243-
withStatement = makeTerm'' <$> symbol WithStatement <*> children (someTerm with)
243+
withStatement = symbol WithStatement *> children (flip (foldr make) <$> some withItem <*> term block')
244244
where
245-
with = makeTerm <$> location <*> (withItem <*> term (makeTerm <$> location <*> manyTermsTill expression (void (symbol WithItem) <|> eof)))
246-
withItem = symbol WithItem *> children (flip Statement.Let <$> term expression <*> term (expression <|> emptyTerm))
247-
<|> flip Statement.Let <$> term expression <*> emptyTerm
245+
make (val, name) = makeTerm1 . Statement.Let name val
246+
withItem = symbol WithItem *> children ((,) <$> term expression <*> term (expression <|> emptyTerm))
248247

249248
forStatement :: Assignment Term
250249
forStatement = symbol ForStatement >>= \ loc -> children (make loc <$> (symbol Variables *> children expressions) <*> term expressionList <*> term block' <*> optional (symbol ElseClause *> children expressions))

0 commit comments

Comments
 (0)