From e6bf961c91f84e3ec2716b0a0b4e7a829c70014c Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Tue, 20 Mar 2018 12:52:21 +1100 Subject: [PATCH 01/20] assignment: add special-cased ruby locals state --- src/Assigning/Assignment.hs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Assigning/Assignment.hs b/src/Assigning/Assignment.hs index 7c567f6ed..8c845f922 100644 --- a/src/Assigning/Assignment.hs +++ b/src/Assigning/Assignment.hs @@ -77,6 +77,8 @@ module Assigning.Assignment , while , until , manyThrough +, getRubyLocals +, putRubyLocals -- Results , Error(..) , errorCallStack @@ -121,6 +123,8 @@ data AssignmentF ast grammar a where Alt :: [a] -> AssignmentF ast grammar a Label :: Assignment ast grammar a -> String -> AssignmentF ast grammar a Fail :: String -> AssignmentF ast grammar a + GetRubyLocals :: AssignmentF ast grammar [ByteString] + PutRubyLocals :: [ByteString] -> AssignmentF ast grammar () data Tracing f a where Tracing :: { tracingCallSite :: Maybe (String, SrcLoc), runTracing :: f a } -> Tracing f a @@ -140,6 +144,12 @@ tracing f = case getCallStack callStack of location :: HasCallStack => Assignment ast grammar (Record Location) location = tracing Location `Then` return +getRubyLocals :: HasCallStack => Assignment ast grammar [ByteString] +getRubyLocals = tracing GetRubyLocals `Then` return + +putRubyLocals :: HasCallStack => [ByteString] -> Assignment ast grammar () +putRubyLocals l = tracing (PutRubyLocals l) `Then` return + -- | Zero-width production of the current node. currentNode :: HasCallStack => Assignment ast grammar (TermF ast (Node grammar) ()) currentNode = tracing CurrentNode `Then` return @@ -239,6 +249,8 @@ runAssignment source = \ assignment state -> go assignment state >>= requireExha run yield t initialState = state `seq` maybe (anywhere Nothing) atNode (listToMaybe stateNodes) where atNode (Term (In node f)) = case runTracing t of Location -> yield (nodeLocation node) state + GetRubyLocals -> yield stateRubyLocals state + PutRubyLocals l -> yield () (state { stateRubyLocals = l }) CurrentNode -> yield (In node (() <$ f)) state Source -> yield (Source.sourceBytes (Source.slice (nodeByteRange node) source)) (advanceState state) Children child -> do @@ -277,7 +289,7 @@ skipTokens state = state { stateNodes = dropWhile ((/= Regular) . symbolType . n -- | Advances the state past the current (head) node (if any), dropping it off stateNodes, and updating stateOffset & statePos to its end; or else returns the state unchanged. advanceState :: State ast grammar -> State ast grammar advanceState state@State{..} - | Term (In Node{..} _) : rest <- stateNodes = State (end nodeByteRange) (spanEnd nodeSpan) stateCallSites rest + | Term (In Node{..} _) : rest <- stateNodes = State (end nodeByteRange) (spanEnd nodeSpan) stateCallSites rest stateRubyLocals | otherwise = state -- | State kept while running 'Assignment's. @@ -286,13 +298,14 @@ data State ast grammar = State , statePos :: {-# UNPACK #-} !Pos -- ^ The (1-indexed) line/column position in the Source thus far reached. , stateCallSites :: ![(String, SrcLoc)] -- ^ The symbols & source locations of the calls thus far. , stateNodes :: ![AST ast grammar] -- ^ The remaining nodes to assign. Note that 'children' rules recur into subterms, and thus this does not necessarily reflect all of the terms remaining to be assigned in the overall algorithm, only those “in scope.” + , stateRubyLocals :: ![ByteString] -- Special state necessary for the Ruby assignment. When we refactor Assignment to use effects we should pull this out into Language.Ruby.Assignment } deriving instance (Eq grammar, Eq1 ast) => Eq (State ast grammar) deriving instance (Show grammar, Show1 ast) => Show (State ast grammar) makeState :: [AST ast grammar] -> State ast grammar -makeState = State 0 (Pos 1 1) [] +makeState ns = State 0 (Pos 1 1) [] ns [] -- Instances @@ -374,6 +387,8 @@ instance (Enum grammar, Ix grammar, Show grammar, Show1 ast) => Show1 (Assignmen Alt as -> showsUnaryWith (const sl) "Alt" d (toList as) Label child string -> showsBinaryWith (liftShowsPrec sp sl) showsPrec "Label" d child string Fail s -> showsUnaryWith showsPrec "Fail" d s + GetRubyLocals -> showString "GetRubyLocals" + PutRubyLocals _ -> showString "PutRubyLocals _" where showChild = liftShowsPrec sp sl showChildren = liftShowList sp sl From ba99be7345f4208512789223b2a9c948801258c6 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Tue, 20 Mar 2018 16:19:27 +1100 Subject: [PATCH 02/20] ruby: emit barewords that aren't defined locals as method calls --- src/Language/Ruby/Assignment.hs | 17 +++++++++++++---- test/Assigning/Assignment/Spec.hs | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index dfb6bc194..eaf2b1ed4 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -111,6 +111,7 @@ expressionChoices = , for , heredoc , identifier + , misc , if' , lambda , literal @@ -147,10 +148,18 @@ parenthesizedExpressions :: Assignment parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions) identifier :: Assignment -identifier = - mk Identifier - <|> mk Identifier' - <|> mk Constant +identifier = do + sym <- symbol Identifier <|> symbol Identifier' + locals <- getRubyLocals + ident <- source + let term = makeTerm sym (Syntax.Identifier $ name ident) + if ident `elem` locals + then pure term + else makeTerm sym <$> (Expression.Call [] term [] <$> emptyTerm) + +misc :: Assignment +misc = + mk Constant <|> mk InstanceVariable <|> mk ClassVariable <|> mk GlobalVariable diff --git a/test/Assigning/Assignment/Spec.hs b/test/Assigning/Assignment/Spec.hs index e4327a153..66e805430 100644 --- a/test/Assigning/Assignment/Spec.hs +++ b/test/Assigning/Assignment/Spec.hs @@ -188,13 +188,13 @@ spec = do it "advances past the current node" $ snd <$> runAssignment "hi" source (makeState [ node Red 0 2 [] ]) `shouldBe` - Right (State 2 (Pos 1 3) [] []) + Right (State 2 (Pos 1 3) [] [] []) describe "children" $ do it "advances past the current node" $ snd <$> runAssignment "a" (children (pure (Out ""))) (makeState [node Red 0 1 []]) `shouldBe` - Right (State 1 (Pos 1 2) [] []) + Right (State 1 (Pos 1 2) [] [] []) it "matches if its subrule matches" $ () <$ runAssignment "a" (children red) (makeState [node Blue 0 1 [node Red 0 1 []]]) From 8dfaae81e1fd626eb3c8e2f287d6c7d4952ef899 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Tue, 20 Mar 2018 17:14:38 +1100 Subject: [PATCH 03/20] ruby: define locals as they are encountered --- src/Language/Ruby/Assignment.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index eaf2b1ed4..e3a84ab01 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -379,8 +379,17 @@ assignment' = makeTerm <$> symbol Assignment <*> children (Statement.As rhs = makeTerm <$> symbol RightAssignmentList <*> children (many expr) <|> expr expr = makeTerm <$> symbol RestAssignment <*> (Syntax.Identifier . name <$> source) <|> makeTerm <$> symbol DestructuredLeftAssignment <*> children (many expr) + <|> lhsIdent <|> expression +lhsIdent :: Assignment +lhsIdent = do + sym <- symbol Identifier <|> symbol Identifier' + locals <- getRubyLocals + ident <- source + putRubyLocals (ident : locals) + pure $ makeTerm sym $ Syntax.Identifier $ name ident + unary :: Assignment unary = symbol Unary >>= \ location -> makeTerm location . Expression.Complement <$> children ( symbol AnonTilde *> expression ) From 437df993b546a814b074d8582fdfa078c5520b31 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 26 Mar 2018 16:41:05 +1100 Subject: [PATCH 04/20] ruby: pull out some duplication in block assignment --- src/Language/Ruby/Assignment.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index e3a84ab01..ea0b27094 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -243,9 +243,10 @@ lambda = makeTerm <$> symbol Lambda <*> children ( <*> expressions) block :: Assignment -block = makeTerm <$> symbol DoBlock <*> children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions) - <|> makeTerm <$> symbol Block <*> children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions) - where params = symbol BlockParameters *> children (many parameter) <|> pure [] +block = makeTerm <$> symbol DoBlock <*> blockChildren + <|> makeTerm <$> symbol Block <*> blockChildren + where blockChildren = children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions) + params = symbol BlockParameters *> children (many parameter) <|> pure [] comment :: Assignment comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) From ccca1e58571fc9b53c80e8ae1b43209ab5566017 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 26 Mar 2018 17:00:30 +1100 Subject: [PATCH 05/20] ruby: implement variable scoping around scoped constructs --- src/Language/Ruby/Assignment.hs | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index ea0b27094..0203cb119 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -147,6 +147,18 @@ expressions = makeTerm'' <$> location <*> many expression parenthesizedExpressions :: Assignment parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions) +withExtendedScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withExtendedScope inner = do + locals <- getRubyLocals + result <- inner + putRubyLocals locals + pure result + +withNewScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withNewScope inner = withExtendedScope $ do + putRubyLocals [] + inner + identifier :: Assignment identifier = do sym <- symbol Identifier <|> symbol Identifier' @@ -204,14 +216,14 @@ endBlock :: Assignment endBlock = makeTerm <$> symbol EndBlock <*> children (Statement.ScopeExit <$> many expression) class' :: Assignment -class' = makeTerm <$> symbol Class <*> children (Ruby.Syntax.Class <$> expression <*> (superclass <|> pure []) <*> expressions) +class' = makeTerm <$> symbol Class <*> (withNewScope . children) (Ruby.Syntax.Class <$> expression <*> (superclass <|> pure []) <*> expressions) where superclass = pure <$ symbol Superclass <*> children expression singletonClass :: Assignment -singletonClass = makeTerm <$> symbol SingletonClass <*> children (Ruby.Syntax.Class <$> expression <*> pure [] <*> expressions) +singletonClass = makeTerm <$> symbol SingletonClass <*> (withNewScope . children) (Ruby.Syntax.Class <$> expression <*> pure [] <*> expressions) module' :: Assignment -module' = makeTerm <$> symbol Module <*> children (Ruby.Syntax.Module <$> expression <*> many expression) +module' = makeTerm <$> symbol Module <*> (withNewScope . children) (Ruby.Syntax.Module <$> expression <*> many expression) scopeResolution :: Assignment scopeResolution = makeTerm <$> symbol ScopeResolution <*> children (Expression.ScopeResolution <$> many expression) @@ -228,24 +240,25 @@ parameter = where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) method :: Assignment -method = makeTerm <$> symbol Method <*> children (Declaration.Method <$> pure [] <*> emptyTerm <*> expression <*> params <*> expressions') +method = makeTerm <$> symbol Method <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> emptyTerm <*> expression <*> params <*> expressions') where params = symbol MethodParameters *> children (many parameter) <|> pure [] expressions' = makeTerm <$> location <*> many expression singletonMethod :: Assignment -singletonMethod = makeTerm <$> symbol SingletonMethod <*> children (Declaration.Method <$> pure [] <*> expression <*> expression <*> params <*> expressions) +singletonMethod = makeTerm <$> symbol SingletonMethod <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> expression <*> expression <*> params <*> expressions) where params = symbol MethodParameters *> children (many parameter) <|> pure [] lambda :: Assignment -lambda = makeTerm <$> symbol Lambda <*> children ( +lambda = makeTerm <$> symbol Lambda <*> (withExtendedScope . children) ( Declaration.Function [] <$> emptyTerm <*> ((symbol BlockParameters <|> symbol LambdaParameters) *> children (many parameter) <|> pure []) <*> expressions) block :: Assignment -block = makeTerm <$> symbol DoBlock <*> blockChildren - <|> makeTerm <$> symbol Block <*> blockChildren - where blockChildren = children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions) +block = makeTerm <$> symbol DoBlock <*> scopedBlockChildren + <|> makeTerm <$> symbol Block <*> scopedBlockChildren + where scopedBlockChildren = withExtendedScope blockChildren + blockChildren = children (Declaration.Function <$> pure [] <*> emptyTerm <*> params <*> expressions) params = symbol BlockParameters *> children (many parameter) <|> pure [] comment :: Assignment From 237ffea2943fe27f47e8536b5123a414fc0ada25 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 4 Apr 2018 19:07:03 +1000 Subject: [PATCH 06/20] alternate with End in putRubyLocals --- src/Assigning/Assignment.hs | 6 ++++-- src/Language/Ruby/Assignment.hs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Assigning/Assignment.hs b/src/Assigning/Assignment.hs index 8c845f922..676b9af40 100644 --- a/src/Assigning/Assignment.hs +++ b/src/Assigning/Assignment.hs @@ -147,8 +147,10 @@ location = tracing Location `Then` return getRubyLocals :: HasCallStack => Assignment ast grammar [ByteString] getRubyLocals = tracing GetRubyLocals `Then` return -putRubyLocals :: HasCallStack => [ByteString] -> Assignment ast grammar () -putRubyLocals l = tracing (PutRubyLocals l) `Then` return +putRubyLocals :: (HasCallStack, Enum grammar, Eq1 ast, Ix grammar) => [ByteString] -> Assignment ast grammar () +putRubyLocals l = mk (PutRubyLocals l) <|> mk End + where + mk a = tracing a `Then` return -- | Zero-width production of the current node. currentNode :: HasCallStack => Assignment ast grammar (TermF ast (Node grammar) ()) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 0203cb119..729616a4e 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -147,14 +147,14 @@ expressions = makeTerm'' <$> location <*> many expression parenthesizedExpressions :: Assignment parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions) -withExtendedScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withExtendedScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a withExtendedScope inner = do locals <- getRubyLocals result <- inner putRubyLocals locals pure result -withNewScope :: Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withNewScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a withNewScope inner = withExtendedScope $ do putRubyLocals [] inner From 5ff04bebcce0809b3efd0bddfa81b890d5a10e14 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 4 Apr 2018 19:10:35 +1000 Subject: [PATCH 07/20] ruby: add Assignment' type so we can remove type constraints --- src/Language/Ruby/Assignment.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 729616a4e..3666bd6c7 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -147,14 +147,14 @@ expressions = makeTerm'' <$> location <*> many expression parenthesizedExpressions :: Assignment parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions) -withExtendedScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withExtendedScope :: Assignment' a -> Assignment' a withExtendedScope inner = do locals <- getRubyLocals result <- inner putRubyLocals locals pure result -withNewScope :: (Enum grammar, Ix grammar, Eq1 ast) => Assignment.Assignment ast grammar a -> Assignment.Assignment ast grammar a +withNewScope :: Assignment' a -> Assignment' a withNewScope inner = withExtendedScope $ do putRubyLocals [] inner From 024d1c362ed80f824bb9cc297615c7ba8374b8f6 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 9 Apr 2018 15:19:21 -0700 Subject: [PATCH 08/20] Allow ability to prioritize local identifiers for certain syntaxes --- src/Language/Ruby/Assignment.hs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 3666bd6c7..20c2fe6ac 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -111,7 +111,6 @@ expressionChoices = , for , heredoc , identifier - , misc , if' , lambda , literal @@ -159,19 +158,11 @@ withNewScope inner = withExtendedScope $ do putRubyLocals [] inner +-- Looks up identifiers in the list of locals to determine vcall vs. local identifier. identifier :: Assignment -identifier = do - sym <- symbol Identifier <|> symbol Identifier' - locals <- getRubyLocals - ident <- source - let term = makeTerm sym (Syntax.Identifier $ name ident) - if ident `elem` locals - then pure term - else makeTerm sym <$> (Expression.Call [] term [] <$> emptyTerm) - -misc :: Assignment -misc = - mk Constant +identifier = + vcallOrLocal + <|> mk Constant <|> mk InstanceVariable <|> mk ClassVariable <|> mk GlobalVariable @@ -183,7 +174,19 @@ misc = <|> mk HashSplatArgument <|> mk BlockArgument <|> mk Uninterpreted - where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) + where + mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) + vcallOrLocal = do + loc <- symbol Identifier <|> symbol Identifier' + locals <- getRubyLocals + ident <- source + if ident `elem` locals + then pure $ makeTerm loc (Syntax.Identifier (name ident)) + else makeTerm loc <$> (Expression.Call [] (makeTerm loc (Syntax.Identifier (name ident))) [] <$> emptyTerm) + +-- Regular identifiers prioritized over vcalls. +plainIdentifier :: Assignment +plainIdentifier = makeTerm <$> (symbol Identifier <|> symbol Identifier') <*> (Syntax.Identifier . name <$> source) -- TODO: Handle interpolation in all literals that support it (strings, regexes, symbols, subshells, etc). literal :: Assignment @@ -240,7 +243,7 @@ parameter = where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) method :: Assignment -method = makeTerm <$> symbol Method <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> emptyTerm <*> expression <*> params <*> expressions') +method = makeTerm <$> symbol Method <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> emptyTerm <*> (plainIdentifier <|> expression) <*> params <*> expressions') where params = symbol MethodParameters *> children (many parameter) <|> pure [] expressions' = makeTerm <$> location <*> many expression From 66720795cc8c62e4f75a1cf34924b3ee803e7223 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 13:57:52 +1000 Subject: [PATCH 09/20] ruby: allow Setter symbols in methodSelector --- src/Language/Ruby/Assignment.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 20c2fe6ac..ed3af9e03 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -350,6 +350,7 @@ methodSelector = makeTerm <$> symbols <*> (Syntax.Identifier <$> (name <$> sourc <|> symbol Identifier' <|> symbol Constant <|> symbol Operator + <|> symbol Setter <|> symbol Super -- TODO(@charliesome): super calls are *not* method calls and need to be assigned into their own syntax terms call :: Assignment From c5be01e8a0007f8de18848c3feebc3347d97b51d Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 14:32:15 +1000 Subject: [PATCH 10/20] ruby: use methodSelector rather than plainIdentifier for def names --- src/Language/Ruby/Assignment.hs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index ed3af9e03..453c05304 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -184,10 +184,6 @@ identifier = then pure $ makeTerm loc (Syntax.Identifier (name ident)) else makeTerm loc <$> (Expression.Call [] (makeTerm loc (Syntax.Identifier (name ident))) [] <$> emptyTerm) --- Regular identifiers prioritized over vcalls. -plainIdentifier :: Assignment -plainIdentifier = makeTerm <$> (symbol Identifier <|> symbol Identifier') <*> (Syntax.Identifier . name <$> source) - -- TODO: Handle interpolation in all literals that support it (strings, regexes, symbols, subshells, etc). literal :: Assignment literal = @@ -243,12 +239,12 @@ parameter = where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) method :: Assignment -method = makeTerm <$> symbol Method <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> emptyTerm <*> (plainIdentifier <|> expression) <*> params <*> expressions') +method = makeTerm <$> symbol Method <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> emptyTerm <*> methodSelector <*> params <*> expressions') where params = symbol MethodParameters *> children (many parameter) <|> pure [] expressions' = makeTerm <$> location <*> many expression singletonMethod :: Assignment -singletonMethod = makeTerm <$> symbol SingletonMethod <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> expression <*> expression <*> params <*> expressions) +singletonMethod = makeTerm <$> symbol SingletonMethod <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> expression <*> methodSelector <*> params <*> expressions) where params = symbol MethodParameters *> children (many parameter) <|> pure [] lambda :: Assignment From d08c6753181437f2b5475d0ad66605d5d6f97a08 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 15:05:39 +1000 Subject: [PATCH 11/20] ruby: make parameter assignment more strict in accepted symbols --- src/Language/Ruby/Assignment.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 453c05304..51b4c0b35 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -229,13 +229,14 @@ scopeResolution = makeTerm <$> symbol ScopeResolution <*> children (Expression.S parameter :: Assignment parameter = - mk SplatParameter + mk Identifier + <|> mk Identifier' + <|> mk SplatParameter <|> mk HashSplatParameter <|> mk BlockParameter <|> mk KeywordParameter <|> mk OptionalParameter <|> makeTerm <$> symbol DestructuredParameter <*> children (many parameter) - <|> expression where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) method :: Assignment From c9995570434f96817b43aceb41ecd3227ea1ea49 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 15:05:59 +1000 Subject: [PATCH 12/20] ruby: emit Send terms from vcallOrLocal rather than Call --- src/Language/Ruby/Assignment.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 51b4c0b35..c0c619121 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -180,9 +180,10 @@ identifier = loc <- symbol Identifier <|> symbol Identifier' locals <- getRubyLocals ident <- source + let identTerm = makeTerm loc (Syntax.Identifier (name ident)) if ident `elem` locals - then pure $ makeTerm loc (Syntax.Identifier (name ident)) - else makeTerm loc <$> (Expression.Call [] (makeTerm loc (Syntax.Identifier (name ident))) [] <$> emptyTerm) + then pure identTerm + else pure $ makeTerm loc (Ruby.Syntax.Send Nothing (Just identTerm) [] Nothing) -- TODO: Handle interpolation in all literals that support it (strings, regexes, symbols, subshells, etc). literal :: Assignment From 2d320fdba1b795f1d0a62e4df0a613330e382db4 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 15:07:05 +1000 Subject: [PATCH 13/20] ruby: update test fixtures --- test/fixtures/ruby/alias.parseA.txt | 29 +++++ test/fixtures/ruby/and-or.diffA-B.txt | 20 ++- test/fixtures/ruby/and-or.diffB-A.txt | 21 ++- test/fixtures/ruby/and-or.parseA.txt | 6 +- test/fixtures/ruby/and-or.parseB.txt | 15 ++- test/fixtures/ruby/begin-block.diffA-B.txt | 8 +- test/fixtures/ruby/begin-block.diffB-A.txt | 9 +- test/fixtures/ruby/begin-block.parseA.txt | 3 +- test/fixtures/ruby/begin-block.parseB.txt | 6 +- test/fixtures/ruby/binary.parseA.txt | 121 ++++++++++++++++++ .../ruby/bitwise-operator.diffA-B.txt | 30 +++-- .../ruby/bitwise-operator.diffB-A.txt | 30 +++-- .../fixtures/ruby/bitwise-operator.parseA.txt | 18 ++- .../fixtures/ruby/bitwise-operator.parseB.txt | 12 +- .../ruby/boolean-operator.diffA-B.txt | 12 +- .../ruby/boolean-operator.diffB-A.txt | 12 +- .../fixtures/ruby/boolean-operator.parseA.txt | 6 +- .../fixtures/ruby/boolean-operator.parseB.txt | 6 +- test/fixtures/ruby/break.diffA-B.txt | 6 +- test/fixtures/ruby/break.diffB-A.txt | 6 +- test/fixtures/ruby/break.parseA.txt | 3 +- test/fixtures/ruby/break.parseB.txt | 3 +- test/fixtures/ruby/calls.parseA.txt | 33 +++++ test/fixtures/ruby/chained-string.parseA.txt | 4 + .../ruby/comparision-operator.diffA-B.txt | 24 ++-- .../ruby/comparision-operator.diffB-A.txt | 24 ++-- .../ruby/comparision-operator.parseA.txt | 12 +- .../ruby/comparision-operator.parseB.txt | 12 +- .../ruby/element-reference.diffA-B.txt | 19 ++- .../ruby/element-reference.diffB-A.txt | 19 ++- .../ruby/element-reference.parseA.txt | 15 ++- .../ruby/element-reference.parseB.txt | 6 +- test/fixtures/ruby/elsif.diffA-B.txt | 6 +- test/fixtures/ruby/elsif.diffB-A.txt | 6 +- test/fixtures/ruby/elsif.parseA.txt | 6 +- test/fixtures/ruby/elsif.parseB.txt | 6 +- test/fixtures/ruby/empty-statement.parseA.txt | 2 + test/fixtures/ruby/end-block.diffA-B.txt | 8 +- test/fixtures/ruby/end-block.diffB-A.txt | 9 +- test/fixtures/ruby/end-block.parseA.txt | 3 +- test/fixtures/ruby/end-block.parseB.txt | 6 +- test/fixtures/ruby/ensure.diffA-B.txt | 6 +- test/fixtures/ruby/ensure.diffB-A.txt | 6 +- test/fixtures/ruby/ensure.parseA.txt | 3 +- test/fixtures/ruby/ensure.parseB.txt | 6 +- test/fixtures/ruby/for.diffA-B.txt | 32 +++-- test/fixtures/ruby/for.diffB-A.txt | 31 +++-- test/fixtures/ruby/for.parseA.txt | 26 ++-- test/fixtures/ruby/for.parseB.txt | 6 +- test/fixtures/ruby/hash.diffA-B.txt | 12 +- test/fixtures/ruby/hash.diffB-A.txt | 12 +- test/fixtures/ruby/hash.parseA.txt | 3 +- test/fixtures/ruby/hash.parseB.txt | 9 +- .../ruby/if-unless-modifiers.diffA-B.txt | 9 +- .../ruby/if-unless-modifiers.diffB-A.txt | 9 +- .../ruby/if-unless-modifiers.parseA.txt | 4 +- .../ruby/if-unless-modifiers.parseB.txt | 6 +- test/fixtures/ruby/if.diffA-B.txt | 20 ++- test/fixtures/ruby/if.diffB-A.txt | 20 ++- test/fixtures/ruby/if.parseA.txt | 15 ++- test/fixtures/ruby/if.parseB.txt | 6 +- test/fixtures/ruby/keywords.parseA.txt | 7 + .../ruby/lambda-dash-rocket.diffA-B.txt | 3 +- .../ruby/lambda-dash-rocket.diffB-A.txt | 3 +- .../ruby/lambda-dash-rocket.parseB.txt | 3 +- test/fixtures/ruby/lambda.diffA-B.txt | 9 +- test/fixtures/ruby/lambda.diffB-A.txt | 9 +- test/fixtures/ruby/lambda.parseA.txt | 6 +- test/fixtures/ruby/lambda.parseB.txt | 3 +- test/fixtures/ruby/literals.parseA.txt | 16 +++ .../method-calls-keyword-args.diffA-B.txt | 6 +- .../method-calls-keyword-args.diffB-A.txt | 6 +- .../ruby/method-calls-keyword-args.parseA.txt | 3 +- .../ruby/method-calls-keyword-args.parseB.txt | 6 +- test/fixtures/ruby/method-calls.diffA-B.txt | 15 ++- test/fixtures/ruby/method-calls.diffB-A.txt | 15 ++- test/fixtures/ruby/method-calls.parseA.txt | 15 ++- .../ruby/method-declaration.diffA-B.txt | 3 +- .../ruby/method-declaration.diffB-A.txt | 3 +- .../ruby/method-declaration.parseB.txt | 3 +- .../ruby/method-invocation.diffA-B.txt | 19 ++- .../ruby/method-invocation.diffB-A.txt | 15 +-- .../ruby/method-invocation.parseA.txt | 9 +- .../ruby/method-invocation.parseB.txt | 3 +- test/fixtures/ruby/methods.parseA.txt | 42 ++++++ test/fixtures/ruby/misc.parseA.txt | 27 ++++ .../ruby/multiple-assignments.diffA-B.txt | 6 +- .../ruby/multiple-assignments.diffB-A.txt | 6 +- .../ruby/multiple-assignments.parseA.txt | 6 +- test/fixtures/ruby/next.parseA.txt | 9 ++ test/fixtures/ruby/percent-array.diffA-B.txt | 3 +- test/fixtures/ruby/percent-array.diffB-A.txt | 3 +- test/fixtures/ruby/percent-array.parseB.txt | 3 +- .../ruby/relational-operator.diffA-B.txt | 33 +++-- .../ruby/relational-operator.diffB-A.txt | 33 +++-- .../ruby/relational-operator.parseA.txt | 18 ++- .../ruby/relational-operator.parseB.txt | 15 ++- test/fixtures/ruby/require.diffA-B.txt | 3 +- test/fixtures/ruby/require.diffB-A.txt | 3 +- test/fixtures/ruby/require.parseA.txt | 3 +- test/fixtures/ruby/rescue-empty.diffA-B.txt | 6 +- test/fixtures/ruby/rescue-empty.diffB-A.txt | 6 +- test/fixtures/ruby/rescue-empty.parseA.txt | 3 +- test/fixtures/ruby/rescue-empty.parseB.txt | 6 +- test/fixtures/ruby/rescue-last-ex.diffA-B.txt | 9 +- test/fixtures/ruby/rescue-last-ex.diffB-A.txt | 9 +- test/fixtures/ruby/rescue-last-ex.parseA.txt | 6 +- test/fixtures/ruby/rescue-last-ex.parseB.txt | 9 +- .../fixtures/ruby/rescue-modifier.diffA-B.txt | 3 +- .../fixtures/ruby/rescue-modifier.diffB-A.txt | 3 +- test/fixtures/ruby/rescue-modifier.parseA.txt | 3 +- test/fixtures/ruby/rescue-modifier.parseB.txt | 3 +- .../ruby/rescue-modifier2.diffA-B.txt | 5 +- .../ruby/rescue-modifier2.diffB-A.txt | 5 +- .../fixtures/ruby/rescue-modifier2.parseA.txt | 3 +- .../fixtures/ruby/rescue-modifier2.parseB.txt | 3 +- test/fixtures/ruby/rescue.diffA-B.txt | 35 +++-- test/fixtures/ruby/rescue.diffB-A.txt | 44 ++++--- test/fixtures/ruby/rescue.parseA.txt | 21 ++- test/fixtures/ruby/rescue.parseB.txt | 9 +- test/fixtures/ruby/return.diffA-B.txt | 3 +- test/fixtures/ruby/return.diffB-A.txt | 3 +- test/fixtures/ruby/return.parseA.txt | 3 +- test/fixtures/ruby/singleton-class.parseA.txt | 11 ++ test/fixtures/ruby/ternary.diffA-B.txt | 15 ++- test/fixtures/ruby/ternary.diffB-A.txt | 15 ++- test/fixtures/ruby/ternary.parseA.txt | 9 +- test/fixtures/ruby/ternary.parseB.txt | 9 +- test/fixtures/ruby/unary.parseA.txt | 20 +++ test/fixtures/ruby/undef.parseA.txt | 27 ++++ test/fixtures/ruby/unless.diffA-B.txt | 12 +- test/fixtures/ruby/unless.diffB-A.txt | 14 +- test/fixtures/ruby/unless.parseA.txt | 9 +- test/fixtures/ruby/unless.parseB.txt | 6 +- test/fixtures/ruby/until.diffA-B.txt | 12 +- test/fixtures/ruby/until.diffB-A.txt | 12 +- test/fixtures/ruby/until.parseA.txt | 9 +- test/fixtures/ruby/until.parseB.txt | 6 +- test/fixtures/ruby/when-else.diffA-B.txt | 23 ++-- test/fixtures/ruby/when-else.diffB-A.txt | 23 ++-- test/fixtures/ruby/when-else.parseA.txt | 15 ++- test/fixtures/ruby/when-else.parseB.txt | 12 +- test/fixtures/ruby/when.diffA-B.txt | 18 ++- test/fixtures/ruby/when.diffB-A.txt | 18 ++- test/fixtures/ruby/when.parseA.txt | 6 +- test/fixtures/ruby/when.parseB.txt | 18 ++- test/fixtures/ruby/while.diffA-B.txt | 12 +- test/fixtures/ruby/while.diffB-A.txt | 12 +- test/fixtures/ruby/while.parseA.txt | 9 +- test/fixtures/ruby/while.parseB.txt | 6 +- test/fixtures/ruby/yield.diffA-B.txt | 3 +- test/fixtures/ruby/yield.diffB-A.txt | 3 +- test/fixtures/ruby/yield.parseA.txt | 3 +- 153 files changed, 1306 insertions(+), 497 deletions(-) create mode 100644 test/fixtures/ruby/alias.parseA.txt create mode 100644 test/fixtures/ruby/binary.parseA.txt create mode 100644 test/fixtures/ruby/calls.parseA.txt create mode 100644 test/fixtures/ruby/chained-string.parseA.txt create mode 100644 test/fixtures/ruby/empty-statement.parseA.txt create mode 100644 test/fixtures/ruby/keywords.parseA.txt create mode 100644 test/fixtures/ruby/literals.parseA.txt create mode 100644 test/fixtures/ruby/methods.parseA.txt create mode 100644 test/fixtures/ruby/misc.parseA.txt create mode 100644 test/fixtures/ruby/next.parseA.txt create mode 100644 test/fixtures/ruby/singleton-class.parseA.txt create mode 100644 test/fixtures/ruby/unary.parseA.txt create mode 100644 test/fixtures/ruby/undef.parseA.txt diff --git a/test/fixtures/ruby/alias.parseA.txt b/test/fixtures/ruby/alias.parseA.txt new file mode 100644 index 000000000..27cc8cba6 --- /dev/null +++ b/test/fixtures/ruby/alias.parseA.txt @@ -0,0 +1,29 @@ +(Program + (Call + (Identifier) + (Symbol) + (Symbol) + (Empty)) + (Call + (Identifier) + (Send + (Identifier)) + (Send + (Identifier)) + (Empty)) + (Call + (Identifier) + (Identifier) + (Identifier) + (Empty)) + (Call + (Identifier) + (Send + (Identifier)) + (Identifier) + (Empty)) + (Call + (Identifier) + (Identifier) + (Identifier) + (Empty))) diff --git a/test/fixtures/ruby/and-or.diffA-B.txt b/test/fixtures/ruby/and-or.diffA-B.txt index f907e219b..59064ebaa 100644 --- a/test/fixtures/ruby/and-or.diffA-B.txt +++ b/test/fixtures/ruby/and-or.diffA-B.txt @@ -1,11 +1,17 @@ (Program {+(LowOr - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} (LowAnd - { (Identifier) + { (Send + {-(Identifier)-}) ->(LowOr - {+(Identifier)+} - {+(Identifier)+}) } - { (Identifier) - ->(Identifier) })) + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } + (Send + { (Identifier) + ->(Identifier) }))) diff --git a/test/fixtures/ruby/and-or.diffB-A.txt b/test/fixtures/ruby/and-or.diffB-A.txt index c4763f2af..1373e5c10 100644 --- a/test/fixtures/ruby/and-or.diffB-A.txt +++ b/test/fixtures/ruby/and-or.diffB-A.txt @@ -1,12 +1,19 @@ (Program {+(LowAnd - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {-(LowOr - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(LowAnd {-(LowOr - {-(Identifier)-} - {-(Identifier)-})-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/and-or.parseA.txt b/test/fixtures/ruby/and-or.parseA.txt index 525576644..ec8570ce4 100644 --- a/test/fixtures/ruby/and-or.parseA.txt +++ b/test/fixtures/ruby/and-or.parseA.txt @@ -1,4 +1,6 @@ (Program (LowAnd - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/and-or.parseB.txt b/test/fixtures/ruby/and-or.parseB.txt index b197a4de3..86b46393a 100644 --- a/test/fixtures/ruby/and-or.parseB.txt +++ b/test/fixtures/ruby/and-or.parseB.txt @@ -1,9 +1,14 @@ (Program (LowOr - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (LowAnd (LowOr - (Identifier) - (Identifier)) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/begin-block.diffA-B.txt b/test/fixtures/ruby/begin-block.diffA-B.txt index bce079417..589587a85 100644 --- a/test/fixtures/ruby/begin-block.diffA-B.txt +++ b/test/fixtures/ruby/begin-block.diffA-B.txt @@ -1,5 +1,7 @@ (Program -{+(Identifier)+} +{+(Send + {+(Identifier)+})+} (ScopeEntry - { (Identifier) - ->(Identifier) })) + (Send + { (Identifier) + ->(Identifier) }))) diff --git a/test/fixtures/ruby/begin-block.diffB-A.txt b/test/fixtures/ruby/begin-block.diffB-A.txt index 5f8c646b9..7e879840b 100644 --- a/test/fixtures/ruby/begin-block.diffB-A.txt +++ b/test/fixtures/ruby/begin-block.diffB-A.txt @@ -1,6 +1,9 @@ (Program {+(ScopeEntry - {+(Identifier)+})+} -{-(Identifier)-} + {+(Send + {+(Identifier)+})+})+} +{-(Send + {-(Identifier)-})-} {-(ScopeEntry - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/begin-block.parseA.txt b/test/fixtures/ruby/begin-block.parseA.txt index 119631558..d34ffb026 100644 --- a/test/fixtures/ruby/begin-block.parseA.txt +++ b/test/fixtures/ruby/begin-block.parseA.txt @@ -1,3 +1,4 @@ (Program (ScopeEntry - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/begin-block.parseB.txt b/test/fixtures/ruby/begin-block.parseB.txt index 047a4c326..ae6f5c244 100644 --- a/test/fixtures/ruby/begin-block.parseB.txt +++ b/test/fixtures/ruby/begin-block.parseB.txt @@ -1,4 +1,6 @@ (Program - (Identifier) + (Send + (Identifier)) (ScopeEntry - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/binary.parseA.txt b/test/fixtures/ruby/binary.parseA.txt new file mode 100644 index 000000000..0c5b11c8a --- /dev/null +++ b/test/fixtures/ruby/binary.parseA.txt @@ -0,0 +1,121 @@ +(Program + (And + (Send + (Identifier)) + (Send + (Identifier))) + (LowAnd + (Send + (Identifier)) + (Send + (Identifier))) + (LowOr + (Send + (Identifier)) + (Send + (Identifier))) + (Or + (Send + (Identifier)) + (Send + (Identifier))) + (Plus + (Send + (Identifier)) + (Send + (Identifier))) + (Context + (Comment) + (LShift + (Send + (Identifier)) + (Send + (Identifier)))) + (RShift + (Send + (Identifier)) + (Send + (Identifier))) + (BOr + (Send + (Identifier)) + (Send + (Identifier))) + (BAnd + (Send + (Identifier)) + (Send + (Identifier))) + (BXOr + (Send + (Identifier)) + (Send + (Identifier))) + (Equal + (Send + (Identifier)) + (Send + (Identifier))) + (Not + (Equal + (Send + (Identifier)) + (Send + (Identifier)))) + (Equal + (Send + (Identifier)) + (Send + (Identifier))) + (Comparison + (Send + (Identifier)) + (Send + (Identifier))) + (Matches + (Send + (Identifier)) + (Send + (Identifier))) + (NotMatches + (Send + (Identifier)) + (Send + (Identifier))) + (LessThan + (Send + (Identifier)) + (Send + (Identifier))) + (LessThanEqual + (Send + (Identifier)) + (Send + (Identifier))) + (GreaterThan + (Send + (Identifier)) + (Send + (Identifier))) + (GreaterThanEqual + (Send + (Identifier)) + (Send + (Identifier))) + (Context + (Comment) + (DividedBy + (Send + (Identifier)) + (Send + (Identifier)))) + (Modulo + (Send + (Identifier)) + (Send + (Identifier))) + (Power + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/bitwise-operator.diffA-B.txt b/test/fixtures/ruby/bitwise-operator.diffA-B.txt index 564f3f500..a138e990c 100644 --- a/test/fixtures/ruby/bitwise-operator.diffA-B.txt +++ b/test/fixtures/ruby/bitwise-operator.diffA-B.txt @@ -1,16 +1,26 @@ (Program { (BOr - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(BAnd - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } { (RShift - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(LShift - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } {-(BXOr - {-(Identifier)-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/bitwise-operator.diffB-A.txt b/test/fixtures/ruby/bitwise-operator.diffB-A.txt index c0f6cdb2e..0b0691a8a 100644 --- a/test/fixtures/ruby/bitwise-operator.diffB-A.txt +++ b/test/fixtures/ruby/bitwise-operator.diffB-A.txt @@ -1,16 +1,26 @@ (Program { (BAnd - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(BOr - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } { (LShift - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(RShift - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } {+(BXOr - {+(Identifier)+} - {+(Identifier)+})+}) + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+}) diff --git a/test/fixtures/ruby/bitwise-operator.parseA.txt b/test/fixtures/ruby/bitwise-operator.parseA.txt index 7df45acc6..0a5e552c0 100644 --- a/test/fixtures/ruby/bitwise-operator.parseA.txt +++ b/test/fixtures/ruby/bitwise-operator.parseA.txt @@ -1,10 +1,16 @@ (Program (BOr - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (RShift - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (BXOr - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/bitwise-operator.parseB.txt b/test/fixtures/ruby/bitwise-operator.parseB.txt index 8bb14118b..93dd893b3 100644 --- a/test/fixtures/ruby/bitwise-operator.parseB.txt +++ b/test/fixtures/ruby/bitwise-operator.parseB.txt @@ -1,7 +1,11 @@ (Program (BAnd - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (LShift - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/boolean-operator.diffA-B.txt b/test/fixtures/ruby/boolean-operator.diffA-B.txt index 365405c5c..24c997557 100644 --- a/test/fixtures/ruby/boolean-operator.diffA-B.txt +++ b/test/fixtures/ruby/boolean-operator.diffA-B.txt @@ -1,7 +1,11 @@ (Program { (Or - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(And - {+(Identifier)+} - {+(Identifier)+}) }) + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) }) diff --git a/test/fixtures/ruby/boolean-operator.diffB-A.txt b/test/fixtures/ruby/boolean-operator.diffB-A.txt index bab8a9ceb..6fc07b317 100644 --- a/test/fixtures/ruby/boolean-operator.diffB-A.txt +++ b/test/fixtures/ruby/boolean-operator.diffB-A.txt @@ -1,7 +1,11 @@ (Program { (And - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(Or - {+(Identifier)+} - {+(Identifier)+}) }) + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) }) diff --git a/test/fixtures/ruby/boolean-operator.parseA.txt b/test/fixtures/ruby/boolean-operator.parseA.txt index ac8cbd824..b8c198b5a 100644 --- a/test/fixtures/ruby/boolean-operator.parseA.txt +++ b/test/fixtures/ruby/boolean-operator.parseA.txt @@ -1,4 +1,6 @@ (Program (Or - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/boolean-operator.parseB.txt b/test/fixtures/ruby/boolean-operator.parseB.txt index c45251d63..3f3c6c943 100644 --- a/test/fixtures/ruby/boolean-operator.parseB.txt +++ b/test/fixtures/ruby/boolean-operator.parseB.txt @@ -1,4 +1,6 @@ (Program (And - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/break.diffA-B.txt b/test/fixtures/ruby/break.diffA-B.txt index a8ba53676..1153a02e8 100644 --- a/test/fixtures/ruby/break.diffA-B.txt +++ b/test/fixtures/ruby/break.diffA-B.txt @@ -1,7 +1,9 @@ (Program (While - { (Identifier) + { (Send + {-(Identifier)-}) ->(Not - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+}) } (Break (Empty)))) diff --git a/test/fixtures/ruby/break.diffB-A.txt b/test/fixtures/ruby/break.diffB-A.txt index 7341443a6..8604a22d2 100644 --- a/test/fixtures/ruby/break.diffB-A.txt +++ b/test/fixtures/ruby/break.diffB-A.txt @@ -1,7 +1,9 @@ (Program (While { (Not - {-(Identifier)-}) - ->(Identifier) } + {-(Send + {-(Identifier)-})-}) + ->(Send + {+(Identifier)+}) } (Break (Empty)))) diff --git a/test/fixtures/ruby/break.parseA.txt b/test/fixtures/ruby/break.parseA.txt index 40fb98cbb..223395e7e 100644 --- a/test/fixtures/ruby/break.parseA.txt +++ b/test/fixtures/ruby/break.parseA.txt @@ -1,5 +1,6 @@ (Program (While - (Identifier) + (Send + (Identifier)) (Break (Empty)))) diff --git a/test/fixtures/ruby/break.parseB.txt b/test/fixtures/ruby/break.parseB.txt index 9a70cab54..4232fbc78 100644 --- a/test/fixtures/ruby/break.parseB.txt +++ b/test/fixtures/ruby/break.parseB.txt @@ -1,6 +1,7 @@ (Program (While (Not - (Identifier)) + (Send + (Identifier))) (Break (Empty)))) diff --git a/test/fixtures/ruby/calls.parseA.txt b/test/fixtures/ruby/calls.parseA.txt new file mode 100644 index 000000000..edbdccf96 --- /dev/null +++ b/test/fixtures/ruby/calls.parseA.txt @@ -0,0 +1,33 @@ +(Program + (Send + (Identifier) + (Send + (Identifier)) + (Send + (Identifier)) + (KeyValue + (Send + (Identifier)) + (Integer)) + (KeyValue + (Symbol) + (Boolean))) + (Send + (Send + (Identifier)) + (Identifier)) + (Send + (Identifier) + (Send + (Identifier)) + (Send + (Identifier))) + (Send + (Identifier) + (Identifier)) + (Send + (Identifier) + (Identifier)) + (Send + (Identifier) + (Identifier))) diff --git a/test/fixtures/ruby/chained-string.parseA.txt b/test/fixtures/ruby/chained-string.parseA.txt new file mode 100644 index 000000000..13446218a --- /dev/null +++ b/test/fixtures/ruby/chained-string.parseA.txt @@ -0,0 +1,4 @@ +(Program + ( + (TextElement) + (TextElement))) diff --git a/test/fixtures/ruby/comparision-operator.diffA-B.txt b/test/fixtures/ruby/comparision-operator.diffA-B.txt index 05236df2d..00f151a2a 100644 --- a/test/fixtures/ruby/comparision-operator.diffA-B.txt +++ b/test/fixtures/ruby/comparision-operator.diffA-B.txt @@ -1,13 +1,21 @@ (Program { (LessThan - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(LessThanEqual - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } {+(GreaterThanEqual - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {-(GreaterThan - {-(Identifier)-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/comparision-operator.diffB-A.txt b/test/fixtures/ruby/comparision-operator.diffB-A.txt index 4c2443911..d4a424e5d 100644 --- a/test/fixtures/ruby/comparision-operator.diffB-A.txt +++ b/test/fixtures/ruby/comparision-operator.diffB-A.txt @@ -1,13 +1,21 @@ (Program { (LessThanEqual - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(LessThan - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } {+(GreaterThan - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {-(GreaterThanEqual - {-(Identifier)-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/comparision-operator.parseA.txt b/test/fixtures/ruby/comparision-operator.parseA.txt index 25bd02c77..56dda8ed2 100644 --- a/test/fixtures/ruby/comparision-operator.parseA.txt +++ b/test/fixtures/ruby/comparision-operator.parseA.txt @@ -1,7 +1,11 @@ (Program (LessThan - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (GreaterThan - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/comparision-operator.parseB.txt b/test/fixtures/ruby/comparision-operator.parseB.txt index 3cafec206..82463b901 100644 --- a/test/fixtures/ruby/comparision-operator.parseB.txt +++ b/test/fixtures/ruby/comparision-operator.parseB.txt @@ -1,7 +1,11 @@ (Program (LessThanEqual - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (GreaterThanEqual - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/element-reference.diffA-B.txt b/test/fixtures/ruby/element-reference.diffA-B.txt index aafa20058..33e0d958e 100644 --- a/test/fixtures/ruby/element-reference.diffA-B.txt +++ b/test/fixtures/ruby/element-reference.diffA-B.txt @@ -1,16 +1,21 @@ (Program (Subscript - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) {+(TextElement)+} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-}) (Subscript - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) { (Symbol) ->(Symbol) }) {-(Assignment {-(Subscript - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(Integer)-})-}) diff --git a/test/fixtures/ruby/element-reference.diffB-A.txt b/test/fixtures/ruby/element-reference.diffB-A.txt index 6598ed5e2..d2324731c 100644 --- a/test/fixtures/ruby/element-reference.diffB-A.txt +++ b/test/fixtures/ruby/element-reference.diffB-A.txt @@ -1,16 +1,21 @@ (Program (Subscript - { (Identifier) - ->(Identifier) } - {+(Identifier)+} + (Send + { (Identifier) + ->(Identifier) }) + {+(Send + {+(Identifier)+})+} {-(TextElement)-}) (Subscript - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) { (Symbol) ->(Symbol) }) {+(Assignment {+(Subscript - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+(Integer)+})+}) diff --git a/test/fixtures/ruby/element-reference.parseA.txt b/test/fixtures/ruby/element-reference.parseA.txt index 095ca94b0..3e2ef30aa 100644 --- a/test/fixtures/ruby/element-reference.parseA.txt +++ b/test/fixtures/ruby/element-reference.parseA.txt @@ -1,12 +1,17 @@ (Program (Subscript - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (Subscript - (Identifier) + (Send + (Identifier)) (Symbol)) (Assignment (Subscript - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (Integer))) diff --git a/test/fixtures/ruby/element-reference.parseB.txt b/test/fixtures/ruby/element-reference.parseB.txt index d01caab67..477c6ca27 100644 --- a/test/fixtures/ruby/element-reference.parseB.txt +++ b/test/fixtures/ruby/element-reference.parseB.txt @@ -1,7 +1,9 @@ (Program (Subscript - (Identifier) + (Send + (Identifier)) (TextElement)) (Subscript - (Identifier) + (Send + (Identifier)) (Symbol))) diff --git a/test/fixtures/ruby/elsif.diffA-B.txt b/test/fixtures/ruby/elsif.diffA-B.txt index 209340fd7..7e659a08e 100644 --- a/test/fixtures/ruby/elsif.diffA-B.txt +++ b/test/fixtures/ruby/elsif.diffA-B.txt @@ -1,11 +1,13 @@ (Program (If - (Identifier) + (Send + (Identifier)) ( (Send (Identifier))) (If - (Identifier) + (Send + (Identifier)) ( {+(Send {+(Identifier)+})+}) diff --git a/test/fixtures/ruby/elsif.diffB-A.txt b/test/fixtures/ruby/elsif.diffB-A.txt index 0d5cf800a..49d33a9a9 100644 --- a/test/fixtures/ruby/elsif.diffB-A.txt +++ b/test/fixtures/ruby/elsif.diffB-A.txt @@ -1,11 +1,13 @@ (Program (If - (Identifier) + (Send + (Identifier)) ( (Send (Identifier))) (If - (Identifier) + (Send + (Identifier)) ([] {-(Send {-(Identifier)-})-}) diff --git a/test/fixtures/ruby/elsif.parseA.txt b/test/fixtures/ruby/elsif.parseA.txt index 5e0b329d4..0dfc7558b 100644 --- a/test/fixtures/ruby/elsif.parseA.txt +++ b/test/fixtures/ruby/elsif.parseA.txt @@ -1,10 +1,12 @@ (Program (If - (Identifier) + (Send + (Identifier)) ( (Send (Identifier))) (If - (Identifier) + (Send + (Identifier)) ([]) (Empty)))) diff --git a/test/fixtures/ruby/elsif.parseB.txt b/test/fixtures/ruby/elsif.parseB.txt index a823c51eb..88c665a03 100644 --- a/test/fixtures/ruby/elsif.parseB.txt +++ b/test/fixtures/ruby/elsif.parseB.txt @@ -1,11 +1,13 @@ (Program (If - (Identifier) + (Send + (Identifier)) ( (Send (Identifier))) (If - (Identifier) + (Send + (Identifier)) ( (Send (Identifier))) diff --git a/test/fixtures/ruby/empty-statement.parseA.txt b/test/fixtures/ruby/empty-statement.parseA.txt new file mode 100644 index 000000000..e2189ff2c --- /dev/null +++ b/test/fixtures/ruby/empty-statement.parseA.txt @@ -0,0 +1,2 @@ +(Program + (Empty)) diff --git a/test/fixtures/ruby/end-block.diffA-B.txt b/test/fixtures/ruby/end-block.diffA-B.txt index 761acb510..8f99625d9 100644 --- a/test/fixtures/ruby/end-block.diffA-B.txt +++ b/test/fixtures/ruby/end-block.diffA-B.txt @@ -1,5 +1,7 @@ (Program -{+(Identifier)+} +{+(Send + {+(Identifier)+})+} (ScopeExit - { (Identifier) - ->(Identifier) })) + (Send + { (Identifier) + ->(Identifier) }))) diff --git a/test/fixtures/ruby/end-block.diffB-A.txt b/test/fixtures/ruby/end-block.diffB-A.txt index b8080a07b..6eaa6e5d8 100644 --- a/test/fixtures/ruby/end-block.diffB-A.txt +++ b/test/fixtures/ruby/end-block.diffB-A.txt @@ -1,6 +1,9 @@ (Program {+(ScopeExit - {+(Identifier)+})+} -{-(Identifier)-} + {+(Send + {+(Identifier)+})+})+} +{-(Send + {-(Identifier)-})-} {-(ScopeExit - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/end-block.parseA.txt b/test/fixtures/ruby/end-block.parseA.txt index 5ac80d65f..25c3a9495 100644 --- a/test/fixtures/ruby/end-block.parseA.txt +++ b/test/fixtures/ruby/end-block.parseA.txt @@ -1,3 +1,4 @@ (Program (ScopeExit - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/end-block.parseB.txt b/test/fixtures/ruby/end-block.parseB.txt index 0ad65ccc2..ab8b7a91d 100644 --- a/test/fixtures/ruby/end-block.parseB.txt +++ b/test/fixtures/ruby/end-block.parseB.txt @@ -1,4 +1,6 @@ (Program - (Identifier) + (Send + (Identifier)) (ScopeExit - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/ensure.diffA-B.txt b/test/fixtures/ruby/ensure.diffA-B.txt index 0302e7830..f2eca4a32 100644 --- a/test/fixtures/ruby/ensure.diffA-B.txt +++ b/test/fixtures/ruby/ensure.diffA-B.txt @@ -1,7 +1,9 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Finally { ([]) - ->(Identifier) })))) + ->(Send + {+(Identifier)+}) })))) diff --git a/test/fixtures/ruby/ensure.diffB-A.txt b/test/fixtures/ruby/ensure.diffB-A.txt index 9357310c4..9264966b3 100644 --- a/test/fixtures/ruby/ensure.diffB-A.txt +++ b/test/fixtures/ruby/ensure.diffB-A.txt @@ -1,7 +1,9 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Finally - { (Identifier) + { (Send + {-(Identifier)-}) ->([]) })))) diff --git a/test/fixtures/ruby/ensure.parseA.txt b/test/fixtures/ruby/ensure.parseA.txt index f8729ea35..524c181ef 100644 --- a/test/fixtures/ruby/ensure.parseA.txt +++ b/test/fixtures/ruby/ensure.parseA.txt @@ -1,6 +1,7 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Finally ([]))))) diff --git a/test/fixtures/ruby/ensure.parseB.txt b/test/fixtures/ruby/ensure.parseB.txt index 6d2ac8584..3f3ef470b 100644 --- a/test/fixtures/ruby/ensure.parseB.txt +++ b/test/fixtures/ruby/ensure.parseB.txt @@ -1,6 +1,8 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Finally - (Identifier))))) + (Send + (Identifier)))))) diff --git a/test/fixtures/ruby/for.diffA-B.txt b/test/fixtures/ruby/for.diffA-B.txt index a65b6c3b9..d2865da18 100644 --- a/test/fixtures/ruby/for.diffA-B.txt +++ b/test/fixtures/ruby/for.diffA-B.txt @@ -1,28 +1,38 @@ (Program {+(ForEach {+( - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+(Array {+(Integer)+} {+(Integer)+} {+(Integer)+})+} {+(Send {+(Identifier)+} - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {-(ForEach {-( + {-(Send + {-(Identifier)-})-})-} + {-(Send {-(Identifier)-})-} - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(ForEach {-( - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} + {-(Send {-(Identifier)-})-} - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(ForEach {-( - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(Enumeration {-(Integer)-} {-(Integer)-} @@ -30,8 +40,10 @@ {-(Boolean)-})-} {-(ForEach {-( - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(Enumeration {-(Integer)-} {-(Integer)-} diff --git a/test/fixtures/ruby/for.diffB-A.txt b/test/fixtures/ruby/for.diffB-A.txt index 02167c97b..901e1762e 100644 --- a/test/fixtures/ruby/for.diffB-A.txt +++ b/test/fixtures/ruby/for.diffB-A.txt @@ -1,19 +1,27 @@ (Program {+(ForEach {+( + {+(Send + {+(Identifier)+})+})+} + {+(Send {+(Identifier)+})+} - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+(ForEach {+( - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} + {+(Send {+(Identifier)+})+} - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} (ForEach ( - { (Identifier) - ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) })) { (Array {-(Integer)-} {-(Integer)-} @@ -24,12 +32,15 @@ {+(Empty)+}) } { (Send {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-}) ->(Boolean) }) {+(ForEach {+( - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+(Enumeration {+(Integer)+} {+(Integer)+} diff --git a/test/fixtures/ruby/for.parseA.txt b/test/fixtures/ruby/for.parseA.txt index 309c07036..6f91ae369 100644 --- a/test/fixtures/ruby/for.parseA.txt +++ b/test/fixtures/ruby/for.parseA.txt @@ -1,18 +1,26 @@ (Program (ForEach ( + (Send + (Identifier))) + (Send (Identifier)) - (Identifier) - (Identifier)) + (Send + (Identifier))) (ForEach ( - (Identifier) + (Send + (Identifier)) + (Send + (Identifier))) + (Send (Identifier)) - (Identifier) - (Identifier)) + (Send + (Identifier))) (ForEach ( - (Identifier)) + (Send + (Identifier))) (Enumeration (Integer) (Integer) @@ -20,8 +28,10 @@ (Boolean)) (ForEach ( - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (Enumeration (Integer) (Integer) diff --git a/test/fixtures/ruby/for.parseB.txt b/test/fixtures/ruby/for.parseB.txt index a0c763c04..30ed78a02 100644 --- a/test/fixtures/ruby/for.parseB.txt +++ b/test/fixtures/ruby/for.parseB.txt @@ -1,11 +1,13 @@ (Program (ForEach ( - (Identifier)) + (Send + (Identifier))) (Array (Integer) (Integer) (Integer)) (Send (Identifier) - (Identifier)))) + (Send + (Identifier))))) diff --git a/test/fixtures/ruby/hash.diffA-B.txt b/test/fixtures/ruby/hash.diffA-B.txt index 6294f4491..0efdd81e0 100644 --- a/test/fixtures/ruby/hash.diffA-B.txt +++ b/test/fixtures/ruby/hash.diffA-B.txt @@ -2,17 +2,20 @@ (Hash (KeyValue { (Symbol) - ->(Identifier) } + ->(Send + {+(Identifier)+}) } { (TextElement) ->(TextElement) }) (KeyValue { (Symbol) - ->(Identifier) } + ->(Send + {+(Identifier)+}) } { (Integer) ->(Integer) }) (KeyValue { (TextElement) - ->(Identifier) } + ->(Send + {+(Identifier)+}) } { (Boolean) ->(Boolean) }) {-(KeyValue @@ -23,7 +26,8 @@ {-(Context {-(Comment)-} {-(KeyValue - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Integer)-})-})-} {-(Context {-(Comment)-} diff --git a/test/fixtures/ruby/hash.diffB-A.txt b/test/fixtures/ruby/hash.diffB-A.txt index 7b1ca75c0..f6d13dd57 100644 --- a/test/fixtures/ruby/hash.diffB-A.txt +++ b/test/fixtures/ruby/hash.diffB-A.txt @@ -1,17 +1,20 @@ (Program (Hash (KeyValue - { (Identifier) + { (Send + {-(Identifier)-}) ->(Symbol) } { (TextElement) ->(TextElement) }) (KeyValue - { (Identifier) + { (Send + {-(Identifier)-}) ->(Symbol) } { (Integer) ->(Integer) }) (KeyValue - { (Identifier) + { (Send + {-(Identifier)-}) ->(TextElement) } { (Boolean) ->(Boolean) }) @@ -23,7 +26,8 @@ {+(Context {+(Comment)+} {+(KeyValue - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Integer)+})+})+} {+(Context {+(Comment)+} diff --git a/test/fixtures/ruby/hash.parseA.txt b/test/fixtures/ruby/hash.parseA.txt index bcc7e907b..730981f4a 100644 --- a/test/fixtures/ruby/hash.parseA.txt +++ b/test/fixtures/ruby/hash.parseA.txt @@ -17,7 +17,8 @@ (Context (Comment) (KeyValue - (Identifier) + (Send + (Identifier)) (Integer))) (Context (Comment) diff --git a/test/fixtures/ruby/hash.parseB.txt b/test/fixtures/ruby/hash.parseB.txt index 4177683d3..ad05704f5 100644 --- a/test/fixtures/ruby/hash.parseB.txt +++ b/test/fixtures/ruby/hash.parseB.txt @@ -1,11 +1,14 @@ (Program (Hash (KeyValue - (Identifier) + (Send + (Identifier)) (TextElement)) (KeyValue - (Identifier) + (Send + (Identifier)) (Integer)) (KeyValue - (Identifier) + (Send + (Identifier)) (Boolean)))) diff --git a/test/fixtures/ruby/if-unless-modifiers.diffA-B.txt b/test/fixtures/ruby/if-unless-modifiers.diffA-B.txt index f777a87ab..69aa53763 100644 --- a/test/fixtures/ruby/if-unless-modifiers.diffA-B.txt +++ b/test/fixtures/ruby/if-unless-modifiers.diffA-B.txt @@ -1,7 +1,10 @@ (Program (If { (Not - {-(Identifier)-}) - ->(Identifier) } - (Identifier) + {-(Send + {-(Identifier)-})-}) + ->(Send + {+(Identifier)+}) } + (Send + (Identifier)) (Empty))) diff --git a/test/fixtures/ruby/if-unless-modifiers.diffB-A.txt b/test/fixtures/ruby/if-unless-modifiers.diffB-A.txt index a0ba83adc..7fad257f8 100644 --- a/test/fixtures/ruby/if-unless-modifiers.diffB-A.txt +++ b/test/fixtures/ruby/if-unless-modifiers.diffB-A.txt @@ -1,7 +1,10 @@ (Program (If - { (Identifier) + { (Send + {-(Identifier)-}) ->(Not - {+(Identifier)+}) } - (Identifier) + {+(Send + {+(Identifier)+})+}) } + (Send + (Identifier)) (Empty))) diff --git a/test/fixtures/ruby/if-unless-modifiers.parseA.txt b/test/fixtures/ruby/if-unless-modifiers.parseA.txt index efc7ce331..ab715989a 100644 --- a/test/fixtures/ruby/if-unless-modifiers.parseA.txt +++ b/test/fixtures/ruby/if-unless-modifiers.parseA.txt @@ -1,6 +1,8 @@ (Program (If (Not + (Send + (Identifier))) + (Send (Identifier)) - (Identifier) (Empty))) diff --git a/test/fixtures/ruby/if-unless-modifiers.parseB.txt b/test/fixtures/ruby/if-unless-modifiers.parseB.txt index 50f08ae58..c1129987d 100644 --- a/test/fixtures/ruby/if-unless-modifiers.parseB.txt +++ b/test/fixtures/ruby/if-unless-modifiers.parseB.txt @@ -1,5 +1,7 @@ (Program (If - (Identifier) - (Identifier) + (Send + (Identifier)) + (Send + (Identifier)) (Empty))) diff --git a/test/fixtures/ruby/if.diffA-B.txt b/test/fixtures/ruby/if.diffA-B.txt index a4b869cc2..a2151c9b3 100644 --- a/test/fixtures/ruby/if.diffA-B.txt +++ b/test/fixtures/ruby/if.diffA-B.txt @@ -1,16 +1,22 @@ (Program (If - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) ([] - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-}) { (If - {-(Identifier)-} - {-( + {-(Send {-(Identifier)-})-} - {-(Identifier)-}) + {-( + {-(Send + {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-}) ->(Empty) }) {+(If - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+([])+} {+(Empty)+})+}) diff --git a/test/fixtures/ruby/if.diffB-A.txt b/test/fixtures/ruby/if.diffB-A.txt index 058779626..f310c46c9 100644 --- a/test/fixtures/ruby/if.diffB-A.txt +++ b/test/fixtures/ruby/if.diffB-A.txt @@ -1,16 +1,22 @@ (Program (If - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) ( - {+(Identifier)+}) + {+(Send + {+(Identifier)+})+}) { (Empty) ->(If - {+(Identifier)+} - {+( + {+(Send {+(Identifier)+})+} - {+(Identifier)+}) }) + {+( + {+(Send + {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+}) }) {-(If - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-([])-} {-(Empty)-})-}) diff --git a/test/fixtures/ruby/if.parseA.txt b/test/fixtures/ruby/if.parseA.txt index c6a5f86cb..1f437cf11 100644 --- a/test/fixtures/ruby/if.parseA.txt +++ b/test/fixtures/ruby/if.parseA.txt @@ -1,10 +1,15 @@ (Program (If - (Identifier) - ( + (Send (Identifier)) + ( + (Send + (Identifier))) (If - (Identifier) - ( + (Send (Identifier)) - (Identifier)))) + ( + (Send + (Identifier))) + (Send + (Identifier))))) diff --git a/test/fixtures/ruby/if.parseB.txt b/test/fixtures/ruby/if.parseB.txt index cf31ff1f9..1c33d88a2 100644 --- a/test/fixtures/ruby/if.parseB.txt +++ b/test/fixtures/ruby/if.parseB.txt @@ -1,9 +1,11 @@ (Program (If - (Identifier) + (Send + (Identifier)) ([]) (Empty)) (If - (Identifier) + (Send + (Identifier)) ([]) (Empty))) diff --git a/test/fixtures/ruby/keywords.parseA.txt b/test/fixtures/ruby/keywords.parseA.txt new file mode 100644 index 000000000..e9b1f6823 --- /dev/null +++ b/test/fixtures/ruby/keywords.parseA.txt @@ -0,0 +1,7 @@ +(Program + (Send + (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) diff --git a/test/fixtures/ruby/lambda-dash-rocket.diffA-B.txt b/test/fixtures/ruby/lambda-dash-rocket.diffA-B.txt index 0e36a5d4e..080b2d9a9 100644 --- a/test/fixtures/ruby/lambda-dash-rocket.diffA-B.txt +++ b/test/fixtures/ruby/lambda-dash-rocket.diffA-B.txt @@ -9,4 +9,5 @@ { ( {-(Integer)-} {-(Integer)-}) - ->(Identifier) }))) + ->(Send + {+(Identifier)+}) }))) diff --git a/test/fixtures/ruby/lambda-dash-rocket.diffB-A.txt b/test/fixtures/ruby/lambda-dash-rocket.diffB-A.txt index 20d00883b..2476cec06 100644 --- a/test/fixtures/ruby/lambda-dash-rocket.diffB-A.txt +++ b/test/fixtures/ruby/lambda-dash-rocket.diffB-A.txt @@ -6,7 +6,8 @@ {+(Identifier)+} (Function (Empty) - { (Identifier) + { (Send + {-(Identifier)-}) ->( {+(Integer)+} {+(Integer)+}) }))) diff --git a/test/fixtures/ruby/lambda-dash-rocket.parseB.txt b/test/fixtures/ruby/lambda-dash-rocket.parseB.txt index 2b73c18de..cbe35bb4b 100644 --- a/test/fixtures/ruby/lambda-dash-rocket.parseB.txt +++ b/test/fixtures/ruby/lambda-dash-rocket.parseB.txt @@ -3,4 +3,5 @@ (Empty) (Function (Empty) - (Identifier)))) + (Send + (Identifier))))) diff --git a/test/fixtures/ruby/lambda.diffA-B.txt b/test/fixtures/ruby/lambda.diffA-B.txt index 7f87ae78b..347a6dbfa 100644 --- a/test/fixtures/ruby/lambda.diffA-B.txt +++ b/test/fixtures/ruby/lambda.diffA-B.txt @@ -6,13 +6,15 @@ {+(Identifier)+} { ([]) ->(Plus - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Integer)+}) })) {-(Send {-(Identifier)-} {-(Function {-(Empty)-} - {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-})-} {-(Send {-(Identifier)-} {-(Function @@ -30,7 +32,8 @@ {-(Empty)-} {-(Function {-(Empty)-} - {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-})-} {-(Function {-(Empty)-} {-(Identifier)-} diff --git a/test/fixtures/ruby/lambda.diffB-A.txt b/test/fixtures/ruby/lambda.diffB-A.txt index b2123253f..fd3c37ae8 100644 --- a/test/fixtures/ruby/lambda.diffB-A.txt +++ b/test/fixtures/ruby/lambda.diffB-A.txt @@ -5,14 +5,16 @@ (Empty) {-(Identifier)-} { (Plus - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Integer)-}) ->([]) })) {+(Send {+(Identifier)+} {+(Function {+(Empty)+} - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {+(Send {+(Identifier)+} {+(Function @@ -30,7 +32,8 @@ {+(Empty)+} {+(Function {+(Empty)+} - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {+(Function {+(Empty)+} {+(Identifier)+} diff --git a/test/fixtures/ruby/lambda.parseA.txt b/test/fixtures/ruby/lambda.parseA.txt index aef573fea..bbfaf8869 100644 --- a/test/fixtures/ruby/lambda.parseA.txt +++ b/test/fixtures/ruby/lambda.parseA.txt @@ -8,7 +8,8 @@ (Identifier) (Function (Empty) - (Identifier))) + (Send + (Identifier)))) (Send (Identifier) (Function @@ -26,7 +27,8 @@ (Empty) (Function (Empty) - (Identifier))) + (Send + (Identifier)))) (Function (Empty) (Identifier) diff --git a/test/fixtures/ruby/lambda.parseB.txt b/test/fixtures/ruby/lambda.parseB.txt index 23f3795f0..0ae3a43d2 100644 --- a/test/fixtures/ruby/lambda.parseB.txt +++ b/test/fixtures/ruby/lambda.parseB.txt @@ -5,5 +5,6 @@ (Empty) (Identifier) (Plus - (Identifier) + (Send + (Identifier)) (Integer))))) diff --git a/test/fixtures/ruby/literals.parseA.txt b/test/fixtures/ruby/literals.parseA.txt new file mode 100644 index 000000000..37708d778 --- /dev/null +++ b/test/fixtures/ruby/literals.parseA.txt @@ -0,0 +1,16 @@ +(Program + (Boolean) + (Boolean) + (Null) + (Symbol) + (Integer) + (Identifier) + (Identifier) + (Enumeration + (Integer) + (Integer) + (Empty)) + (Enumeration + (Integer) + (Integer) + (Empty))) diff --git a/test/fixtures/ruby/method-calls-keyword-args.diffA-B.txt b/test/fixtures/ruby/method-calls-keyword-args.diffA-B.txt index 29d015331..8189b4f1b 100644 --- a/test/fixtures/ruby/method-calls-keyword-args.diffA-B.txt +++ b/test/fixtures/ruby/method-calls-keyword-args.diffA-B.txt @@ -2,8 +2,10 @@ (Send (Identifier) (KeyValue - (Identifier) + (Send + (Identifier)) (Boolean)) {+(KeyValue - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Integer)+})+})) diff --git a/test/fixtures/ruby/method-calls-keyword-args.diffB-A.txt b/test/fixtures/ruby/method-calls-keyword-args.diffB-A.txt index d997a17bc..e7edf45fd 100644 --- a/test/fixtures/ruby/method-calls-keyword-args.diffB-A.txt +++ b/test/fixtures/ruby/method-calls-keyword-args.diffB-A.txt @@ -2,8 +2,10 @@ (Send (Identifier) (KeyValue - (Identifier) + (Send + (Identifier)) (Boolean)) {-(KeyValue - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Integer)-})-})) diff --git a/test/fixtures/ruby/method-calls-keyword-args.parseA.txt b/test/fixtures/ruby/method-calls-keyword-args.parseA.txt index 44ef36306..2beabf7a1 100644 --- a/test/fixtures/ruby/method-calls-keyword-args.parseA.txt +++ b/test/fixtures/ruby/method-calls-keyword-args.parseA.txt @@ -2,5 +2,6 @@ (Send (Identifier) (KeyValue - (Identifier) + (Send + (Identifier)) (Boolean)))) diff --git a/test/fixtures/ruby/method-calls-keyword-args.parseB.txt b/test/fixtures/ruby/method-calls-keyword-args.parseB.txt index 2c25ecd29..0b3fc4ad2 100644 --- a/test/fixtures/ruby/method-calls-keyword-args.parseB.txt +++ b/test/fixtures/ruby/method-calls-keyword-args.parseB.txt @@ -2,8 +2,10 @@ (Send (Identifier) (KeyValue - (Identifier) + (Send + (Identifier)) (Boolean)) (KeyValue - (Identifier) + (Send + (Identifier)) (Integer)))) diff --git a/test/fixtures/ruby/method-calls.diffA-B.txt b/test/fixtures/ruby/method-calls.diffA-B.txt index 3c46d8c5c..d29b6ccf4 100644 --- a/test/fixtures/ruby/method-calls.diffA-B.txt +++ b/test/fixtures/ruby/method-calls.diffA-B.txt @@ -1,23 +1,28 @@ (Program (Send - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} { (Identifier) ->(Identifier) }) {-(Send {-(Identifier)-} - {-(Identifier)-} - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} {-(KeyValue {-(Symbol)-} {-(Integer)-})-} {-(KeyValue - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Integer)-})-})-} {-(Send {-(Identifier)-} {-(Send {-(Identifier)-} - {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-})-} {-(Send {-(Identifier)-} {-(KeyValue diff --git a/test/fixtures/ruby/method-calls.diffB-A.txt b/test/fixtures/ruby/method-calls.diffB-A.txt index c028170a1..ba8248ce3 100644 --- a/test/fixtures/ruby/method-calls.diffB-A.txt +++ b/test/fixtures/ruby/method-calls.diffB-A.txt @@ -1,23 +1,28 @@ (Program (Send - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} { (Identifier) ->(Identifier) }) {+(Send {+(Identifier)+} - {+(Identifier)+} - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} {+(KeyValue {+(Symbol)+} {+(Integer)+})+} {+(KeyValue - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Integer)+})+})+} {+(Send {+(Identifier)+} {+(Send {+(Identifier)+} - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {+(Send {+(Identifier)+} {+(KeyValue diff --git a/test/fixtures/ruby/method-calls.parseA.txt b/test/fixtures/ruby/method-calls.parseA.txt index 0bc76963f..b3d66df01 100644 --- a/test/fixtures/ruby/method-calls.parseA.txt +++ b/test/fixtures/ruby/method-calls.parseA.txt @@ -1,22 +1,27 @@ (Program (Send - (Identifier) + (Send + (Identifier)) (Identifier)) (Send (Identifier) - (Identifier) - (Identifier) + (Send + (Identifier)) + (Send + (Identifier)) (KeyValue (Symbol) (Integer)) (KeyValue - (Identifier) + (Send + (Identifier)) (Integer))) (Send (Identifier) (Send (Identifier) - (Identifier))) + (Send + (Identifier)))) (Send (Identifier) (KeyValue diff --git a/test/fixtures/ruby/method-declaration.diffA-B.txt b/test/fixtures/ruby/method-declaration.diffA-B.txt index 7bc06c40b..7592bf4e4 100644 --- a/test/fixtures/ruby/method-declaration.diffA-B.txt +++ b/test/fixtures/ruby/method-declaration.diffA-B.txt @@ -5,4 +5,5 @@ ->(Identifier) } {+(Identifier)+} ( - {+(Identifier)+}))) + {+(Send + {+(Identifier)+})+}))) diff --git a/test/fixtures/ruby/method-declaration.diffB-A.txt b/test/fixtures/ruby/method-declaration.diffB-A.txt index 06c351819..ff032f032 100644 --- a/test/fixtures/ruby/method-declaration.diffB-A.txt +++ b/test/fixtures/ruby/method-declaration.diffB-A.txt @@ -5,4 +5,5 @@ ->(Identifier) } {-(Identifier)-} ([] - {-(Identifier)-}))) + {-(Send + {-(Identifier)-})-}))) diff --git a/test/fixtures/ruby/method-declaration.parseB.txt b/test/fixtures/ruby/method-declaration.parseB.txt index 377ea7f4e..acf2aca5b 100644 --- a/test/fixtures/ruby/method-declaration.parseB.txt +++ b/test/fixtures/ruby/method-declaration.parseB.txt @@ -4,4 +4,5 @@ (Identifier) (Identifier) ( - (Identifier)))) + (Send + (Identifier))))) diff --git a/test/fixtures/ruby/method-invocation.diffA-B.txt b/test/fixtures/ruby/method-invocation.diffA-B.txt index 8804f3a1f..04f0d5ce1 100644 --- a/test/fixtures/ruby/method-invocation.diffA-B.txt +++ b/test/fixtures/ruby/method-invocation.diffA-B.txt @@ -1,17 +1,16 @@ (Program -{+(Send - {+(Identifier)+} - {+(TextElement)+})+} -{-(Identifier)-} (Send (Identifier) + {+(TextElement)+}) + (Send + (Send + (Identifier)) (Identifier)) + (Send + (Identifier) + {+(Integer)+} + {+(Integer)+}) {+(Send {+(Identifier)+} {+(Integer)+} - {+(Integer)+})+} -{+(Send - {+(Identifier)+} - {+(Integer)+} - {+(Integer)+})+} -{-(Identifier)-}) + {+(Integer)+})+}) diff --git a/test/fixtures/ruby/method-invocation.diffB-A.txt b/test/fixtures/ruby/method-invocation.diffB-A.txt index d736631e1..9e4934ad1 100644 --- a/test/fixtures/ruby/method-invocation.diffB-A.txt +++ b/test/fixtures/ruby/method-invocation.diffB-A.txt @@ -1,16 +1,15 @@ (Program -{+(Identifier)+} -{-(Send - {-(Identifier)-} - {-(TextElement)-})-} (Send (Identifier) + {-(TextElement)-}) + (Send + (Send + (Identifier)) (Identifier)) -{+(Identifier)+} -{-(Send - {-(Identifier)-} + (Send + (Identifier) {-(Integer)-} - {-(Integer)-})-} + {-(Integer)-}) {-(Send {-(Identifier)-} {-(Integer)-} diff --git a/test/fixtures/ruby/method-invocation.parseA.txt b/test/fixtures/ruby/method-invocation.parseA.txt index 5d1ce8893..c9c800039 100644 --- a/test/fixtures/ruby/method-invocation.parseA.txt +++ b/test/fixtures/ruby/method-invocation.parseA.txt @@ -1,6 +1,9 @@ (Program - (Identifier) (Send - (Identifier) (Identifier)) - (Identifier)) + (Send + (Send + (Identifier)) + (Identifier)) + (Send + (Identifier))) diff --git a/test/fixtures/ruby/method-invocation.parseB.txt b/test/fixtures/ruby/method-invocation.parseB.txt index de9b0825b..2b9590185 100644 --- a/test/fixtures/ruby/method-invocation.parseB.txt +++ b/test/fixtures/ruby/method-invocation.parseB.txt @@ -3,7 +3,8 @@ (Identifier) (TextElement)) (Send - (Identifier) + (Send + (Identifier)) (Identifier)) (Send (Identifier) diff --git a/test/fixtures/ruby/methods.parseA.txt b/test/fixtures/ruby/methods.parseA.txt new file mode 100644 index 000000000..c801ae2f7 --- /dev/null +++ b/test/fixtures/ruby/methods.parseA.txt @@ -0,0 +1,42 @@ +(Program + (Method + (Empty) + (Identifier) + ([])) + (Method + (Empty) + (Identifier) + ([])) + (Method + (Empty) + (Identifier) + (Identifier) + ([])) + (Method + (Empty) + (Identifier) + (Identifier) + (Identifier) + (Identifier) + (Identifier) + ([])) + (Method + (Empty) + (Identifier) + (Identifier) + ([])) + (Method + (Empty) + (Identifier) + (Identifier) + ([])) + (Method + (Identifier) + (Identifier) + ([])) + (Method + (Identifier) + (Identifier) + (Identifier) + (Identifier) + ([]))) diff --git a/test/fixtures/ruby/misc.parseA.txt b/test/fixtures/ruby/misc.parseA.txt new file mode 100644 index 000000000..f494f4f8f --- /dev/null +++ b/test/fixtures/ruby/misc.parseA.txt @@ -0,0 +1,27 @@ +(Program + (Send + (Identifier) + (Send + (Identifier)) + (Function + (Empty) + ([]))) + (Send + (Send + (Identifier)) + (Identifier) + (Function + (Empty) + (Identifier) + (Identifier) + (Identifier) + ([]))) + (Send + (Identifier) + (Send + (Identifier)) + (Function + (Empty) + (Identifier) + ([]))) + (Identifier)) diff --git a/test/fixtures/ruby/multiple-assignments.diffA-B.txt b/test/fixtures/ruby/multiple-assignments.diffA-B.txt index b60fbedae..7c735abdd 100644 --- a/test/fixtures/ruby/multiple-assignments.diffA-B.txt +++ b/test/fixtures/ruby/multiple-assignments.diffA-B.txt @@ -45,10 +45,12 @@ {-(Identifier)-})-})-} {-( {-(Send - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Identifier)-})-} {-(Send - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Identifier)-})-})-})-} {-(Assignment {-( diff --git a/test/fixtures/ruby/multiple-assignments.diffB-A.txt b/test/fixtures/ruby/multiple-assignments.diffB-A.txt index 9072ef138..e6f8ba6d8 100644 --- a/test/fixtures/ruby/multiple-assignments.diffB-A.txt +++ b/test/fixtures/ruby/multiple-assignments.diffB-A.txt @@ -45,10 +45,12 @@ {+(Identifier)+})+})+} {+( {+(Send - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Identifier)+})+} {+(Send - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Identifier)+})+})+})+} {+(Assignment {+( diff --git a/test/fixtures/ruby/multiple-assignments.parseA.txt b/test/fixtures/ruby/multiple-assignments.parseA.txt index 917c016f8..406650c2d 100644 --- a/test/fixtures/ruby/multiple-assignments.parseA.txt +++ b/test/fixtures/ruby/multiple-assignments.parseA.txt @@ -44,10 +44,12 @@ (Identifier))) ( (Send - (Identifier) + (Send + (Identifier)) (Identifier)) (Send - (Identifier) + (Send + (Identifier)) (Identifier)))) (Assignment ( diff --git a/test/fixtures/ruby/next.parseA.txt b/test/fixtures/ruby/next.parseA.txt new file mode 100644 index 000000000..16cc87aba --- /dev/null +++ b/test/fixtures/ruby/next.parseA.txt @@ -0,0 +1,9 @@ +(Program + (ForEach + ( + (Send + (Identifier))) + (Send + (Identifier)) + (Continue + (Empty)))) diff --git a/test/fixtures/ruby/percent-array.diffA-B.txt b/test/fixtures/ruby/percent-array.diffA-B.txt index 95b0e7b23..816d3f1cb 100644 --- a/test/fixtures/ruby/percent-array.diffA-B.txt +++ b/test/fixtures/ruby/percent-array.diffA-B.txt @@ -1,3 +1,4 @@ (Program (Array - {+(Identifier)+})) + {+(Send + {+(Identifier)+})+})) diff --git a/test/fixtures/ruby/percent-array.diffB-A.txt b/test/fixtures/ruby/percent-array.diffB-A.txt index 3c41cf037..6fa764e68 100644 --- a/test/fixtures/ruby/percent-array.diffB-A.txt +++ b/test/fixtures/ruby/percent-array.diffB-A.txt @@ -1,3 +1,4 @@ (Program (Array - {-(Identifier)-})) + {-(Send + {-(Identifier)-})-})) diff --git a/test/fixtures/ruby/percent-array.parseB.txt b/test/fixtures/ruby/percent-array.parseB.txt index e5aab4598..06ea45410 100644 --- a/test/fixtures/ruby/percent-array.parseB.txt +++ b/test/fixtures/ruby/percent-array.parseB.txt @@ -1,3 +1,4 @@ (Program (Array - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/relational-operator.diffA-B.txt b/test/fixtures/ruby/relational-operator.diffA-B.txt index 573104fbf..9e83444ee 100644 --- a/test/fixtures/ruby/relational-operator.diffA-B.txt +++ b/test/fixtures/ruby/relational-operator.diffA-B.txt @@ -1,21 +1,32 @@ (Program { (Equal - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(Comparison - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } {+(Matches - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+(Assignment {+(Identifier)+} {+(Not - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {-(Not {-(Equal - {-(Identifier)-} - {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-})-} {-(Equal - {-(Identifier)-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/relational-operator.diffB-A.txt b/test/fixtures/ruby/relational-operator.diffB-A.txt index 6c5ab4bab..3fe29af28 100644 --- a/test/fixtures/ruby/relational-operator.diffB-A.txt +++ b/test/fixtures/ruby/relational-operator.diffB-A.txt @@ -1,21 +1,32 @@ (Program { (Comparison - {-(Identifier)-} - {-(Identifier)-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}) ->(Equal - {+(Identifier)+} - {+(Identifier)+}) } + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+}) } {+(Not {+(Equal - {+(Identifier)+} - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+})+} {+(Equal - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {-(Matches - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(Assignment {-(Identifier)-} {-(Not - {-(Identifier)-})-})-}) + {-(Send + {-(Identifier)-})-})-})-}) diff --git a/test/fixtures/ruby/relational-operator.parseA.txt b/test/fixtures/ruby/relational-operator.parseA.txt index 46e89bb6c..53b7e0147 100644 --- a/test/fixtures/ruby/relational-operator.parseA.txt +++ b/test/fixtures/ruby/relational-operator.parseA.txt @@ -1,11 +1,17 @@ (Program (Equal - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (Not (Equal - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) (Equal - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/relational-operator.parseB.txt b/test/fixtures/ruby/relational-operator.parseB.txt index 5d1624698..d5441e01e 100644 --- a/test/fixtures/ruby/relational-operator.parseB.txt +++ b/test/fixtures/ruby/relational-operator.parseB.txt @@ -1,11 +1,16 @@ (Program (Comparison - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (Matches - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) (Assignment (Identifier) (Not - (Identifier)))) + (Send + (Identifier))))) diff --git a/test/fixtures/ruby/require.diffA-B.txt b/test/fixtures/ruby/require.diffA-B.txt index a5dbacab3..627790c44 100644 --- a/test/fixtures/ruby/require.diffA-B.txt +++ b/test/fixtures/ruby/require.diffA-B.txt @@ -7,4 +7,5 @@ ->(Identifier) } {+(Symbol)+} {+(TextElement)+} - {-(Identifier)-})) + {-(Send + {-(Identifier)-})-})) diff --git a/test/fixtures/ruby/require.diffB-A.txt b/test/fixtures/ruby/require.diffB-A.txt index 9097a9f15..e55fea24f 100644 --- a/test/fixtures/ruby/require.diffB-A.txt +++ b/test/fixtures/ruby/require.diffB-A.txt @@ -5,6 +5,7 @@ (Send { (Identifier) ->(Identifier) } - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {-(Symbol)-} {-(TextElement)-})) diff --git a/test/fixtures/ruby/require.parseA.txt b/test/fixtures/ruby/require.parseA.txt index 3537988d3..7c20ab878 100644 --- a/test/fixtures/ruby/require.parseA.txt +++ b/test/fixtures/ruby/require.parseA.txt @@ -3,4 +3,5 @@ (TextElement)) (Send (Identifier) - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/rescue-empty.diffA-B.txt b/test/fixtures/ruby/rescue-empty.diffA-B.txt index 385261ff5..f0d3e467c 100644 --- a/test/fixtures/ruby/rescue-empty.diffA-B.txt +++ b/test/fixtures/ruby/rescue-empty.diffA-B.txt @@ -1,8 +1,10 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ([]) { ([]) - ->(Identifier) })))) + ->(Send + {+(Identifier)+}) })))) diff --git a/test/fixtures/ruby/rescue-empty.diffB-A.txt b/test/fixtures/ruby/rescue-empty.diffB-A.txt index 73903ed69..73cad3bfc 100644 --- a/test/fixtures/ruby/rescue-empty.diffB-A.txt +++ b/test/fixtures/ruby/rescue-empty.diffB-A.txt @@ -1,8 +1,10 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ([]) - { (Identifier) + { (Send + {-(Identifier)-}) ->([]) })))) diff --git a/test/fixtures/ruby/rescue-empty.parseA.txt b/test/fixtures/ruby/rescue-empty.parseA.txt index f90f70778..519796778 100644 --- a/test/fixtures/ruby/rescue-empty.parseA.txt +++ b/test/fixtures/ruby/rescue-empty.parseA.txt @@ -1,7 +1,8 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ([]) ([]))))) diff --git a/test/fixtures/ruby/rescue-empty.parseB.txt b/test/fixtures/ruby/rescue-empty.parseB.txt index bbbb75fa6..c7bc8332d 100644 --- a/test/fixtures/ruby/rescue-empty.parseB.txt +++ b/test/fixtures/ruby/rescue-empty.parseB.txt @@ -1,7 +1,9 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ([]) - (Identifier))))) + (Send + (Identifier)))))) diff --git a/test/fixtures/ruby/rescue-last-ex.diffA-B.txt b/test/fixtures/ruby/rescue-last-ex.diffA-B.txt index 616a7543d..8b0da7220 100644 --- a/test/fixtures/ruby/rescue-last-ex.diffA-B.txt +++ b/test/fixtures/ruby/rescue-last-ex.diffA-B.txt @@ -1,12 +1,15 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ( ( (Identifier)) ( - (Identifier))) + (Send + (Identifier)))) { ([]) - ->(Identifier) })))) + ->(Send + {+(Identifier)+}) })))) diff --git a/test/fixtures/ruby/rescue-last-ex.diffB-A.txt b/test/fixtures/ruby/rescue-last-ex.diffB-A.txt index d059c7ed5..a639d31c5 100644 --- a/test/fixtures/ruby/rescue-last-ex.diffB-A.txt +++ b/test/fixtures/ruby/rescue-last-ex.diffB-A.txt @@ -1,12 +1,15 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ( ( (Identifier)) ( - (Identifier))) - { (Identifier) + (Send + (Identifier)))) + { (Send + {-(Identifier)-}) ->([]) })))) diff --git a/test/fixtures/ruby/rescue-last-ex.parseA.txt b/test/fixtures/ruby/rescue-last-ex.parseA.txt index 620ae6d2c..89713222d 100644 --- a/test/fixtures/ruby/rescue-last-ex.parseA.txt +++ b/test/fixtures/ruby/rescue-last-ex.parseA.txt @@ -1,11 +1,13 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ( ( (Identifier)) ( - (Identifier))) + (Send + (Identifier)))) ([]))))) diff --git a/test/fixtures/ruby/rescue-last-ex.parseB.txt b/test/fixtures/ruby/rescue-last-ex.parseB.txt index a629d5af9..eb5ee6c1c 100644 --- a/test/fixtures/ruby/rescue-last-ex.parseB.txt +++ b/test/fixtures/ruby/rescue-last-ex.parseB.txt @@ -1,11 +1,14 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ( ( (Identifier)) ( - (Identifier))) - (Identifier))))) + (Send + (Identifier)))) + (Send + (Identifier)))))) diff --git a/test/fixtures/ruby/rescue-modifier.diffA-B.txt b/test/fixtures/ruby/rescue-modifier.diffA-B.txt index 7b3841cc2..509fab25d 100644 --- a/test/fixtures/ruby/rescue-modifier.diffA-B.txt +++ b/test/fixtures/ruby/rescue-modifier.diffA-B.txt @@ -1,6 +1,7 @@ (Program (Try - (Identifier) + (Send + (Identifier)) (Catch { (Null) ->(Boolean) } diff --git a/test/fixtures/ruby/rescue-modifier.diffB-A.txt b/test/fixtures/ruby/rescue-modifier.diffB-A.txt index 34ea56eec..4c1f4d125 100644 --- a/test/fixtures/ruby/rescue-modifier.diffB-A.txt +++ b/test/fixtures/ruby/rescue-modifier.diffB-A.txt @@ -1,6 +1,7 @@ (Program (Try - (Identifier) + (Send + (Identifier)) (Catch { (Boolean) ->(Null) } diff --git a/test/fixtures/ruby/rescue-modifier.parseA.txt b/test/fixtures/ruby/rescue-modifier.parseA.txt index 73f4dd51a..7d9f2e4fb 100644 --- a/test/fixtures/ruby/rescue-modifier.parseA.txt +++ b/test/fixtures/ruby/rescue-modifier.parseA.txt @@ -1,6 +1,7 @@ (Program (Try - (Identifier) + (Send + (Identifier)) (Catch (Null) (Empty)))) diff --git a/test/fixtures/ruby/rescue-modifier.parseB.txt b/test/fixtures/ruby/rescue-modifier.parseB.txt index 3fbb3d0dd..bc98ab542 100644 --- a/test/fixtures/ruby/rescue-modifier.parseB.txt +++ b/test/fixtures/ruby/rescue-modifier.parseB.txt @@ -1,6 +1,7 @@ (Program (Try - (Identifier) + (Send + (Identifier)) (Catch (Boolean) (Empty)))) diff --git a/test/fixtures/ruby/rescue-modifier2.diffA-B.txt b/test/fixtures/ruby/rescue-modifier2.diffA-B.txt index 6cb4f31c4..2be307e31 100644 --- a/test/fixtures/ruby/rescue-modifier2.diffA-B.txt +++ b/test/fixtures/ruby/rescue-modifier2.diffA-B.txt @@ -1,7 +1,8 @@ (Program (Try - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) (Catch (Null) (Empty)))) diff --git a/test/fixtures/ruby/rescue-modifier2.diffB-A.txt b/test/fixtures/ruby/rescue-modifier2.diffB-A.txt index 6cb4f31c4..2be307e31 100644 --- a/test/fixtures/ruby/rescue-modifier2.diffB-A.txt +++ b/test/fixtures/ruby/rescue-modifier2.diffB-A.txt @@ -1,7 +1,8 @@ (Program (Try - { (Identifier) - ->(Identifier) } + (Send + { (Identifier) + ->(Identifier) }) (Catch (Null) (Empty)))) diff --git a/test/fixtures/ruby/rescue-modifier2.parseA.txt b/test/fixtures/ruby/rescue-modifier2.parseA.txt index 73f4dd51a..7d9f2e4fb 100644 --- a/test/fixtures/ruby/rescue-modifier2.parseA.txt +++ b/test/fixtures/ruby/rescue-modifier2.parseA.txt @@ -1,6 +1,7 @@ (Program (Try - (Identifier) + (Send + (Identifier)) (Catch (Null) (Empty)))) diff --git a/test/fixtures/ruby/rescue-modifier2.parseB.txt b/test/fixtures/ruby/rescue-modifier2.parseB.txt index 73f4dd51a..7d9f2e4fb 100644 --- a/test/fixtures/ruby/rescue-modifier2.parseB.txt +++ b/test/fixtures/ruby/rescue-modifier2.parseB.txt @@ -1,6 +1,7 @@ (Program (Try - (Identifier) + (Send + (Identifier)) (Catch (Null) (Empty)))) diff --git a/test/fixtures/ruby/rescue.diffA-B.txt b/test/fixtures/ruby/rescue.diffA-B.txt index 9d4959b36..cd45faf3c 100644 --- a/test/fixtures/ruby/rescue.diffA-B.txt +++ b/test/fixtures/ruby/rescue.diffA-B.txt @@ -1,12 +1,19 @@ (Program - (Try - ( - (Identifier) +{+(Try + {+( + {+(Send + {+(Identifier)+})+} {+(Catch {+( {+( - {+(Identifier)+})+})+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+})+} + {+(Send + {+(Identifier)+})+})+})+})+} +{-(Try + {-( + {-(Send + {-(Identifier)-})-} {-(Catch {-( {-( @@ -17,13 +24,17 @@ {-(Identifier)-} {-(Identifier)-})-} {-( - {-(Identifier)-})-})-} - {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-})-} + {-(Send + {-(Identifier)-})-})-})-} {-(Else {-(Empty)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-(Finally - {-(Identifier)-})-})) + {-(Send + {-(Identifier)-})-})-})-})-} {-(Method {-(Empty)-} {-(Identifier)-} @@ -38,7 +49,8 @@ {-(Identifier)-} {-(Identifier)-})-} {-( - {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-})-} {-([])-})-})-} {-(Else {-(Empty)-} @@ -46,7 +58,8 @@ {-(Finally {-([])-})-})-})-} {-(Try - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Catch {-(Null)-} {-(Empty)-})-})-}) diff --git a/test/fixtures/ruby/rescue.diffB-A.txt b/test/fixtures/ruby/rescue.diffB-A.txt index dc5444767..806ebf354 100644 --- a/test/fixtures/ruby/rescue.diffB-A.txt +++ b/test/fixtures/ruby/rescue.diffB-A.txt @@ -1,7 +1,8 @@ (Program - (Try - ( - (Identifier) +{+(Try + {+( + {+(Send + {+(Identifier)+})+} {+(Catch {+( {+( @@ -12,18 +13,17 @@ {+(Identifier)+} {+(Identifier)+})+} {+( - {+(Identifier)+})+})+} - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {+(Else {+(Empty)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+(Finally - {+(Identifier)+})+} - {-(Catch - {-( - {-( - {-(Identifier)-})-})-} - {-(Identifier)-})-})) + {+(Send + {+(Identifier)+})+})+})+})+} {+(Method {+(Empty)+} {+(Identifier)+} @@ -38,15 +38,27 @@ {+(Identifier)+} {+(Identifier)+})+} {+( - {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+})+} {+([])+})+})+} {+(Else {+(Empty)+} {+([])+})+} {+(Finally {+([])+})+})+})+} -{+(Try - {+(Identifier)+} + (Try + { ( + {-(Send + {-(Identifier)-})-} + {-(Catch + {-( + {-( + {-(Send + {-(Identifier)-})-})-})-} + {-(Send + {-(Identifier)-})-})-}) + ->(Send + {+(Identifier)+}) } {+(Catch {+(Null)+} - {+(Empty)+})+})+}) + {+(Empty)+})+})) diff --git a/test/fixtures/ruby/rescue.parseA.txt b/test/fixtures/ruby/rescue.parseA.txt index 53120529f..9b906f35f 100644 --- a/test/fixtures/ruby/rescue.parseA.txt +++ b/test/fixtures/ruby/rescue.parseA.txt @@ -1,7 +1,8 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ( ( @@ -12,13 +13,17 @@ (Identifier) (Identifier)) ( - (Identifier))) - (Identifier))) + (Send + (Identifier)))) + (Send + (Identifier)))) (Else (Empty) - (Identifier)) + (Send + (Identifier))) (Finally - (Identifier)))) + (Send + (Identifier))))) (Method (Empty) (Identifier) @@ -33,7 +38,8 @@ (Identifier) (Identifier)) ( - (Identifier))) + (Send + (Identifier)))) ([]))) (Else (Empty) @@ -41,7 +47,8 @@ (Finally ([])))) (Try - (Identifier) + (Send + (Identifier)) (Catch (Null) (Empty)))) diff --git a/test/fixtures/ruby/rescue.parseB.txt b/test/fixtures/ruby/rescue.parseB.txt index c78c661a5..be7a76a73 100644 --- a/test/fixtures/ruby/rescue.parseB.txt +++ b/test/fixtures/ruby/rescue.parseB.txt @@ -1,9 +1,12 @@ (Program (Try ( - (Identifier) + (Send + (Identifier)) (Catch ( ( - (Identifier))) - (Identifier))))) + (Send + (Identifier)))) + (Send + (Identifier)))))) diff --git a/test/fixtures/ruby/return.diffA-B.txt b/test/fixtures/ruby/return.diffA-B.txt index af3329be2..91eed3c30 100644 --- a/test/fixtures/ruby/return.diffA-B.txt +++ b/test/fixtures/ruby/return.diffA-B.txt @@ -1,4 +1,5 @@ (Program (Return - { (Identifier) + { (Send + {-(Identifier)-}) ->(Empty) })) diff --git a/test/fixtures/ruby/return.diffB-A.txt b/test/fixtures/ruby/return.diffB-A.txt index 7d7e9647f..a20d9027c 100644 --- a/test/fixtures/ruby/return.diffB-A.txt +++ b/test/fixtures/ruby/return.diffB-A.txt @@ -1,4 +1,5 @@ (Program (Return { (Empty) - ->(Identifier) })) + ->(Send + {+(Identifier)+}) })) diff --git a/test/fixtures/ruby/return.parseA.txt b/test/fixtures/ruby/return.parseA.txt index a8acb73dc..c5734dd38 100644 --- a/test/fixtures/ruby/return.parseA.txt +++ b/test/fixtures/ruby/return.parseA.txt @@ -1,3 +1,4 @@ (Program (Return - (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/singleton-class.parseA.txt b/test/fixtures/ruby/singleton-class.parseA.txt new file mode 100644 index 000000000..f80075b5a --- /dev/null +++ b/test/fixtures/ruby/singleton-class.parseA.txt @@ -0,0 +1,11 @@ +(Program + (Class + (Identifier) + ([])) + (Class + (ScopeResolution + (Identifier) + (Identifier)) + (Send + (Identifier) + (Symbol)))) diff --git a/test/fixtures/ruby/ternary.diffA-B.txt b/test/fixtures/ruby/ternary.diffA-B.txt index 897ee313c..35d0c9d69 100644 --- a/test/fixtures/ruby/ternary.diffA-B.txt +++ b/test/fixtures/ruby/ternary.diffA-B.txt @@ -1,8 +1,11 @@ (Program (If - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })) + (Send + { (Identifier) + ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) }))) diff --git a/test/fixtures/ruby/ternary.diffB-A.txt b/test/fixtures/ruby/ternary.diffB-A.txt index 897ee313c..35d0c9d69 100644 --- a/test/fixtures/ruby/ternary.diffB-A.txt +++ b/test/fixtures/ruby/ternary.diffB-A.txt @@ -1,8 +1,11 @@ (Program (If - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) } - { (Identifier) - ->(Identifier) })) + (Send + { (Identifier) + ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) }))) diff --git a/test/fixtures/ruby/ternary.parseA.txt b/test/fixtures/ruby/ternary.parseA.txt index 76d8615b5..5f8701c9b 100644 --- a/test/fixtures/ruby/ternary.parseA.txt +++ b/test/fixtures/ruby/ternary.parseA.txt @@ -1,5 +1,8 @@ (Program (If - (Identifier) - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/ternary.parseB.txt b/test/fixtures/ruby/ternary.parseB.txt index 76d8615b5..5f8701c9b 100644 --- a/test/fixtures/ruby/ternary.parseB.txt +++ b/test/fixtures/ruby/ternary.parseB.txt @@ -1,5 +1,8 @@ (Program (If - (Identifier) - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/unary.parseA.txt b/test/fixtures/ruby/unary.parseA.txt new file mode 100644 index 000000000..6a1bb5d57 --- /dev/null +++ b/test/fixtures/ruby/unary.parseA.txt @@ -0,0 +1,20 @@ +(Program + (Complement + (Send + (Identifier))) + (Not + (Send + (Identifier))) + (Negate + (Send + (Identifier))) + (Send + (Identifier)) + (Not + (Send + (Identifier))) + (Call + (Identifier) + (Send + (Identifier)) + (Empty))) diff --git a/test/fixtures/ruby/undef.parseA.txt b/test/fixtures/ruby/undef.parseA.txt new file mode 100644 index 000000000..aa534d9a7 --- /dev/null +++ b/test/fixtures/ruby/undef.parseA.txt @@ -0,0 +1,27 @@ +(Program + (Call + (Identifier) + (Symbol) + (Empty)) + (Call + (Identifier) + (Send + (Identifier)) + (Empty)) + (Call + (Identifier) + (Identifier) + (Empty)) + (Call + (Identifier) + (Identifier) + (Empty)) + (Call + (Identifier) + (Identifier) + (Empty)) + (Call + (Identifier) + (Symbol) + (Symbol) + (Empty))) diff --git a/test/fixtures/ruby/unless.diffA-B.txt b/test/fixtures/ruby/unless.diffA-B.txt index 35d70a884..406ec89b6 100644 --- a/test/fixtures/ruby/unless.diffA-B.txt +++ b/test/fixtures/ruby/unless.diffA-B.txt @@ -1,14 +1,18 @@ (Program (If (Not - { (Identifier) - ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) })) ([] + {-(Send + {-(Identifier)-})-}) + { (Send {-(Identifier)-}) - { (Identifier) ->(Empty) }) {+(If {+(Not - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+([])+} {+(Empty)+})+}) diff --git a/test/fixtures/ruby/unless.diffB-A.txt b/test/fixtures/ruby/unless.diffB-A.txt index dc0a2073b..ccf5e5da4 100644 --- a/test/fixtures/ruby/unless.diffB-A.txt +++ b/test/fixtures/ruby/unless.diffB-A.txt @@ -1,14 +1,18 @@ (Program (If (Not - { (Identifier) - ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) })) ( - {+(Identifier)+}) + {+(Send + {+(Identifier)+})+}) { (Empty) - ->(Identifier) }) + ->(Send + {+(Identifier)+}) }) {-(If {-(Not - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-([])-} {-(Empty)-})-}) diff --git a/test/fixtures/ruby/unless.parseA.txt b/test/fixtures/ruby/unless.parseA.txt index 6ebc0b75f..e219ada22 100644 --- a/test/fixtures/ruby/unless.parseA.txt +++ b/test/fixtures/ruby/unless.parseA.txt @@ -1,7 +1,10 @@ (Program (If (Not - (Identifier)) + (Send + (Identifier))) ( - (Identifier)) - (Identifier))) + (Send + (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/unless.parseB.txt b/test/fixtures/ruby/unless.parseB.txt index 87505c1f7..ac70e7130 100644 --- a/test/fixtures/ruby/unless.parseB.txt +++ b/test/fixtures/ruby/unless.parseB.txt @@ -1,11 +1,13 @@ (Program (If (Not - (Identifier)) + (Send + (Identifier))) ([]) (Empty)) (If (Not - (Identifier)) + (Send + (Identifier))) ([]) (Empty))) diff --git a/test/fixtures/ruby/until.diffA-B.txt b/test/fixtures/ruby/until.diffA-B.txt index 9490d37e3..3e78b93db 100644 --- a/test/fixtures/ruby/until.diffA-B.txt +++ b/test/fixtures/ruby/until.diffA-B.txt @@ -1,10 +1,14 @@ (Program (While (Not - (Identifier)) + (Send + (Identifier))) { ([]) - ->(Identifier) }) + ->(Send + {+(Identifier)+}) }) {-(While {-(Not - {-(Identifier)-})-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/until.diffB-A.txt b/test/fixtures/ruby/until.diffB-A.txt index 364b038fe..c9a208953 100644 --- a/test/fixtures/ruby/until.diffB-A.txt +++ b/test/fixtures/ruby/until.diffB-A.txt @@ -1,10 +1,14 @@ (Program (While (Not - (Identifier)) - { (Identifier) + (Send + (Identifier))) + { (Send + {-(Identifier)-}) ->([]) }) {+(While {+(Not - {+(Identifier)+})+} - {+(Identifier)+})+}) + {+(Send + {+(Identifier)+})+})+} + {+(Send + {+(Identifier)+})+})+}) diff --git a/test/fixtures/ruby/until.parseA.txt b/test/fixtures/ruby/until.parseA.txt index ebec4d08c..42514e560 100644 --- a/test/fixtures/ruby/until.parseA.txt +++ b/test/fixtures/ruby/until.parseA.txt @@ -1,9 +1,12 @@ (Program (While (Not - (Identifier)) + (Send + (Identifier))) ([])) (While (Not - (Identifier)) - (Identifier))) + (Send + (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/until.parseB.txt b/test/fixtures/ruby/until.parseB.txt index 524320200..0169df2f1 100644 --- a/test/fixtures/ruby/until.parseB.txt +++ b/test/fixtures/ruby/until.parseB.txt @@ -1,5 +1,7 @@ (Program (While (Not - (Identifier)) - (Identifier))) + (Send + (Identifier))) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/when-else.diffA-B.txt b/test/fixtures/ruby/when-else.diffA-B.txt index 351ee5af5..67b5a3187 100644 --- a/test/fixtures/ruby/when-else.diffA-B.txt +++ b/test/fixtures/ruby/when-else.diffA-B.txt @@ -1,18 +1,25 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - { (Identifier) - ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) })) ( - {+(Identifier)+} - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} {-(Pattern {-( - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-( - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-([])-})-})-}))))) diff --git a/test/fixtures/ruby/when-else.diffB-A.txt b/test/fixtures/ruby/when-else.diffB-A.txt index 6faa8148c..51de319d1 100644 --- a/test/fixtures/ruby/when-else.diffB-A.txt +++ b/test/fixtures/ruby/when-else.diffB-A.txt @@ -1,18 +1,25 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - { (Identifier) - ->(Identifier) }) + (Send + { (Identifier) + ->(Identifier) })) ( {+(Pattern {+( - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+( - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+([])+})+})+} - {-(Identifier)-} - {-(Identifier)-}))))) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-}))))) diff --git a/test/fixtures/ruby/when-else.parseA.txt b/test/fixtures/ruby/when-else.parseA.txt index 5c16a9e61..9eae0374a 100644 --- a/test/fixtures/ruby/when-else.parseA.txt +++ b/test/fixtures/ruby/when-else.parseA.txt @@ -1,15 +1,20 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - (Identifier)) + (Send + (Identifier))) ( (Pattern ( - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) ( - (Identifier) + (Send + (Identifier)) ([])))))))) diff --git a/test/fixtures/ruby/when-else.parseB.txt b/test/fixtures/ruby/when-else.parseB.txt index fc4a57a7d..4e0a1bc49 100644 --- a/test/fixtures/ruby/when-else.parseB.txt +++ b/test/fixtures/ruby/when-else.parseB.txt @@ -1,10 +1,14 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - (Identifier)) + (Send + (Identifier))) ( - (Identifier) - (Identifier)))))) + (Send + (Identifier)) + (Send + (Identifier))))))) diff --git a/test/fixtures/ruby/when.diffA-B.txt b/test/fixtures/ruby/when.diffA-B.txt index db30dc679..431220686 100644 --- a/test/fixtures/ruby/when.diffA-B.txt +++ b/test/fixtures/ruby/when.diffA-B.txt @@ -1,18 +1,24 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - (Identifier)) + (Send + (Identifier))) ( - {+(Identifier)+} + {+(Send + {+(Identifier)+})+} {+(Pattern {+( - {+(Identifier)+} - {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+} {+( - {+(Identifier)+})+})+})))) + {+(Send + {+(Identifier)+})+})+})+})))) {-(Match {-(Empty)-} {-( diff --git a/test/fixtures/ruby/when.diffB-A.txt b/test/fixtures/ruby/when.diffB-A.txt index cef7d148d..edb3b8715 100644 --- a/test/fixtures/ruby/when.diffB-A.txt +++ b/test/fixtures/ruby/when.diffB-A.txt @@ -1,18 +1,24 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - (Identifier)) + (Send + (Identifier))) ([] - {-(Identifier)-} + {-(Send + {-(Identifier)-})-} {-(Pattern {-( - {-(Identifier)-} - {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-} {-( - {-(Identifier)-})-})-})))) + {-(Send + {-(Identifier)-})-})-})-})))) {+(Match {+(Empty)+} {+( diff --git a/test/fixtures/ruby/when.parseA.txt b/test/fixtures/ruby/when.parseA.txt index 02e88aac8..2533c0c85 100644 --- a/test/fixtures/ruby/when.parseA.txt +++ b/test/fixtures/ruby/when.parseA.txt @@ -1,10 +1,12 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - (Identifier)) + (Send + (Identifier))) ([])))) (Match (Empty) diff --git a/test/fixtures/ruby/when.parseB.txt b/test/fixtures/ruby/when.parseB.txt index 506d6d79c..3c10f0c37 100644 --- a/test/fixtures/ruby/when.parseB.txt +++ b/test/fixtures/ruby/when.parseB.txt @@ -1,15 +1,21 @@ (Program (Match - (Identifier) + (Send + (Identifier)) ( (Pattern ( - (Identifier)) + (Send + (Identifier))) ( - (Identifier) + (Send + (Identifier)) (Pattern ( - (Identifier) - (Identifier)) + (Send + (Identifier)) + (Send + (Identifier))) ( - (Identifier)))))))) + (Send + (Identifier))))))))) diff --git a/test/fixtures/ruby/while.diffA-B.txt b/test/fixtures/ruby/while.diffA-B.txt index f58e72a4d..5687ca0cc 100644 --- a/test/fixtures/ruby/while.diffA-B.txt +++ b/test/fixtures/ruby/while.diffA-B.txt @@ -1,8 +1,12 @@ (Program (While - (Identifier) + (Send + (Identifier)) { ([]) - ->(Identifier) }) + ->(Send + {+(Identifier)+}) }) {-(While - {-(Identifier)-} - {-(Identifier)-})-}) + {-(Send + {-(Identifier)-})-} + {-(Send + {-(Identifier)-})-})-}) diff --git a/test/fixtures/ruby/while.diffB-A.txt b/test/fixtures/ruby/while.diffB-A.txt index 9d9665e32..969590f00 100644 --- a/test/fixtures/ruby/while.diffB-A.txt +++ b/test/fixtures/ruby/while.diffB-A.txt @@ -1,8 +1,12 @@ (Program (While - (Identifier) - { (Identifier) + (Send + (Identifier)) + { (Send + {-(Identifier)-}) ->([]) }) {+(While - {+(Identifier)+} - {+(Identifier)+})+}) + {+(Send + {+(Identifier)+})+} + {+(Send + {+(Identifier)+})+})+}) diff --git a/test/fixtures/ruby/while.parseA.txt b/test/fixtures/ruby/while.parseA.txt index e9f9fcb1d..6ae0c7011 100644 --- a/test/fixtures/ruby/while.parseA.txt +++ b/test/fixtures/ruby/while.parseA.txt @@ -1,7 +1,10 @@ (Program (While - (Identifier) + (Send + (Identifier)) ([])) (While - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/while.parseB.txt b/test/fixtures/ruby/while.parseB.txt index 9d71ba831..7fd7dda40 100644 --- a/test/fixtures/ruby/while.parseB.txt +++ b/test/fixtures/ruby/while.parseB.txt @@ -1,4 +1,6 @@ (Program (While - (Identifier) - (Identifier))) + (Send + (Identifier)) + (Send + (Identifier)))) diff --git a/test/fixtures/ruby/yield.diffA-B.txt b/test/fixtures/ruby/yield.diffA-B.txt index 1640ee3f5..5982d3d5f 100644 --- a/test/fixtures/ruby/yield.diffA-B.txt +++ b/test/fixtures/ruby/yield.diffA-B.txt @@ -1,4 +1,5 @@ (Program (Yield - { (Identifier) + { (Send + {-(Identifier)-}) ->(Empty) })) diff --git a/test/fixtures/ruby/yield.diffB-A.txt b/test/fixtures/ruby/yield.diffB-A.txt index 58cbd85f0..7f8e21d19 100644 --- a/test/fixtures/ruby/yield.diffB-A.txt +++ b/test/fixtures/ruby/yield.diffB-A.txt @@ -1,4 +1,5 @@ (Program (Yield { (Empty) - ->(Identifier) })) + ->(Send + {+(Identifier)+}) })) diff --git a/test/fixtures/ruby/yield.parseA.txt b/test/fixtures/ruby/yield.parseA.txt index b16da4483..e86849a79 100644 --- a/test/fixtures/ruby/yield.parseA.txt +++ b/test/fixtures/ruby/yield.parseA.txt @@ -1,3 +1,4 @@ (Program (Yield - (Identifier))) + (Send + (Identifier)))) From c6cdfc49581e7085b69068ea57c2f53592377685 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 9 Apr 2018 15:31:44 -0700 Subject: [PATCH 14/20] Fix CLI specs --- test/Semantic/CLI/Spec.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Semantic/CLI/Spec.hs b/test/Semantic/CLI/Spec.hs index b1cccdcee..8d716b956 100644 --- a/test/Semantic/CLI/Spec.hs +++ b/test/Semantic/CLI/Spec.hs @@ -38,9 +38,9 @@ parseFixtures = where pathMode = Right [("test/fixtures/ruby/and-or.A.rb", Just Ruby)] pathMode' = Right [("test/fixtures/ruby/and-or.A.rb", Just Ruby), ("test/fixtures/ruby/and-or.B.rb", Just Ruby)] - sExpressionParseTreeOutput = "(Program\n (LowAnd\n (Identifier)\n (Identifier)))\n" - jsonParseTreeOutput = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"}]}\n" - jsonParseTreeOutput' = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/and-or.B.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}}],\"sourceRange\":[0,10],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,11]}},{\"category\":\"LowAnd\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[11,12],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,2]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"b\",\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}}],\"sourceRange\":[11,17],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,7]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"c\",\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}}],\"sourceRange\":[11,23],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,13]}}],\"sourceRange\":[0,24],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}},\"language\":\"Ruby\"}]}\n" + sExpressionParseTreeOutput = "(Program\n (LowAnd\n (Call\n (Identifier)\n (Empty))\n (Call\n (Identifier)\n (Empty))))\n" + jsonParseTreeOutput = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[4,4],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,5]}}],\"sourceRange\":[0,4],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,5]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[11,11],\"sourceSpan\":{\"start\":[1,12],\"end\":[1,12]}}],\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"}]}\n" + jsonParseTreeOutput' = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[4,4],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,5]}}],\"sourceRange\":[0,4],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,5]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[11,11],\"sourceSpan\":{\"start\":[1,12],\"end\":[1,12]}}],\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/and-or.B.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[4,4],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,5]}}],\"sourceRange\":[0,4],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,5]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[10,10],\"sourceSpan\":{\"start\":[1,11],\"end\":[1,11]}}],\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}}],\"sourceRange\":[0,10],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,11]}},{\"category\":\"LowAnd\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[11,12],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,2]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[13,13],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,3]}}],\"sourceRange\":[11,13],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,3]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"b\",\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[17,17],\"sourceSpan\":{\"start\":[2,7],\"end\":[2,7]}}],\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}}],\"sourceRange\":[11,17],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,7]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"c\",\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[23,23],\"sourceSpan\":{\"start\":[2,13],\"end\":[2,13]}}],\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}}],\"sourceRange\":[11,23],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,13]}}],\"sourceRange\":[0,24],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}},\"language\":\"Ruby\"}]}\n" emptyJsonParseTreeOutput = "{\"trees\":[]}\n" symbolsOutput = "{\"files\":[{\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"symbols\":[{\"span\":{\"start\":[1,1],\"end\":[2,4]},\"kind\":\"Method\",\"symbol\":\"foo\"}],\"language\":\"Ruby\"}]}\n" tagsOutput = "[{\"span\":{\"start\":[1,1],\"end\":[2,4]},\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"kind\":\"Method\",\"symbol\":\"foo\",\"line\":\"def foo\",\"language\":\"Ruby\"}]\n" @@ -54,6 +54,6 @@ diffFixtures = ] where pathMode = Right [both ("test/fixtures/ruby/method-declaration.A.rb", Just Ruby) ("test/fixtures/ruby/method-declaration.B.rb", Just Ruby)] - jsonOutput = "{\"diffs\":[{\"diff\":{\"merge\":{\"after\":{\"category\":\"Program\",\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Method\",\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}},\"children\":[],\"before\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}}}},{\"patch\":{\"replace\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]}},{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"merge\":{\"after\":{\"category\":\"\",\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}},\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"baz\",\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}}],\"before\":{\"category\":\"[]\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Method\",\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Program\",\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}}},\"stat\":{\"replace\":[{\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/method-declaration.B.rb\",\"language\":\"Ruby\"}],\"path\":\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\"}}]}\n" - sExpressionOutput = "(Program\n (Method\n (Empty)\n { (Identifier)\n ->(Identifier) }\n {+(Identifier)+}\n (\n {+(Identifier)+})))\n" + jsonOutput = "{\"diffs\":[{\"diff\":{\"merge\":{\"after\":{\"category\":\"Program\",\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Method\",\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}},\"children\":[],\"before\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}}}},{\"patch\":{\"replace\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]}},{\"patch\":{\"insert\":{\"category\":\"Call\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"patch\":{\"insert\":{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[9,9],\"sourceSpan\":{\"start\":[1,10],\"end\":[1,10]}}}}],\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"merge\":{\"after\":{\"category\":\"\",\"sourceRange\":[13,17],\"sourceSpan\":{\"start\":[2,3],\"end\":[3,1]}},\"children\":[{\"patch\":{\"insert\":{\"category\":\"Call\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"baz\",\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}},{\"patch\":{\"insert\":{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[17,17],\"sourceSpan\":{\"start\":[3,1],\"end\":[3,1]}}}}],\"sourceRange\":[13,17],\"sourceSpan\":{\"start\":[2,3],\"end\":[3,1]}}}}],\"before\":{\"category\":\"[]\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Method\",\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Program\",\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}}},\"stat\":{\"replace\":[{\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/method-declaration.B.rb\",\"language\":\"Ruby\"}],\"path\":\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\"}}]}\n" + sExpressionOutput = "(Program\n (Method\n (Empty)\n { (Identifier)\n ->(Identifier) }\n {+(Call\n {+(Identifier)+}\n {+(Empty)+})+}\n (\n {+(Call\n {+(Identifier)+}\n {+(Empty)+})+})))\n" tocOutput = "{\"changes\":{\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\":[{\"span\":{\"start\":[1,1],\"end\":[3,4]},\"category\":\"Method\",\"term\":\"bar\",\"changeType\":\"modified\"}]},\"errors\":{}}\n" From cdb5672b2730a712eb2612255decf40f795bd14e Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 15:40:46 +1000 Subject: [PATCH 15/20] test: fix expected output for parse and diff cli tests --- test/Semantic/CLI/Spec.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Semantic/CLI/Spec.hs b/test/Semantic/CLI/Spec.hs index 8d716b956..996387155 100644 --- a/test/Semantic/CLI/Spec.hs +++ b/test/Semantic/CLI/Spec.hs @@ -38,9 +38,9 @@ parseFixtures = where pathMode = Right [("test/fixtures/ruby/and-or.A.rb", Just Ruby)] pathMode' = Right [("test/fixtures/ruby/and-or.A.rb", Just Ruby), ("test/fixtures/ruby/and-or.B.rb", Just Ruby)] - sExpressionParseTreeOutput = "(Program\n (LowAnd\n (Call\n (Identifier)\n (Empty))\n (Call\n (Identifier)\n (Empty))))\n" - jsonParseTreeOutput = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[4,4],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,5]}}],\"sourceRange\":[0,4],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,5]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[11,11],\"sourceSpan\":{\"start\":[1,12],\"end\":[1,12]}}],\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"}]}\n" - jsonParseTreeOutput' = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[4,4],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,5]}}],\"sourceRange\":[0,4],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,5]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[11,11],\"sourceSpan\":{\"start\":[1,12],\"end\":[1,12]}}],\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/and-or.B.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[4,4],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,5]}}],\"sourceRange\":[0,4],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,5]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[10,10],\"sourceSpan\":{\"start\":[1,11],\"end\":[1,11]}}],\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}}],\"sourceRange\":[0,10],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,11]}},{\"category\":\"LowAnd\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[11,12],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,2]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[13,13],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,3]}}],\"sourceRange\":[11,13],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,3]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"b\",\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[17,17],\"sourceSpan\":{\"start\":[2,7],\"end\":[2,7]}}],\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}}],\"sourceRange\":[11,17],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,7]}},{\"category\":\"Call\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"c\",\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}},{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[23,23],\"sourceSpan\":{\"start\":[2,13],\"end\":[2,13]}}],\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}}],\"sourceRange\":[11,23],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,13]}}],\"sourceRange\":[0,24],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}},\"language\":\"Ruby\"}]}\n" + sExpressionParseTreeOutput = "(Program\n (LowAnd\n (Send\n (Identifier))\n (Send\n (Identifier))))\n" + jsonParseTreeOutput = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}}],\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"}]}\n" + jsonParseTreeOutput' = "{\"trees\":[{\"path\":\"test/fixtures/ruby/and-or.A.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowAnd\",\"children\":[{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}}],\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,12]}}],\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,12]}}],\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,1]}},\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/and-or.B.rb\",\"programNode\":{\"category\":\"Program\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}}],\"sourceRange\":[0,3],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,4]}},{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}}],\"sourceRange\":[7,10],\"sourceSpan\":{\"start\":[1,8],\"end\":[1,11]}}],\"sourceRange\":[0,10],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,11]}},{\"category\":\"LowAnd\",\"children\":[{\"category\":\"LowOr\",\"children\":[{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[11,12],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,2]}}],\"sourceRange\":[11,12],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,2]}},{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"b\",\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}}],\"sourceRange\":[16,17],\"sourceSpan\":{\"start\":[2,6],\"end\":[2,7]}}],\"sourceRange\":[11,17],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,7]}},{\"category\":\"Send\",\"children\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"c\",\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}}],\"sourceRange\":[22,23],\"sourceSpan\":{\"start\":[2,12],\"end\":[2,13]}}],\"sourceRange\":[11,23],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,13]}}],\"sourceRange\":[0,24],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}},\"language\":\"Ruby\"}]}\n" emptyJsonParseTreeOutput = "{\"trees\":[]}\n" symbolsOutput = "{\"files\":[{\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"symbols\":[{\"span\":{\"start\":[1,1],\"end\":[2,4]},\"kind\":\"Method\",\"symbol\":\"foo\"}],\"language\":\"Ruby\"}]}\n" tagsOutput = "[{\"span\":{\"start\":[1,1],\"end\":[2,4]},\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"kind\":\"Method\",\"symbol\":\"foo\",\"line\":\"def foo\",\"language\":\"Ruby\"}]\n" @@ -54,6 +54,6 @@ diffFixtures = ] where pathMode = Right [both ("test/fixtures/ruby/method-declaration.A.rb", Just Ruby) ("test/fixtures/ruby/method-declaration.B.rb", Just Ruby)] - jsonOutput = "{\"diffs\":[{\"diff\":{\"merge\":{\"after\":{\"category\":\"Program\",\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Method\",\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}},\"children\":[],\"before\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}}}},{\"patch\":{\"replace\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]}},{\"patch\":{\"insert\":{\"category\":\"Call\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"patch\":{\"insert\":{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[9,9],\"sourceSpan\":{\"start\":[1,10],\"end\":[1,10]}}}}],\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"merge\":{\"after\":{\"category\":\"\",\"sourceRange\":[13,17],\"sourceSpan\":{\"start\":[2,3],\"end\":[3,1]}},\"children\":[{\"patch\":{\"insert\":{\"category\":\"Call\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"baz\",\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}},{\"patch\":{\"insert\":{\"category\":\"Empty\",\"children\":[],\"sourceRange\":[17,17],\"sourceSpan\":{\"start\":[3,1],\"end\":[3,1]}}}}],\"sourceRange\":[13,17],\"sourceSpan\":{\"start\":[2,3],\"end\":[3,1]}}}}],\"before\":{\"category\":\"[]\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Method\",\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Program\",\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}}},\"stat\":{\"replace\":[{\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/method-declaration.B.rb\",\"language\":\"Ruby\"}],\"path\":\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\"}}]}\n" - sExpressionOutput = "(Program\n (Method\n (Empty)\n { (Identifier)\n ->(Identifier) }\n {+(Call\n {+(Identifier)+}\n {+(Empty)+})+}\n (\n {+(Call\n {+(Identifier)+}\n {+(Empty)+})+})))\n" + jsonOutput = "{\"diffs\":[{\"diff\":{\"merge\":{\"after\":{\"category\":\"Program\",\"sourceRange\":[0,21],\"sourceSpan\":{\"start\":[1,1],\"end\":[4,1]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Method\",\"sourceRange\":[0,20],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,4]}},\"children\":[{\"merge\":{\"after\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}},\"children\":[],\"before\":{\"category\":\"Empty\",\"sourceRange\":[0,0],\"sourceSpan\":{\"start\":[1,1],\"end\":[1,1]}}}},{\"patch\":{\"replace\":[{\"category\":\"Identifier\",\"children\":[],\"name\":\"foo\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}},{\"category\":\"Identifier\",\"children\":[],\"name\":\"bar\",\"sourceRange\":[4,7],\"sourceSpan\":{\"start\":[1,5],\"end\":[1,8]}}]}},{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"a\",\"sourceRange\":[8,9],\"sourceSpan\":{\"start\":[1,9],\"end\":[1,10]}}}},{\"merge\":{\"after\":{\"category\":\"\",\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}},\"children\":[{\"patch\":{\"insert\":{\"category\":\"Send\",\"children\":[{\"patch\":{\"insert\":{\"category\":\"Identifier\",\"children\":[],\"name\":\"baz\",\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}}],\"sourceRange\":[13,16],\"sourceSpan\":{\"start\":[2,3],\"end\":[2,6]}}}}],\"before\":{\"category\":\"[]\",\"sourceRange\":[8,11],\"sourceSpan\":{\"start\":[2,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Method\",\"sourceRange\":[0,11],\"sourceSpan\":{\"start\":[1,1],\"end\":[2,4]}}}}],\"before\":{\"category\":\"Program\",\"sourceRange\":[0,12],\"sourceSpan\":{\"start\":[1,1],\"end\":[3,1]}}}},\"stat\":{\"replace\":[{\"path\":\"test/fixtures/ruby/method-declaration.A.rb\",\"language\":\"Ruby\"},{\"path\":\"test/fixtures/ruby/method-declaration.B.rb\",\"language\":\"Ruby\"}],\"path\":\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\"}}]}\n" + sExpressionOutput = "(Program\n (Method\n (Empty)\n { (Identifier)\n ->(Identifier) }\n {+(Identifier)+}\n (\n {+(Send\n {+(Identifier)+})+})))\n" tocOutput = "{\"changes\":{\"test/fixtures/ruby/method-declaration.A.rb -> test/fixtures/ruby/method-declaration.B.rb\":[{\"span\":{\"start\":[1,1],\"end\":[3,4]},\"category\":\"Method\",\"term\":\"bar\",\"changeType\":\"modified\"}]},\"errors\":{}}\n" From a81beeb125d465122c53061a8f72243fb3d9c360 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 15:47:52 +1000 Subject: [PATCH 16/20] ruby: register parameters as local identifier names --- src/Language/Ruby/Assignment.hs | 3 +-- test/fixtures/ruby/lambda.diffA-B.txt | 3 +-- test/fixtures/ruby/lambda.diffB-A.txt | 3 +-- test/fixtures/ruby/lambda.parseB.txt | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index c0c619121..05a95d6d0 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -230,8 +230,7 @@ scopeResolution = makeTerm <$> symbol ScopeResolution <*> children (Expression.S parameter :: Assignment parameter = - mk Identifier - <|> mk Identifier' + lhsIdent <|> mk SplatParameter <|> mk HashSplatParameter <|> mk BlockParameter diff --git a/test/fixtures/ruby/lambda.diffA-B.txt b/test/fixtures/ruby/lambda.diffA-B.txt index 347a6dbfa..67d452c63 100644 --- a/test/fixtures/ruby/lambda.diffA-B.txt +++ b/test/fixtures/ruby/lambda.diffA-B.txt @@ -6,8 +6,7 @@ {+(Identifier)+} { ([]) ->(Plus - {+(Send - {+(Identifier)+})+} + {+(Identifier)+} {+(Integer)+}) })) {-(Send {-(Identifier)-} diff --git a/test/fixtures/ruby/lambda.diffB-A.txt b/test/fixtures/ruby/lambda.diffB-A.txt index fd3c37ae8..1f25ddb9c 100644 --- a/test/fixtures/ruby/lambda.diffB-A.txt +++ b/test/fixtures/ruby/lambda.diffB-A.txt @@ -5,8 +5,7 @@ (Empty) {-(Identifier)-} { (Plus - {-(Send - {-(Identifier)-})-} + {-(Identifier)-} {-(Integer)-}) ->([]) })) {+(Send diff --git a/test/fixtures/ruby/lambda.parseB.txt b/test/fixtures/ruby/lambda.parseB.txt index 0ae3a43d2..23f3795f0 100644 --- a/test/fixtures/ruby/lambda.parseB.txt +++ b/test/fixtures/ruby/lambda.parseB.txt @@ -5,6 +5,5 @@ (Empty) (Identifier) (Plus - (Send - (Identifier)) + (Identifier) (Integer))))) From bdcd8fcbc3ec656ae7fa6ba13f02305c8193f5e9 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Wed, 11 Apr 2018 16:32:55 +1000 Subject: [PATCH 17/20] ruby: implement more strict assignment for parameters --- src/Language/Ruby/Assignment.hs | 24 ++++++++++++++----- ...thod-declaration-unnamed-param.diffA-B.txt | 2 +- ...thod-declaration-unnamed-param.diffB-A.txt | 2 +- ...ethod-declaration-unnamed-param.parseB.txt | 2 +- test/fixtures/ruby/methods.parseA.txt | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 05a95d6d0..8782d5203 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -231,13 +231,25 @@ scopeResolution = makeTerm <$> symbol ScopeResolution <*> children (Expression.S parameter :: Assignment parameter = lhsIdent - <|> mk SplatParameter - <|> mk HashSplatParameter - <|> mk BlockParameter - <|> mk KeywordParameter - <|> mk OptionalParameter + <|> splatParameter + <|> hashSplatParameter + <|> blockParameter + <|> keywordParameter + <|> optionalParameter <|> makeTerm <$> symbol DestructuredParameter <*> children (many parameter) - where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) + where + -- splat and hash splat arguments can be unnamed. we don't currently + -- support unnamed arguments in the term syntax, so the use of emptyTerm + -- here is a huge hack. what we should be able to do is return a Nothing + -- for the argument name for splats and hash splats. TODO fix me: + mkSplat s = symbol s *> children (lhsIdent <|> emptyTerm) + splatParameter = mkSplat SplatParameter + hashSplatParameter = mkSplat HashSplatParameter + blockParameter = symbol BlockParameter *> children lhsIdent + -- we don't yet care about default expressions for optional (including + -- keyword) parameters, but we need to match on them to prevent errors: + keywordParameter = symbol KeywordParameter *> children (lhsIdent <* optional expression) + optionalParameter = symbol OptionalParameter *> children (lhsIdent <* expression) method :: Assignment method = makeTerm <$> symbol Method <*> (withNewScope . children) (Declaration.Method <$> pure [] <*> emptyTerm <*> methodSelector <*> params <*> expressions') diff --git a/test/fixtures/ruby/method-declaration-unnamed-param.diffA-B.txt b/test/fixtures/ruby/method-declaration-unnamed-param.diffA-B.txt index 675cbc16b..72c9961f7 100644 --- a/test/fixtures/ruby/method-declaration-unnamed-param.diffA-B.txt +++ b/test/fixtures/ruby/method-declaration-unnamed-param.diffA-B.txt @@ -3,5 +3,5 @@ (Empty) (Identifier) (Identifier) - {+(Identifier)+} + {+(Empty)+} ([]))) diff --git a/test/fixtures/ruby/method-declaration-unnamed-param.diffB-A.txt b/test/fixtures/ruby/method-declaration-unnamed-param.diffB-A.txt index a6fbfc702..50487c8b0 100644 --- a/test/fixtures/ruby/method-declaration-unnamed-param.diffB-A.txt +++ b/test/fixtures/ruby/method-declaration-unnamed-param.diffB-A.txt @@ -3,5 +3,5 @@ (Empty) (Identifier) (Identifier) - {-(Identifier)-} + {-(Empty)-} ([]))) diff --git a/test/fixtures/ruby/method-declaration-unnamed-param.parseB.txt b/test/fixtures/ruby/method-declaration-unnamed-param.parseB.txt index 92cbd428b..8d306c54e 100644 --- a/test/fixtures/ruby/method-declaration-unnamed-param.parseB.txt +++ b/test/fixtures/ruby/method-declaration-unnamed-param.parseB.txt @@ -3,5 +3,5 @@ (Empty) (Identifier) (Identifier) - (Identifier) + (Empty) ([]))) diff --git a/test/fixtures/ruby/methods.parseA.txt b/test/fixtures/ruby/methods.parseA.txt index c801ae2f7..546f73f91 100644 --- a/test/fixtures/ruby/methods.parseA.txt +++ b/test/fixtures/ruby/methods.parseA.txt @@ -18,7 +18,7 @@ (Identifier) (Identifier) (Identifier) - (Identifier) + (Empty) ([])) (Method (Empty) From 584aa364b517578e4eb6455582ffde42ae6a312b Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Fri, 13 Apr 2018 17:40:45 +1000 Subject: [PATCH 18/20] style cleanups --- src/Assigning/Assignment.hs | 5 ++--- src/Language/Ruby/Assignment.hs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Assigning/Assignment.hs b/src/Assigning/Assignment.hs index 676b9af40..d200082ba 100644 --- a/src/Assigning/Assignment.hs +++ b/src/Assigning/Assignment.hs @@ -148,9 +148,8 @@ getRubyLocals :: HasCallStack => Assignment ast grammar [ByteString] getRubyLocals = tracing GetRubyLocals `Then` return putRubyLocals :: (HasCallStack, Enum grammar, Eq1 ast, Ix grammar) => [ByteString] -> Assignment ast grammar () -putRubyLocals l = mk (PutRubyLocals l) <|> mk End - where - mk a = tracing a `Then` return +putRubyLocals l = (tracing (PutRubyLocals l) `Then` return) + <|> (tracing End `Then` return) -- | Zero-width production of the current node. currentNode :: HasCallStack => Assignment ast grammar (TermF ast (Node grammar) ()) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 8782d5203..9bd488ffe 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -411,11 +411,11 @@ assignment' = makeTerm <$> symbol Assignment <*> children (Statement.As lhsIdent :: Assignment lhsIdent = do - sym <- symbol Identifier <|> symbol Identifier' + loc <- symbol Identifier <|> symbol Identifier' locals <- getRubyLocals ident <- source putRubyLocals (ident : locals) - pure $ makeTerm sym $ Syntax.Identifier $ name ident + pure $ makeTerm loc (Syntax.Identifier (name ident)) unary :: Assignment unary = symbol Unary >>= \ location -> From 699e2642ff7c122d926b9cb7696cf1b396f55e9d Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 16 Apr 2018 17:16:14 +1000 Subject: [PATCH 19/20] allow comments in and around parameters --- src/Language/Ruby/Assignment.hs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 9bd488ffe..54731081e 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -229,15 +229,16 @@ scopeResolution :: Assignment scopeResolution = makeTerm <$> symbol ScopeResolution <*> children (Expression.ScopeResolution <$> many expression) parameter :: Assignment -parameter = - lhsIdent - <|> splatParameter - <|> hashSplatParameter - <|> blockParameter - <|> keywordParameter - <|> optionalParameter - <|> makeTerm <$> symbol DestructuredParameter <*> children (many parameter) +parameter = postContextualize comment (term uncontextualizedParameter) where + uncontextualizedParameter = + lhsIdent + <|> splatParameter + <|> hashSplatParameter + <|> blockParameter + <|> keywordParameter + <|> optionalParameter + <|> makeTerm <$> symbol DestructuredParameter <*> children (many parameter) -- splat and hash splat arguments can be unnamed. we don't currently -- support unnamed arguments in the term syntax, so the use of emptyTerm -- here is a huge hack. what we should be able to do is return a Nothing From 08a6b0a2d69909a65594e9f8fa567af10fe991f7 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 16 Apr 2018 17:39:34 +1000 Subject: [PATCH 20/20] appease hlint --- src/Language/Ruby/Assignment.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Language/Ruby/Assignment.hs b/src/Language/Ruby/Assignment.hs index 54731081e..5b5426de1 100644 --- a/src/Language/Ruby/Assignment.hs +++ b/src/Language/Ruby/Assignment.hs @@ -177,9 +177,7 @@ identifier = where mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source) vcallOrLocal = do - loc <- symbol Identifier <|> symbol Identifier' - locals <- getRubyLocals - ident <- source + (loc, ident, locals) <- identWithLocals let identTerm = makeTerm loc (Syntax.Identifier (name ident)) if ident `elem` locals then pure identTerm @@ -410,11 +408,17 @@ assignment' = makeTerm <$> symbol Assignment <*> children (Statement.As <|> lhsIdent <|> expression -lhsIdent :: Assignment -lhsIdent = do +identWithLocals :: Assignment' (Record Location, ByteString, [ByteString]) +identWithLocals = do loc <- symbol Identifier <|> symbol Identifier' + -- source advances, so it's important we call getRubyLocals first locals <- getRubyLocals ident <- source + pure (loc, ident, locals) + +lhsIdent :: Assignment +lhsIdent = do + (loc, ident, locals) <- identWithLocals putRubyLocals (ident : locals) pure $ makeTerm loc (Syntax.Identifier (name ident))