mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Update assignment for single list comprehensions
This commit is contained in:
parent
77d53e9127
commit
f9f2e46059
@ -456,15 +456,12 @@ none :: Assignment
|
|||||||
none = makeTerm <$> symbol None <*> (Literal.Null <$ source)
|
none = makeTerm <$> symbol None <*> (Literal.Null <$ source)
|
||||||
|
|
||||||
comprehension :: Assignment
|
comprehension :: Assignment
|
||||||
comprehension = makeTerm <$> symbol GeneratorExpression <*> children (comprehensionDeclaration expression)
|
comprehension = symbol ListComprehension >>= \ loc -> children (mk loc <$> expression <*> forInClause <*> (ifClause <|> emptyTerm))
|
||||||
<|> makeTerm <$> symbol ListComprehension <*> children (comprehensionDeclaration expression)
|
where forInClause = symbol ForInClause *> children ((,) <$> variables <*> expressions)
|
||||||
<|> makeTerm <$> symbol SetComprehension <*> children (comprehensionDeclaration expression)
|
variables = symbol Variables *> children expression
|
||||||
<|> makeTerm <$> symbol DictionaryComprehension <*> children (comprehensionDeclaration keyValue)
|
ifClause = symbol IfClause *> children expression
|
||||||
where
|
mk loc expr (bindings, context) ifExpr = makeTerm loc (Declaration.Comprehension expr bindings context ifExpr)
|
||||||
keyValue = makeTerm <$> location <*> (Literal.KeyValue <$> expression <*> expression)
|
|
||||||
comprehensionDeclaration preceeding = Declaration.Comprehension <$ many comment <*> preceeding <* symbol Variables <*> children (many expression) <*> (flip (foldr makeComprehension) <$> many nestedComprehension <*> expression)
|
|
||||||
makeComprehension (loc, makeRest) rest = makeTerm loc (makeRest rest)
|
|
||||||
nestedComprehension = (,) <$> location <*> (Declaration.Comprehension <$> expression <* symbol Variables <*> children (many expression))
|
|
||||||
|
|
||||||
conditionalExpression :: Assignment
|
conditionalExpression :: Assignment
|
||||||
conditionalExpression = makeTerm <$> symbol ConditionalExpression <*> children (
|
conditionalExpression = makeTerm <$> symbol ConditionalExpression <*> children (
|
||||||
|
Loading…
Reference in New Issue
Block a user