1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

With statements with multiple withItems and partial withItems

This commit is contained in:
Timothy Clem 2017-07-21 15:46:04 -07:00
parent 1ab0701df2
commit 618165452a
2 changed files with 10 additions and 2 deletions

View File

@ -203,9 +203,12 @@ decoratedDefinition = symbol DecoratedDefinition *> children (makeDecorator <$>
decorator' = Declaration.Decorator <$> expression <*> ((symbol ArgumentList *> children (many expression <|> many emptyTerm)) <|> many emptyTerm)
withStatement :: Assignment
withStatement = makeTerm <$> symbol WithStatement <*> children (uncurry Statement.Let . swap <$> withItem <*> expressions)
withStatement = symbol WithStatement >>= \ loc -> children (mk loc <$> some with)
where
withItem = symbol WithItem *> children ((,) <$> expression <*> expression)
mk _ [child] = child
mk l children = makeTerm l children
with = makeTerm <$> location <*> (uncurry Statement.Let . swap <$> withItem <*> expressions)
withItem = symbol WithItem *> children ((,) <$> expression <*> (expression <|> emptyTerm))
forStatement :: Assignment
forStatement = symbol ForStatement >>= \ loc -> children (make loc <$> (makeTerm <$> symbol Variables <*> children (many expression)) <*> expressionList <*> expressions <*> optional (makeTerm <$> symbol ElseClause <*> children (many expression)))

5
test/fixtures/python/with.B.py vendored Normal file
View File

@ -0,0 +1,5 @@
with cls._lock:
found = False
with patch.object(sys, 'stdout', stdout), \
patch.object(sys, 'stderr', stderr):
x