1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 09:15:01 +03:00

Add conditional

This commit is contained in:
Timothy Clem 2017-06-19 07:49:57 -06:00
parent 0285cf4939
commit e7e1898c66

View File

@ -86,12 +86,14 @@ statement = -- handleError $
<|> mk Break Statement.Break
<|> mk Next Statement.Continue
<|> for
-- <|> assignment'
<|> class'
<|> method
<|> identifier
<|> literal
<|> scopeResolution
<|> conditional
-- <|> assignment'
-- TODO: rescue
where mk s construct = makeTerm <$> symbol s <*> children ((construct .) . fromMaybe <$> emptyTerm <*> optional (symbol ArgumentList *> children statement))
statements :: Assignment
@ -198,6 +200,9 @@ for = makeTerm <$> symbol For <*> children (Statement.ForEach <$> identifier <*>
-- <|> makeTerm <$> symbol AnonLAngleLAngleEqual <*> (Expression.LShift var <$> expression)
-- <|> makeTerm <$> symbol AnonCaretEqual <*> (Expression.BXOr var <$> expression)))
conditional :: Assignment
conditional = makeTerm <$> symbol Conditional <*> children (Statement.If <$> statement <*> statement <*> statement)
emptyStatement :: Assignment
emptyStatement = makeTerm <$> symbol EmptyStatement <*> (Syntax.Empty <$> (Just <$> source))