1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Merge remote-tracking branch 'origin/master' into typescript-graphs

This commit is contained in:
Timothy Clem 2018-04-16 08:28:48 -07:00
commit 44e0d2f08e
159 changed files with 1399 additions and 527 deletions

View File

@ -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,13 @@ 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, Enum grammar, Eq1 ast, Ix grammar) => [ByteString] -> Assignment ast grammar ()
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) ())
currentNode = tracing CurrentNode `Then` return
@ -239,6 +250,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 +290,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 +299,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 +388,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

View File

@ -146,10 +146,22 @@ expressions = makeTerm'' <$> location <*> many expression
parenthesizedExpressions :: Assignment
parenthesizedExpressions = makeTerm'' <$> symbol ParenthesizedStatements <*> children (Syntax.Paren <$> expressions)
withExtendedScope :: Assignment' a -> Assignment' a
withExtendedScope inner = do
locals <- getRubyLocals
result <- inner
putRubyLocals locals
pure result
withNewScope :: Assignment' a -> Assignment' a
withNewScope inner = withExtendedScope $ do
putRubyLocals []
inner
-- Looks up identifiers in the list of locals to determine vcall vs. local identifier.
identifier :: Assignment
identifier =
mk Identifier
<|> mk Identifier'
vcallOrLocal
<|> mk Constant
<|> mk InstanceVariable
<|> mk ClassVariable
@ -162,7 +174,14 @@ identifier =
<|> 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, ident, locals) <- identWithLocals
let identTerm = makeTerm loc (Syntax.Identifier (name ident))
if ident `elem` locals
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
@ -195,48 +214,63 @@ 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)
parameter :: Assignment
parameter =
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)
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
-- 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 <*> children (Declaration.Method <$> pure [] <*> emptyTerm <*> 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 <*> 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
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 <*> 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 <*> 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
comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
@ -324,6 +358,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
@ -370,8 +405,23 @@ 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
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))
unary :: Assignment
unary = symbol Unary >>= \ location ->
makeTerm location . Expression.Complement <$> children ( symbol AnonTilde *> expression )

View File

@ -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 []]])

View File

@ -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 (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\":\"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\":\"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"

29
test/fixtures/ruby/alias.parseA.txt vendored Normal file
View File

@ -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)))

View File

@ -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) })))

View File

@ -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)-})-})-})

View File

@ -1,4 +1,6 @@
(Program
(LowAnd
(Identifier)
(Identifier)))
(Send
(Identifier))
(Send
(Identifier))))

View File

@ -1,9 +1,14 @@
(Program
(LowOr
(Identifier)
(Identifier))
(Send
(Identifier))
(Send
(Identifier)))
(LowAnd
(LowOr
(Identifier)
(Identifier))
(Identifier)))
(Send
(Identifier))
(Send
(Identifier)))
(Send
(Identifier))))

View File

@ -1,5 +1,7 @@
(Program
{+(Identifier)+}
{+(Send
{+(Identifier)+})+}
(ScopeEntry
{ (Identifier)
->(Identifier) }))
(Send
{ (Identifier)
->(Identifier) })))

View File

@ -1,6 +1,9 @@
(Program
{+(ScopeEntry
{+(Identifier)+})+}
{-(Identifier)-}
{+(Send
{+(Identifier)+})+})+}
{-(Send
{-(Identifier)-})-}
{-(ScopeEntry
{-(Identifier)-})-})
{-(Send
{-(Identifier)-})-})-})

View File

@ -1,3 +1,4 @@
(Program
(ScopeEntry
(Identifier)))
(Send
(Identifier))))

View File

@ -1,4 +1,6 @@
(Program
(Identifier)
(Send
(Identifier))
(ScopeEntry
(Identifier)))
(Send
(Identifier))))

121
test/fixtures/ruby/binary.parseA.txt vendored Normal file
View File

@ -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))))

View File

