1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

🔥 expr.

This commit is contained in:
Rob Rix 2017-04-19 16:28:51 -04:00
parent c83b75f5b4
commit 1d2c924088

View File

@ -78,8 +78,8 @@ statement = exit Statement.Return Return
<|> if'
<|> ifModifier
<|> unless
<|> expr
where exit construct sym = term . construct <$ symbol sym <*> children (optional (symbol ArgumentList *> children expr))
<|> literal
where exit construct sym = term . construct <$ symbol sym <*> children (optional (symbol ArgumentList *> children statement))
comment :: Assignment Grammar (Term Syntax ())
comment = term . Comment.Comment <$ symbol Comment <*> source
@ -89,14 +89,11 @@ if' = go If
where go s = term <$ symbol s <*> children (Statement.If <$> statement <*> (term <$> many statement) <*> (go Elsif <|> term <$ symbol Else <*> children (many statement)))
ifModifier :: Assignment Grammar (Term Syntax ())
ifModifier = term <$ symbol IfModifier <*> children (flip Statement.If <$> statement <*> expr <*> pure (term Syntax.Empty))
ifModifier = term <$ symbol IfModifier <*> children (flip Statement.If <$> statement <*> statement <*> pure (term Syntax.Empty))
unless :: Assignment Grammar (Term Syntax ())
unless = term <$ symbol Unless <*> children (Statement.If <$> (term . Expression.Not <$> statement) <*> (term <$> many statement) <*> (term <$ symbol Else <*> children (many statement)))
expr :: Assignment Grammar (Term Syntax ())
expr = literal
literal :: Assignment Grammar (Term Syntax ())
literal = term Literal.true <$ symbol Language.Ruby.Syntax.True <* source
<|> term Literal.false <$ symbol Language.Ruby.Syntax.False <* source