1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 13:51:44 +03:00

Remove Args syntax entirely!

This commit is contained in:
Timothy Clem 2016-11-04 13:42:03 -07:00
parent 46d3066a97
commit 5705393b10
4 changed files with 7 additions and 13 deletions

View File

@ -204,9 +204,6 @@ toTermName source term = case unwrap term of
(_, _) -> toTermName' base <> "[" <> toTermName' element <> "]"
S.VarAssignment varId _ -> toTermName' varId
S.VarDecl decl -> toTermName' decl
-- TODO: We should remove Args from Syntax since I don't think we should ever
-- evaluate Args as a single toTermName Text - joshvera
S.Args args -> mconcat $ toTermName' <$> args
-- TODO: We should remove Case from Syntax since I don't think we should ever
-- evaluate Case as a single toTermName Text - joshvera
S.Case expr _ -> toTermName' expr

View File

@ -41,15 +41,16 @@ termConstructor source sourceSpan name range children
S.Indexed rest -> S.Indexed $ a : rest
_ -> S.Indexed children
("comma_op", _ ) -> 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
("ternary", condition : cases) -> S.Ternary condition cases
("ternary", _ ) -> S.Error children
("arguments", _) -> S.Args children
("var_assignment", [ x, y ]) -> S.VarAssignment x y
("var_assignment", _ ) -> S.Error children
("var_declaration", _) -> S.Indexed $ toVarDecl <$> children

View File

@ -100,7 +100,6 @@ syntaxToTermField syntax = case syntax of
S.MathAssignment identifier value -> [ "identifier" .= identifier ] <> [ "value" .= value ]
S.MemberAccess identifier value -> [ "identifier" .= identifier ] <> [ "value" .= value ]
S.MethodCall identifier methodIdentifier parameters -> [ "identifier" .= identifier ] <> [ "methodIdentifier" .= methodIdentifier ] <> [ "parameters" .= parameters ]
S.Args c -> childrenFields c
S.Operator syntaxes -> [ "operatorSyntaxes" .= syntaxes ]
S.VarDecl declaration -> [ "declaration" .= declaration ]
S.VarAssignment identifier value -> [ "identifier" .= identifier ] <> [ "value" .= value ]

View File

@ -36,9 +36,6 @@ data Syntax a f
-- | A method call consisting of its target, the method name, and the parameters passed to the method.
-- | e.g. in Javascript console.log('hello') represents a method call.
| MethodCall { targetId :: f, methodId :: f, methodParams :: [f] }
-- | The list of arguments to a method call.
-- | TODO: It might be worth removing this and using Fixed instead.
| Args [f]
-- | An operator can be applied to a list of syntaxes.
| Operator [f]
-- | A variable declaration. e.g. var foo;