@ -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)-})-})-})

View File

@ -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)+})+})+})

View File

@ -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))))

View File

@ -1,7 +1,11 @@
(Program
(BAnd
(Identifier)
(Identifier))
(Send
(Identifier))
(Send
(Identifier)))
(LShift
(Identifier)
(Identifier)))
(Send
(Identifier))
(Send
(Identifier))))

View File

@ -1,7 +1,11 @@
(Program
{ (Or
{-(Identifier)-}
{-(Identifier)-})
{-(Send
{-(Identifier)-})-}
{-(Send
{-(Identifier)-})-})
->(And
{+(Identifier)+}
{+(Identifier)+}) })
{+(Send
{+(Identifier)+})+}
{+(Send
{+(Identifier)+})+}) })

View File

@ -1,7 +1,11 @@
(Program
{ (And
{-(Identifier)-}
{-(Identifier)-})
{-(Send
{-(Identifier)-})-}
{-(Send
{-(Identifier)-})-})
->(Or
{+(Identifier)+}
{+(Identifier)+}) })
{+(Send
{+(Identifier)+})+}
{+(Send
{+(Identifier)+})+}) })

View File

@ -1,4 +1,6 @@
(Program
(Or
(Identifier)
(Identifier)))
(Send
(Identifier))
(Send
(Identifier))))

View File

@ -1,4 +1,6 @@
(Program
(And
(Identifier)
(Identifier)))
(Send
(Identifier))
(Send
(Identifier))))

View File

@ -1,7 +1,9 @@
(Program
(While
{ (Identifier)
{ (Send
{-(Identifier)-})
->(Not
{+(Identifier)+}) }
{+(Send
{+(Identifier)+})+}) }
(Break
(Empty))))

View File

@ -1,7 +1,9 @@
(Program
(While
{ (Not
{-(Identifier)-})
->(Identifier) }
{-(Send
{-(Identifier)-})-})
->(Send
{+(Identifier)+}) }
(Break
(Empty))))

View File

@ -1,5 +1,6 @@
(Program
(While
(Identifier)
(Send
(Identifier))
(Break
(Empty))))

View File

@ -1,6 +1,7 @@
(Program
(While
(Not
(Identifier))
(Send
(Identifier)))
(Break
(Empty))))

33
test/fixtures/ruby/calls.parseA.txt vendored Normal file
View File

@ -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)))

View File

@ -0,0 +1,4 @@
(Program
(
(TextElement)
(TextElement)))

View File

@ -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)-})-})-})

View File

@ -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)-})-})-})

View File

@ -1,7 +1,11 @@
(Program
(LessThan
(Identifier)
(Identifier))
(Send
(Identifier))
(Send
(Identifier)))
(GreaterThan
(Identifier)
(Identifier)))
(Send
(Identifier))
(Send
(Identifier))))

View File

@ -1,7 +1,11 @@
(Program
(LessThanEqual
(Identifier)
(Identifier))
(Send
(Identifier))
(Send
(Identifier)))
(GreaterThanEqual
(Identifier)
(Identifier)))
(Send
(Identifier))
(Send
(Identifier))))

View File

@ -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)-})-})

View File

@ -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)+})+})

View File

@ -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)))

View File

@ -1,7 +1,9 @@
(Program
(Subscript
(Identifier)
(Send
(Identifier))
(TextElement))
(Subscript
(Identifier)
(Send
(Identifier))
(Symbol)))

View File

