From 5705393b1041a8d066f2e67149a9e24ebafccd66 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 4 Nov 2016 13:42:03 -0700 Subject: [PATCH] Remove Args syntax entirely! --- src/DiffSummary.hs | 3 --- src/Language/JavaScript.hs | 13 +++++++------ src/Renderer/JSON.hs | 1 - src/Syntax.hs | 3 --- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 22861dea9..ada3ecc68 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -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 diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index 8122d11c0..4af1f2b6e 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -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 diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 60c675efa..21c5d9cf2 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -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 ] diff --git a/src/Syntax.hs b/src/Syntax.hs index a9279aa4a..1d8defe58 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -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;