1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 21:31:48 +03:00

Expand If assignment

This commit is contained in:
Rick Winfrey 2017-05-30 16:58:30 -07:00
parent aad7f36902
commit 393c481f83

View File

@ -197,9 +197,9 @@ returnStatement = makeTerm <$> symbol ReturnStatement <*> (Statement.Return <$>
ifStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> condition <*> statement <*> (flip (foldr makeElif) <$> many elifClause <*> optionalElse))
ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> expression <*> statement <*> (flip (foldr makeElif) <$> many elifClause <*> optionalElse))
where elseClause = symbol ElseClause *> children statement
elifClause = (,) <$ symbol ElifClause <*> location <*> children (Statement.If <$> condition <*> statement)
elifClause = (,) <$ symbol ElifClause <*> location <*> children (Statement.If <$> expression <*> statement)
condition = boolean
optionalElse = fromMaybe <$> emptyTerm <*> optional elseClause
makeElif (loc, makeIf) rest = makeTerm loc (makeIf rest)