@ -1,11 +1,13 @@
(Program
(If
(Identifier)
(Send
(Identifier))
(
(Send
(Identifier)))
(If
(Identifier)
(Send
(Identifier))
(
{+(Send
{+(Identifier)+})+})

View File

@ -1,11 +1,13 @@
(Program
(If
(Identifier)
(Send
(Identifier))
(
(Send
(Identifier)))
(If
(Identifier)
(Send
(Identifier))
([]
{-(Send
{-(Identifier)-})-})

View File

@ -1,10 +1,12 @@
(Program
(If
(Identifier)
(Send
(Identifier))
(
(Send
(Identifier)))
(If
(Identifier)
(Send
(Identifier))
([])
(Empty))))

View File

@ -1,11 +1,13 @@
(Program
(If
(Identifier)
(Send
(Identifier))
(
(Send
(Identifier)))
(If
(Identifier)
(Send
(Identifier))
(
(Send
(Identifier)))

View File

@ -0,0 +1,2 @@
(Program
(Empty))

View File

@ -1,5 +1,7 @@
(Program
{+(Identifier)+}
{+(Send
{+(Identifier)+})+}
(ScopeExit
{ (Identifier)
->(Identifier) }))
(Send
{ (Identifier)
->(Identifier) })))

View File

@ -1,6 +1,9 @@
(Program
{+(ScopeExit
{+(Identifier)+})+}
{-(Identifier)-}
{+(Send
{+(Identifier)+})+})+}
{-(Send
{-(Identifier)-})-}
{-(ScopeExit
{-(Identifier)-})-})
{-(Send
{-(Identifier)-})-})-})

View File

@ -1,3 +1,4 @@
(Program
(ScopeExit
(Identifier)))
(Send
(Identifier))))

View File

@ -1,4 +1,6 @@
(Program
(Identifier)
(Send
(Identifier))
(ScopeExit
(Identifier)))
(Send
(Identifier))))

View File

@ -1,7 +1,9 @@
(Program
(Try
(
(Identifier)
(Send
(Identifier))
(Finally
{ ([])
->(Identifier) }))))
->(Send
{+(Identifier)+}) }))))

View File

@ -1,7 +1,9 @@
(Program
(Try
(
(Identifier)
(Send
(Identifier))
(Finally
{ (Identifier)
{ (Send
{-(Identifier)-})
->([]) }))))

View File

@ -1,6 +1,7 @@
(Program
(Try
(
(Identifier)
(Send
(Identifier))
(Finally
([])))))

View File

@ -1,6 +1,8 @@
(Program
(Try
(
(Identifier)
(Send
(Identifier))
(Finally
(Identifier)))))
(Send
(Identifier))))))

View File

@ -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)-}

View File

@ -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)+}

View File

@ -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)

View File

@ -1,11 +1,13 @@
(Program
(ForEach
(
(Identifier))
(Send
(Identifier)))
(Array
(Integer)
(Integer)
(Integer))
(Send
(Identifier)
(Identifier))))
(Send
(Identifier)))))

View File

@ -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)-}

View File

@ -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)+}

View File

@ -17,7 +17,8 @@
(Context
(Comment)
(KeyValue
(Identifier)
(Send
(Identifier))
(Integer)))
(Context
(Comment)

View File

@ -1,11 +1,14 @@
(Program
(Hash
(KeyValue
(Identifier)
(Send
(Identifier))
(TextElement))
(KeyValue
(Identifier)
(Send
(Identifier))
(Integer))
(KeyValue
(Identifier)
(Send
(Identifier))
(Boolean))))

View File

@ -1,7 +1,10 @@
(Program
(If
{ (Not
{-(Identifier)-})
->(Identifier) }
(Identifier)
{-(Send
{-(Identifier)-})-})
->(Send
{+(Identifier)+}) }
(Send
(Identifier))
(Empty)))

View File

@ -1,7 +1,10 @@
(Program
(If
{ (Identifier)
{ (Send
{-(Identifier)-})
->(Not
{+(Identifier)+}) }
(Identifier)
{+(Send
{+(Identifier)+})+}) }
(Send
(Identifier))
(Empty)))

View File

@ -1,6 +1,8 @@
(Program
(If
(Not
(Send
(Identifier)))
(Send
(Identifier))
(Identifier)
(Empty)))

View File

