1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

ruby: pull out some duplication in block assignment

This commit is contained in:
Charlie Somerville 2018-03-26 16:41:05 +11:00
parent 8dfaae81e1
commit 437df993b5

View File

@ -243,9 +243,10 @@ lambda = makeTerm <$> symbol Lambda <*> children (
<*> expressions)
block :: Assignment
block = makeTerm <$> symbol DoBlock <*> children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions)
<|> makeTerm <$> symbol Block <*> children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions)
where params = symbol BlockParameters *> children (many parameter) <|> pure []
block = makeTerm <$> symbol DoBlock <*> blockChildren
<|> makeTerm <$> symbol Block <*> blockChildren
where blockChildren = children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions)
params = symbol BlockParameters *> children (many parameter) <|> pure []
comment :: Assignment
comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)