1
1
mirror of https://github.com/github/semantic.git synced 2025-01-05 14:11:33 +03:00

parse For exprs

This commit is contained in:
joshvera 2016-07-28 16:34:07 -04:00
parent 69c02ce76e
commit c45f251b3d
3 changed files with 4 additions and 4 deletions

View File

@ -162,7 +162,7 @@ diffSummary = cata $ \case
(Free (infos :< Syntax.VarAssignment varId value)) -> prependSummary (category $ snd infos) <$> varId <> value
(Free (infos :< Syntax.VarDecl decl)) -> prependSummary (category $ snd infos) <$> decl
(Free (infos :< Syntax.Args args)) -> prependSummary (category $ snd infos) <$> join args
(Free (infos :< Syntax.For expr value body)) -> prependSummary (category $ snd infos) <$> expr <> value <> body
(Free (infos :< Syntax.For exprs body)) -> prependSummary (category $ snd infos) <$> join exprs <> body
(Free (infos :< Syntax.While expr body)) -> prependSummary (category $ snd infos) <$> expr <> body
(Free (infos :< Syntax.DoWhile expr body)) -> prependSummary (category $ snd infos) <$> expr <> body
(Free (infos :< Syntax.Switch expr cases)) -> prependSummary (category $ snd infos) <$> expr <> join cases

View File

@ -81,8 +81,8 @@ termConstructor source info = cofree . construct
toTuple child | S.Leaf c <- unwrap child = [cofree (extract child :< S.Comment c)]
construct children | isFixed (category info) = withDefaultInfo $ S.Fixed children
construct children | For == (category info), [clause, value, body] <- children =
withDefaultInfo $ S.For clause value body
construct children | For == (category info), Just (exprs, body) <- unsnoc children =
withDefaultInfo $ S.For exprs body
construct children | While == (category info), [expr, body] <- children =
withDefaultInfo $ S.While expr body
construct children | DoWhile == (category info), [expr, body] <- children =

View File

@ -73,7 +73,7 @@ termFields info syntax = "range" .= characterRange info : "category" .= category
S.Args c -> childrenFields c
S.Assignment assignmentId property -> [ "assignmentIdentifier" .= assignmentId ] <> [ "property" .= property ]
S.MemberAccess memberId value -> [ "memberIdentifier" .= memberId ] <> [ "value" .= value ]
S.For expr value body -> [ "forDeclaration" .= expr ] <> [ "forValue" .= value ] <> [ "forBody" .= body ]
S.For exprs body -> [ "forExpressions" .= exprs ] <> [ "forBody" .= body ]
S.While expr body -> [ "whileExpr" .= expr ] <> [ "whileBody" .= body ]
S.DoWhile expr body -> [ "doWhileExpr" .= expr ] <> [ "doWhileBody" .= body ]
S.Switch expr cases -> [ "switchExpression" .= expr ] <> [ "cases" .= cases ]