mirror of
https://github.com/github/semantic.git
synced 2025-01-04 21:47:07 +03:00
Assign withStatements
This commit is contained in:
parent
64b2845138
commit
97d6cefb0b
@ -62,6 +62,7 @@ type Syntax =
|
||||
, Statement.Finally
|
||||
, Statement.ForEach
|
||||
, Statement.If
|
||||
, Statement.Let
|
||||
, Statement.NoOp
|
||||
, Statement.Return
|
||||
, Statement.Throw
|
||||
@ -125,6 +126,7 @@ statement = assertStatement
|
||||
<|> returnStatement
|
||||
<|> tryStatement
|
||||
<|> whileStatement
|
||||
<|> withStatement
|
||||
|
||||
expressionStatement :: Assignment
|
||||
expressionStatement = symbol ExpressionStatement *> children expression
|
||||
@ -152,6 +154,12 @@ expression = await
|
||||
<|> typedParameter
|
||||
<|> unaryOperator
|
||||
|
||||
withStatement :: Assignment
|
||||
withStatement = makeTerm <$> symbol WithStatement <*> (children $ do
|
||||
(value, variable) <- (symbol WithItem *> (children $ (,) <$> identifier <*> identifier))
|
||||
body <- expression
|
||||
pure (Statement.Let variable value body))
|
||||
|
||||
forStatement :: Assignment
|
||||
forStatement = symbol ForStatement >>= \ loc -> children (make loc <$> (makeTerm <$> symbol Variables <*> children (many expression)) <*> expressionList <*> (makeTerm <$> location <*> many expression) <*> (optional (makeTerm <$> symbol ElseClause <*> children (many declaration))))
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user