@ -1,5 +1,7 @@
(Program
(If
(Identifier)
(Identifier)
(Send
(Identifier))
(Send
(Identifier))
(Empty)))

View File

@ -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)+})+})

View File

@ -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)-})-})

View File

@ -1,10 +1,15 @@
(Program
(If
(Identifier)
(
(Send
(Identifier))
(
(Send
(Identifier)))
(If
(Identifier)
(
(Send
(Identifier))
(Identifier))))
(
(Send
(Identifier)))
(Send
(Identifier)))))

View File

@ -1,9 +1,11 @@
(Program
(If
(Identifier)
(Send
(Identifier))
([])
(Empty))
(If
(Identifier)
(Send
(Identifier))
([])
(Empty)))

View File

@ -0,0 +1,7 @@
(Program
(Send
(Identifier))
(Send
(Identifier))
(Send
(Identifier)))

View File

@ -9,4 +9,5 @@
{ (
{-(Integer)-}
{-(Integer)-})
->(Identifier) })))
->(Send
{+(Identifier)+}) })))

View File

@ -6,7 +6,8 @@
{+(Identifier)+}
(Function
(Empty)
{ (Identifier)
{ (Send
{-(Identifier)-})
->(
{+(Integer)+}
{+(Integer)+}) })))

View File

@ -3,4 +3,5 @@
(Empty)
(Function
(Empty)
(Identifier))))
(Send
(Identifier)))))

View File

@ -12,7 +12,8 @@
{-(Identifier)-}
{-(Function
{-(Empty)-}
{-(Identifier)-})-})-}
{-(Send
{-(Identifier)-})-})-})-}
{-(Send
{-(Identifier)-}
{-(Function
@ -30,7 +31,8 @@
{-(Empty)-}
{-(Function
{-(Empty)-}
{-(Identifier)-})-})-}
{-(Send
{-(Identifier)-})-})-})-}
{-(Function
{-(Empty)-}
{-(Identifier)-}

View File

@ -12,7 +12,8 @@
{+(Identifier)+}
{+(Function
{+(Empty)+}
{+(Identifier)+})+})+}
{+(Send
{+(Identifier)+})+})+})+}
{+(Send
{+(Identifier)+}
{+(Function
@ -30,7 +31,8 @@
{+(Empty)+}
{+(Function
{+(Empty)+}
{+(Identifier)+})+})+}
{+(Send
{+(Identifier)+})+})+})+}
{+(Function
{+(Empty)+}
{+(Identifier)+}

View File

@ -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)

16
test/fixtures/ruby/literals.parseA.txt vendored Normal file
View File

@ -0,0 +1,16 @@
(Program
(Boolean)
(Boolean)
(Null)
(Symbol)
(Integer)
(Identifier)
(Identifier)
(Enumeration
(Integer)
(Integer)
(Empty))
(Enumeration
(Integer)
(Integer)
(Empty)))

View File

@ -2,8 +2,10 @@
(Send
(Identifier)
(KeyValue
(Identifier)
(Send
(Identifier))
(Boolean))
{+(KeyValue
{+(Identifier)+}
{+(Send
{+(Identifier)+})+}
{+(Integer)+})+}))

View File

@ -2,8 +2,10 @@
(Send
(Identifier)
(KeyValue
(Identifier)
(Send
(Identifier))
(Boolean))
{-(KeyValue
{-(Identifier)-}
{-(Send
{-(Identifier)-})-}
{-(Integer)-})-}))

View File

@ -2,5 +2,6 @@
(Send
(Identifier)
(KeyValue
(Identifier)
(Send
(Identifier))
(Boolean))))

View File

@ -2,8 +2,10 @@
(Send
(Identifier)
(KeyValue
(Identifier)
(Send
(Identifier))
(Boolean))
(KeyValue
(Identifier)
(Send
(Identifier))
(Integer))))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -3,5 +3,5 @@
(Empty)
(Identifier)
(Identifier)
{+(Identifier)+}
{+(Empty)+}
([])))

