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

Remove ruby parsing dependence on Args syntax

This commit is contained in:
Timothy Clem 2016-11-04 13:30:32 -07:00
parent 437522f5e1
commit 46d3066a97

View File

@ -31,7 +31,6 @@ termConstructor
termConstructor source sourceSpan name range children
| name == "ERROR" = withDefaultInfo (S.Error children)
| otherwise = withDefaultInfo $ case (name, children) of
("argument_list", _) -> S.Args children
("array", _) -> S.Array children
("assignment", [ identifier, value ]) -> S.Assignment identifier value
("assignment", _ ) -> S.Error children
@ -43,11 +42,13 @@ termConstructor source sourceSpan name range children
("conditional_assignment", _ ) -> S.Error children
("conditional", condition : cases) -> S.Ternary condition cases
("conditional", _ ) -> S.Error children
("function_call", _) -> case runCofree <$> children of
[ _ :< S.MemberAccess{..}, _ :< S.Args args ] -> S.MethodCall memberId property args
[ _ :< S.MemberAccess{..} ] -> S.MethodCall memberId property []
[ function, _ :< S.Args args ] -> S.FunctionCall (cofree function) args
(x:xs) -> S.FunctionCall (cofree x) (cofree <$> xs)
("function_call", _) -> case children of
[ member, args ] |
category (extract member) == MemberAccess,
category (extract args) == Args -> case toList (unwrap member) of
[target, method] -> S.MethodCall target method (toList (unwrap args))
_ -> S.Error children
[ function, args ] | category (extract args) == Args -> S.FunctionCall function (toList (unwrap args))
_ -> S.Error children
("hash", _) -> S.Object $ foldMap toTuple children
("if_modifier", [ lhs, condition ]) -> S.If condition [lhs]