From 048ac119edbeee5aad44b007bc56e3a2d986ab87 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 6 Dec 2016 11:43:20 -0800 Subject: [PATCH] Remove need for Binary and Unary - just use operator instead. --- src/DiffSummary.hs | 2 -- src/Language/Ruby.hs | 9 ++------- src/Renderer/JSON.hs | 2 -- src/Syntax.hs | 4 ---- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dd99aac9b..52b8b06e8 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -258,8 +258,6 @@ toTermName source term = case unwrap term of S.Rescue args _ -> intercalate ", " $ toTermName' <$> args S.Break expr -> toTermName' expr S.Continue expr -> toTermName' expr - S.Binary clauses -> termNameFromChildren term clauses - S.Unary clauses -> termNameFromChildren term clauses where toTermName' = toTermName source termNameFromChildren term children = termNameFromRange (unionRangesFrom (range term) (range <$> children)) termNameFromSource term = termNameFromRange (range term) diff --git a/src/Language/Ruby.hs b/src/Language/Ruby.hs index 525d85519..ab18e6316 100644 --- a/src/Language/Ruby.hs +++ b/src/Language/Ruby.hs @@ -40,15 +40,10 @@ termConstructor source sourceSpan name range children allChildren condition <- withRecord (setCategory (extract expr) Negate) (S.Negate expr) withDefaultInfo $ S.While condition rest _ -> withDefaultInfo $ S.Error children - | name == "binary" = case children of + | name `elem` ["binary", "unary"] = case children of [ _, _ ] -> do allChildren' <- allChildren - withDefaultInfo $ S.Binary allChildren' - _ -> withDefaultInfo $ S.Error children - | name == "unary" = case children of - [ _ ] -> do - allChildren' <- allChildren - withDefaultInfo $ S.Unary allChildren' + withDefaultInfo $ S.Operator allChildren' _ -> withDefaultInfo $ S.Error children | otherwise = withDefaultInfo $ case (name, children) of ("argument_pair", [ k, v ] ) -> S.Pair k v diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index a25c47a10..61304385c 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -145,6 +145,4 @@ syntaxToTermField syntax = case syntax of S.TypeConversion a b -> childrenFields [a, b] S.Break expr -> [ "expression" .= expr ] S.Continue expr -> [ "expression" .= expr ] - S.Binary expressions -> [ "expressions" .= expressions ] - S.Unary expr -> [ "expression" .= expr ] where childrenFields c = [ "children" .= c ] diff --git a/src/Syntax.hs b/src/Syntax.hs index ff8594594..f5e7ad017 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -89,10 +89,6 @@ data Syntax a f | TypeConversion f f | Break f | Continue f - -- | A binary statement has two terms separated by an unamed operator production. - | Binary [f] - -- | A unary statement has one term prefixed by an unamed operator production. - | Unary [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable, ToJSON)