View File

@ -3,5 +3,5 @@
(Empty)
(Identifier)
(Identifier)
{-(Identifier)-}
{-(Empty)-}
([])))

View File

@ -3,5 +3,5 @@
(Empty)
(Identifier)
(Identifier)
(Identifier)
(Empty)
([])))

View File

@ -5,4 +5,5 @@
->(Identifier) }
{+(Identifier)+}
(
{+(Identifier)+})))
{+(Send
{+(Identifier)+})+})))

View File

@ -5,4 +5,5 @@
->(Identifier) }
{-(Identifier)-}
([]
{-(Identifier)-})))
{-(Send
{-(Identifier)-})-})))

View File

@ -4,4 +4,5 @@
(Identifier)
(Identifier)
(
(Identifier))))
(Send
(Identifier)))))

View File

@ -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)+})+})

View File

@ -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)-}

View File

@ -1,6 +1,9 @@
(Program
(Identifier)
(Send
(Identifier)
(Identifier))
(Identifier))
(Send
(Send
(Identifier))
(Identifier))
(Send
(Identifier)))

View File

@ -3,7 +3,8 @@
(Identifier)
(TextElement))
(Send
(Identifier)
(Send
(Identifier))
(Identifier))
(Send
(Identifier)

42
test/fixtures/ruby/methods.parseA.txt vendored Normal file
View File

@ -0,0 +1,42 @@
(Program
(Method
(Empty)
(Identifier)
([]))
(Method
(Empty)
(Identifier)
([]))
(Method
(Empty)
(Identifier)
(Identifier)
([]))
(Method
(Empty)
(Identifier)
(Identifier)
(Identifier)
(Identifier)
(Empty)
([]))
(Method
(Empty)
(Identifier)
(Identifier)
([]))
(Method
(Empty)
(Identifier)
(Identifier)
([]))
(Method
(Identifier)
(Identifier)
([]))
(Method
(Identifier)
(Identifier)
(Identifier)
(Identifier)
([])))

27
test/fixtures/ruby/misc.parseA.txt vendored Normal file
View File

@ -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))

View File

@ -45,10 +45,12 @@
{-(Identifier)-})-})-}
{-(
{-(Send
{-(Identifier)-}
{-(Send
{-(Identifier)-})-}
{-(Identifier)-})-}
{-(Send
{-(Identifier)-}
{-(Send
{-(Identifier)-})-}
{-(Identifier)-})-})-})-}
{-(Assignment
{-(

View File

@ -45,10 +45,12 @@
{+(Identifier)+})+})+}
{+(
{+(Send
{+(Identifier)+}
{+(Send
{+(Identifier)+})+}
{+(Identifier)+})+}
{+(Send
{+(Identifier)+}
{+(Send
{+(Identifier)+})+}
{+(Identifier)+})+})+})+}
{+(Assignment
{+(

View File

@ -44,10 +44,12 @@
(Identifier)))
(
(Send
(Identifier)
(Send
(Identifier))
(Identifier))
(Send
(Identifier)
(Send
(Identifier))
(Identifier))))
(Assignment
(

9
test/fixtures/ruby/next.parseA.txt vendored Normal file
View File

@ -0,0 +1,9 @@
(Program
(ForEach
(
(Send
(Identifier)))
(Send
(Identifier))
(Continue
(Empty))))

View File

@ -1,3 +1,4 @@
(Program
(Array
{+(Identifier)+}))
{+(Send
{+(Identifier)+})+}))

View File

@ -1,3 +1,4 @@
(Program
(Array
{-(Identifier)-}))
{-(Send
{-(Identifier)-})-}))

View File

@ -1,3 +1,4 @@
(Program
(Array
(Identifier)))
(Send
(Identifier))))

View File

@ -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)-})-})-})

Some files were not shown because too many files have changed in this diff Show More