mirror of
https://github.com/github/semantic.git
synced 2024-12-29 01:42:43 +03:00
Assign generator expressions
This commit is contained in:
parent
0d7719432d
commit
4b64206feb
@ -26,6 +26,7 @@ import Term
|
||||
type Syntax = Union Syntax'
|
||||
type Syntax' =
|
||||
'[ Comment.Comment
|
||||
, Declaration.Comprehension
|
||||
, Declaration.Function
|
||||
, Declaration.Import
|
||||
, Declaration.Variable
|
||||
@ -103,6 +104,7 @@ expression = statement
|
||||
<|> dottedName
|
||||
<|> await
|
||||
<|> lambda
|
||||
<|> generatorExpression
|
||||
|
||||
dottedName :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
|
||||
dottedName = makeTerm <$> symbol DottedName <*> children (Expression.ScopeResolution <$> many expression)
|
||||
@ -287,6 +289,9 @@ lambda = makeTerm <$> symbol Lambda <*> children (Declaration.Function <$> lambd
|
||||
lambdaParameters = many identifier
|
||||
lambdaBody = expression
|
||||
|
||||
generatorExpression :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
|
||||
generatorExpression = makeTerm <$> symbol GeneratorExpression <*> children (Declaration.Comprehension <$> expression <* symbol AnonFor <* symbol Variables <*> children (many expression) <* symbol AnonIn <*> expression)
|
||||
|
||||
makeTerm :: HasCallStack => InUnion Syntax' f => a -> f (Term Syntax a) -> Term Syntax a
|
||||
makeTerm a f = cofree (a :< inj f)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user