mirror of
https://github.com/github/semantic.git
synced 2024-12-27 00:44:57 +03:00
Merge pull request #2112 from github/charliesome/context
Implement evaluation context and self
This commit is contained in:
commit
cefddb7ae3
@ -93,8 +93,8 @@ convergingModules recur m = do
|
||||
c <- getConfiguration (subterm (moduleBody m))
|
||||
-- Convergence here is predicated upon an Eq instance, not α-equivalence
|
||||
cache <- converge lowerBound (\ prevCache -> isolateCache $ do
|
||||
TermEvaluator (putHeap (configurationHeap c))
|
||||
TermEvaluator (putEnv (configurationEnvironment c))
|
||||
TermEvaluator (putHeap (configurationHeap c))
|
||||
TermEvaluator (putEvalContext (configurationContext c))
|
||||
-- We need to reset fresh generation so that this invocation converges.
|
||||
resetFresh 0 $
|
||||
-- This is subtle: though the calling context supports nondeterminism, we want
|
||||
|
@ -2,15 +2,17 @@
|
||||
module Control.Abstract.Environment
|
||||
( Environment
|
||||
, Exports
|
||||
, getEvalContext
|
||||
, putEvalContext
|
||||
, withEvalContext
|
||||
, getEnv
|
||||
, putEnv
|
||||
, withEnv
|
||||
, export
|
||||
, lookupEnv
|
||||
, bind
|
||||
, bindAll
|
||||
, locally
|
||||
, close
|
||||
, self
|
||||
-- * Effects
|
||||
, Env(..)
|
||||
, runEnv
|
||||
@ -21,30 +23,33 @@ module Control.Abstract.Environment
|
||||
) where
|
||||
|
||||
import Control.Abstract.Evaluator
|
||||
import Data.Abstract.Environment (Bindings, Environment)
|
||||
import Data.Abstract.Environment (Bindings, Environment, EvalContext(..))
|
||||
import qualified Data.Abstract.Environment as Env
|
||||
import Data.Abstract.Exports as Exports
|
||||
import Data.Abstract.Name
|
||||
import Prologue
|
||||
|
||||
-- | Retrieve the environment.
|
||||
-- | Retrieve the current execution context
|
||||
getEvalContext :: Member (Env address) effects => Evaluator address value effects (EvalContext address)
|
||||
getEvalContext = send GetCtx
|
||||
|
||||
-- | Retrieve the current environment
|
||||
getEnv :: Member (Env address) effects => Evaluator address value effects (Environment address)
|
||||
getEnv = send GetEnv
|
||||
getEnv = ctxEnvironment <$> getEvalContext
|
||||
|
||||
-- | Replace the environment. This is only for use in Analysis.Abstract.Caching.
|
||||
putEnv :: Member (Env address) effects => Environment address -> Evaluator address value effects ()
|
||||
putEnv = send . PutEnv
|
||||
-- | Replace the execution context. This is only for use in Analysis.Abstract.Caching.
|
||||
putEvalContext :: Member (Env address) effects => EvalContext address -> Evaluator address value effects ()
|
||||
putEvalContext = send . PutCtx
|
||||
|
||||
-- | Replace the environment for a computation
|
||||
withEnv :: Member (Env address) effects
|
||||
=> Environment address
|
||||
-> Evaluator address value effects a
|
||||
-> Evaluator address value effects a
|
||||
withEnv env comp = do
|
||||
oldEnv <- getEnv
|
||||
putEnv env
|
||||
withEvalContext :: Member (Env address) effects
|
||||
=> EvalContext address
|
||||
-> Evaluator address value effects a
|
||||
-> Evaluator address value effects a
|
||||
withEvalContext ctx comp = do
|
||||
oldCtx <- getEvalContext
|
||||
putEvalContext ctx
|
||||
value <- comp
|
||||
putEnv oldEnv
|
||||
putEvalContext oldCtx
|
||||
pure value
|
||||
|
||||
-- | Add an export to the global export state.
|
||||
@ -71,6 +76,8 @@ locally = send . Locally @_ @_ @address . lowerEff
|
||||
close :: Member (Env address) effects => Set Name -> Evaluator address value effects (Environment address)
|
||||
close = send . Close
|
||||
|
||||
self :: Member (Env address) effects => Evaluator address value effects (Maybe address)
|
||||
self = ctxSelf <$> getEvalContext
|
||||
|
||||
-- Effects
|
||||
|
||||
@ -79,8 +86,8 @@ data Env address m return where
|
||||
Bind :: Name -> address -> Env address m ()
|
||||
Close :: Set Name -> Env address m (Environment address)
|
||||
Locally :: m a -> Env address m a
|
||||
GetEnv :: Env address m (Environment address)
|
||||
PutEnv :: Environment address -> Env address m ()
|
||||
GetCtx :: Env address m (EvalContext address)
|
||||
PutCtx :: EvalContext address -> Env address m ()
|
||||
Export :: Name -> Name -> Maybe address -> Env address m ()
|
||||
|
||||
instance PureEffect (Env address)
|
||||
@ -89,17 +96,17 @@ instance Effect (Env address) where
|
||||
handleState c dist (Request (Bind name addr) k) = Request (Bind name addr) (dist . (<$ c) . k)
|
||||
handleState c dist (Request (Close names) k) = Request (Close names) (dist . (<$ c) . k)
|
||||
handleState c dist (Request (Locally action) k) = Request (Locally (dist (action <$ c))) (dist . fmap k)
|
||||
handleState c dist (Request GetEnv k) = Request GetEnv (dist . (<$ c) . k)
|
||||
handleState c dist (Request (PutEnv e) k) = Request (PutEnv e) (dist . (<$ c) . k)
|
||||
handleState c dist (Request GetCtx k) = Request GetCtx (dist . (<$ c) . k)
|
||||
handleState c dist (Request (PutCtx e) k) = Request (PutCtx e) (dist . (<$ c) . k)
|
||||
handleState c dist (Request (Export name alias addr) k) = Request (Export name alias addr) (dist . (<$ c) . k)
|
||||
|
||||
-- | Runs a computation in the context of an existing environment.
|
||||
-- New bindings created in the computation are returned.
|
||||
runEnv :: Effects effects
|
||||
=> Environment address
|
||||
=> EvalContext address
|
||||
-> Evaluator address value (Env address ': effects) a
|
||||
-> Evaluator address value effects (Bindings address, a)
|
||||
runEnv initial = fmap (filterEnv . fmap (first Env.head)) . runState lowerBound . runState (Env.push initial) . reinterpret2 handleEnv
|
||||
runEnv initial = fmap (filterEnv . fmap (first (Env.head . ctxEnvironment))) . runState lowerBound . runState initial . reinterpret2 handleEnv
|
||||
where -- TODO: If the set of exports is empty because no exports have been
|
||||
-- defined, do we export all terms, or no terms? This behavior varies across
|
||||
-- languages. We need better semantics rather than doing it ad-hoc.
|
||||
@ -107,17 +114,17 @@ runEnv initial = fmap (filterEnv . fmap (first Env.head)) . runState lowerBound
|
||||
| Exports.null ports = (binds, a)
|
||||
| otherwise = (Exports.toBindings ports <> Env.aliasBindings (Exports.aliases ports) binds, a)
|
||||
|
||||
handleEnv :: forall address value effects a . Effects effects => Env address (Eff (Env address ': effects)) a -> Evaluator address value (State (Environment address) ': State (Exports address) ': effects) a
|
||||
handleEnv :: forall address value effects a . Effects effects => Env address (Eff (Env address ': effects)) a -> Evaluator address value (State (EvalContext address) ': State (Exports address) ': effects) a
|
||||
handleEnv = \case
|
||||
Lookup name -> Env.lookupEnv' name <$> get
|
||||
Bind name addr -> modify (Env.insertEnv name addr)
|
||||
Close names -> Env.intersect names <$> get
|
||||
Lookup name -> Env.lookupEnv' name . ctxEnvironment <$> get
|
||||
Bind name addr -> modify (\EvalContext{..} -> EvalContext ctxSelf (Env.insertEnv name addr ctxEnvironment))
|
||||
Close names -> Env.intersect names . ctxEnvironment <$> get
|
||||
Locally action -> do
|
||||
modify' (Env.push @address)
|
||||
modify' (\EvalContext{..} -> EvalContext ctxSelf (Env.push @address ctxEnvironment))
|
||||
a <- reinterpret2 handleEnv (raiseEff action)
|
||||
a <$ modify' (Env.pop @address)
|
||||
GetEnv -> get
|
||||
PutEnv e -> put e
|
||||
a <$ modify' (\EvalContext{..} -> EvalContext ctxSelf (Env.pop @address ctxEnvironment))
|
||||
GetCtx -> get
|
||||
PutCtx e -> put e
|
||||
Export name alias addr -> modify (Exports.insert name alias addr)
|
||||
|
||||
-- | Errors involving the environment.
|
||||
|
@ -39,7 +39,7 @@ import Prologue
|
||||
|
||||
-- | Get the current 'Configuration' with a passed-in term.
|
||||
getConfiguration :: (Member (Reader (Live address)) effects, Member (Env address) effects, Member (State (Heap address (Cell address) value)) effects) => term -> TermEvaluator term address value effects (Configuration term address (Cell address) value)
|
||||
getConfiguration term = Configuration term <$> TermEvaluator askRoots <*> TermEvaluator getEnv <*> TermEvaluator getHeap
|
||||
getConfiguration term = Configuration term <$> TermEvaluator askRoots <*> TermEvaluator getEvalContext <*> TermEvaluator getHeap
|
||||
|
||||
|
||||
-- | Retrieve the heap.
|
||||
|
@ -42,16 +42,16 @@ data Comparator
|
||||
function :: Member (Function address value) effects => [Name] -> Set Name -> Evaluator address value effects address -> Evaluator address value effects value
|
||||
function names fvs (Evaluator body) = send (Function names fvs body)
|
||||
|
||||
call :: Member (Function address value) effects => value -> [address] -> Evaluator address value effects address
|
||||
call fn args = send (Call fn args)
|
||||
call :: Member (Function address value) effects => value -> address -> [address] -> Evaluator address value effects address
|
||||
call fn self args = send (Call fn self args)
|
||||
|
||||
data Function address value m result where
|
||||
Function :: [Name] -> Set Name -> m address -> Function address value m value
|
||||
Call :: value -> [address] -> Function address value m address
|
||||
Call :: value -> address -> [address] -> Function address value m address
|
||||
|
||||
instance PureEffect (Function address value) where
|
||||
handle handler (Request (Function name fvs body) k) = Request (Function name fvs (handler body)) (handler . k)
|
||||
handle handler (Request (Call fn addrs) k) = Request (Call fn addrs) (handler . k)
|
||||
handle handler (Request (Call fn self addrs) k) = Request (Call fn self addrs) (handler . k)
|
||||
|
||||
|
||||
class Show value => AbstractIntro value where
|
||||
@ -216,10 +216,10 @@ evaluateInScopedEnv :: ( AbstractValue address value effects
|
||||
=> address
|
||||
-> Evaluator address value effects a
|
||||
-> Evaluator address value effects a
|
||||
evaluateInScopedEnv scopedEnvTerm term = do
|
||||
scopedEnv <- scopedEnvironment scopedEnvTerm
|
||||
evaluateInScopedEnv receiver term = do
|
||||
scopedEnv <- scopedEnvironment receiver
|
||||
env <- maybeM getEnv scopedEnv
|
||||
withEnv env term
|
||||
withEvalContext (EvalContext (Just receiver) env) term
|
||||
|
||||
|
||||
-- | Evaluates a 'Value' returning the referenced value
|
||||
|
@ -6,9 +6,9 @@ import Data.Abstract.Live
|
||||
|
||||
-- | A single point in a program’s execution.
|
||||
data Configuration term address cell value = Configuration
|
||||
{ configurationTerm :: term -- ^ The “instruction,” i.e. the current term to evaluate.
|
||||
, configurationRoots :: Live address -- ^ The set of rooted addresses.
|
||||
, configurationEnvironment :: Environment address -- ^ The environment binding any free variables in 'configurationTerm'.
|
||||
, configurationHeap :: Heap address cell value -- ^ The heap of values.
|
||||
{ configurationTerm :: term -- ^ The “instruction,” i.e. the current term to evaluate.
|
||||
, configurationRoots :: Live address -- ^ The set of rooted addresses.
|
||||
, configurationContext :: EvalContext address -- ^ The evaluation context in 'configurationTerm'.
|
||||
, configurationHeap :: Heap address cell value -- ^ The heap of values.
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Data.Abstract.Environment
|
||||
( Environment(..)
|
||||
, Bindings(..)
|
||||
, EvalContext(..)
|
||||
, addresses
|
||||
, aliasBindings
|
||||
, allNames
|
||||
@ -54,6 +55,12 @@ instance Lower (Bindings address) where
|
||||
newtype Environment address = Environment { unEnvironment :: NonEmpty (Bindings address) }
|
||||
deriving (Eq, Ord)
|
||||
|
||||
data EvalContext address = EvalContext { ctxSelf :: Maybe address, ctxEnvironment :: Environment address }
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
instance Lower (EvalContext address) where
|
||||
lowerBound = EvalContext Nothing lowerBound
|
||||
|
||||
-- | Make and enter a new empty scope in the given environment.
|
||||
push :: Environment address -> Environment address
|
||||
push (Environment (a :| as)) = Environment (mempty :| a : as)
|
||||
|
@ -127,7 +127,7 @@ evaluate lang analyzeModule analyzeTerm runValue modules = do
|
||||
= runReader info
|
||||
. runAllocator
|
||||
. runDeref
|
||||
. runEnv (newEnv preludeBinds)
|
||||
. runEnv (EvalContext Nothing (X.push (newEnv preludeBinds)))
|
||||
. runReturn
|
||||
. runLoopControl
|
||||
|
||||
|
@ -29,7 +29,7 @@ runFunction = interpret $ \case
|
||||
Env.insert name addr <$> rest) (pure lowerBound) params
|
||||
addr <- locally (bindAll env *> catchReturn (runFunction (Evaluator body)))
|
||||
deref addr
|
||||
Call _ params -> do
|
||||
Call _ _ params -> do
|
||||
traverse_ deref params
|
||||
box Abstract
|
||||
|
||||
|
@ -12,7 +12,7 @@ module Data.Abstract.Value.Concrete
|
||||
|
||||
import qualified Control.Abstract as Abstract
|
||||
import Control.Abstract hiding (Function(..))
|
||||
import Data.Abstract.Environment (Environment, Bindings)
|
||||
import Data.Abstract.Environment (Environment, Bindings, EvalContext(..))
|
||||
import qualified Data.Abstract.Environment as Env
|
||||
import Data.Abstract.Name
|
||||
import qualified Data.Abstract.Number as Number
|
||||
@ -79,15 +79,15 @@ runFunction toEvaluator fromEvaluator = interpret $ \case
|
||||
moduleInfo <- currentModule
|
||||
i <- fresh
|
||||
Closure packageInfo moduleInfo params (ClosureBody i (fromEvaluator (Evaluator body))) <$> close (foldr Set.delete fvs params)
|
||||
Abstract.Call op params -> do
|
||||
Abstract.Call op self params -> do
|
||||
case op of
|
||||
Closure packageInfo moduleInfo names (ClosureBody _ body) env -> do
|
||||
-- Evaluate the bindings and body with the closure’s package/module info in scope in order to
|
||||
-- charge them to the closure's origin.
|
||||
withCurrentPackage packageInfo . withCurrentModule moduleInfo $ do
|
||||
bindings <- foldr (\ (name, addr) rest -> Env.insert name addr <$> rest) (pure lowerBound) (zip names params)
|
||||
let fnEnv = Env.push env
|
||||
withEnv fnEnv (catchReturn (bindAll bindings *> runFunction toEvaluator fromEvaluator (toEvaluator body)))
|
||||
let fnCtx = EvalContext (Just self) (Env.push env)
|
||||
withEvalContext fnCtx (catchReturn (bindAll bindings *> runFunction toEvaluator fromEvaluator (toEvaluator body)))
|
||||
_ -> throwValueError (CallError op) >>= box
|
||||
|
||||
|
||||
|
@ -236,7 +236,7 @@ runFunction = interpret $ \case
|
||||
assign addr tvar
|
||||
bimap (Env.insert name addr) (tvar :) <$> rest) (pure (lowerBound, [])) params
|
||||
(zeroOrMoreProduct tvars :->) <$> (locally (catchReturn (bindAll env *> runFunction (Evaluator body))) >>= deref)
|
||||
Abstract.Call op params -> do
|
||||
Abstract.Call op _ params -> do
|
||||
tvar <- fresh
|
||||
paramTypes <- traverse deref params
|
||||
let needed = zeroOrMoreProduct paramTypes :-> Var tvar
|
||||
|
@ -7,7 +7,7 @@ import Data.Abstract.Number (liftIntegralFrac, liftReal, liftedExponent, liftedF
|
||||
import Data.Fixed
|
||||
import Data.JSON.Fields
|
||||
import Diffing.Algorithm
|
||||
import Prologue hiding (index, Member)
|
||||
import Prologue hiding (index, Member, This)
|
||||
import Proto3.Suite.Class
|
||||
|
||||
-- | Typical prefix function application, like `f(x)` in many languages, or `f x` in Haskell.
|
||||
@ -21,8 +21,9 @@ instance Show1 Call where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable Call where
|
||||
eval Call{..} = do
|
||||
op <- subtermValue callFunction
|
||||
recv <- box unit -- TODO
|
||||
args <- traverse subtermAddress callParams
|
||||
Rval <$> call op args
|
||||
Rval <$> call op recv args
|
||||
|
||||
data LessThan a = LessThan { lhs :: a, rhs :: a }
|
||||
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1)
|
||||
@ -496,9 +497,10 @@ instance Show1 Super where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable Super
|
||||
|
||||
data This a = This
|
||||
deriving (Diffable, Eq, Foldable, Functor, Generic1, Ord, Show, Traversable, FreeVariables1, Declarations1, ToJSONFields1, Hashable1)
|
||||
deriving (Diffable, Eq, Foldable, Functor, Generic1, Ord, Show, Traversable, FreeVariables1, Declarations1, ToJSONFields1, Hashable1, Named1, Message1)
|
||||
|
||||
instance Eq1 This where liftEq = genericLiftEq
|
||||
instance Ord1 This where liftCompare = genericLiftCompare
|
||||
instance Show1 This where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable This
|
||||
instance Evaluatable This where
|
||||
eval This = Rval <$> (maybeM (box unit) =<< self)
|
||||
|
@ -81,6 +81,7 @@ type Syntax = '[
|
||||
, Expression.ScopeResolution
|
||||
, Expression.Subscript
|
||||
, Expression.Member
|
||||
, Expression.This
|
||||
, Literal.Array
|
||||
, Literal.Character
|
||||
, Literal.Complex
|
||||
@ -181,6 +182,7 @@ expressionChoices =
|
||||
, parseError
|
||||
, rescue
|
||||
, scopeResolution
|
||||
, self
|
||||
, singletonClass
|
||||
, singletonMethod
|
||||
, subscript
|
||||
@ -220,7 +222,6 @@ identifier =
|
||||
<|> mk ClassVariable
|
||||
<|> mk GlobalVariable
|
||||
<|> mk Operator
|
||||
<|> mk Self
|
||||
<|> mk Super
|
||||
<|> mk Setter
|
||||
<|> mk SplatArgument
|
||||
@ -240,6 +241,9 @@ identifier =
|
||||
then pure identTerm
|
||||
else pure $ makeTerm loc (Ruby.Syntax.Send Nothing (Just identTerm) [] Nothing)
|
||||
|
||||
self :: Assignment Term
|
||||
self = makeTerm <$> symbol Self <*> (Expression.This <$ source)
|
||||
|
||||
-- TODO: Handle interpolation in all literals that support it (strings, regexes, symbols, subshells, etc).
|
||||
literal :: Assignment Term
|
||||
literal =
|
||||
|
@ -55,9 +55,10 @@ instance Evaluatable Send where
|
||||
let sel = case sendSelector of
|
||||
Just sel -> subtermAddress sel
|
||||
Nothing -> variable (name "call")
|
||||
func <- deref =<< maybe sel (flip evaluateInScopedEnv sel <=< subtermAddress) sendReceiver
|
||||
recv <- maybe (self >>= maybeM (box unit)) subtermAddress sendReceiver
|
||||
func <- deref =<< evaluateInScopedEnv recv sel
|
||||
args <- traverse subtermAddress sendArgs
|
||||
Rval <$> call func args -- TODO pass through sendBlock
|
||||
Rval <$> call func recv args -- TODO pass through sendBlock
|
||||
|
||||
data Require a = Require { requireRelative :: Bool, requirePath :: !a }
|
||||
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1)
|
||||
|
@ -92,6 +92,7 @@ type Syntax = '[
|
||||
, Expression.InstanceOf
|
||||
, Expression.New
|
||||
, Expression.Await
|
||||
, Expression.This
|
||||
, Literal.Array
|
||||
, Literal.Boolean
|
||||
, Literal.Float
|
||||
@ -193,7 +194,6 @@ type Syntax = '[
|
||||
, TypeScript.Syntax.Annotation
|
||||
, TypeScript.Syntax.With
|
||||
, TypeScript.Syntax.ForOf
|
||||
, TypeScript.Syntax.This
|
||||
, TypeScript.Syntax.Update
|
||||
, TypeScript.Syntax.ComputedPropertyName
|
||||
, TypeScript.Syntax.Decorator
|
||||
@ -317,7 +317,7 @@ yieldExpression :: Assignment Term
|
||||
yieldExpression = makeTerm <$> symbol Grammar.YieldExpression <*> children (Statement.Yield <$> term (expression <|> emptyTerm))
|
||||
|
||||
this :: Assignment Term
|
||||
this = makeTerm <$> symbol Grammar.This <*> (TypeScript.Syntax.This <$ rawSource)
|
||||
this = makeTerm <$> symbol Grammar.This <*> (Expression.This <$ rawSource)
|
||||
|
||||
regex :: Assignment Term
|
||||
regex = makeTerm <$> symbol Grammar.Regex <*> (Literal.Regex <$> source)
|
||||
|
@ -32,14 +32,6 @@ instance Ord1 Debugger where liftCompare = genericLiftCompare
|
||||
instance Show1 Debugger where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable Debugger
|
||||
|
||||
data This a = This
|
||||
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable)
|
||||
|
||||
instance Eq1 This where liftEq = genericLiftEq
|
||||
instance Ord1 This where liftCompare = genericLiftCompare
|
||||
instance Show1 This where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Evaluatable This
|
||||
|
||||
data Super a = Super
|
||||
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable)
|
||||
|
||||
|
@ -25,8 +25,9 @@ spec = parallel $ do
|
||||
it "calls functions" $ do
|
||||
(_, expected) <- evaluate $ do
|
||||
identity <- function [name "x"] lowerBound (variable (name "x"))
|
||||
recv <- box unit
|
||||
addr <- box (integer 123)
|
||||
call identity [addr]
|
||||
call identity recv [addr]
|
||||
expected `shouldBe` Right (Value.Integer (Number.Integer 123))
|
||||
|
||||
evaluate
|
||||
|
@ -401,6 +401,9 @@ instance Listable1 Expression.Subscript where
|
||||
instance Listable1 Expression.Member where
|
||||
liftTiers tiers = liftCons2 tiers tiers Expression.Member
|
||||
|
||||
instance Listable1 Expression.This where
|
||||
liftTiers tiers = cons0 Expression.This
|
||||
|
||||
instance Listable1 Literal.Complex where
|
||||
liftTiers tiers = cons1 Literal.Complex
|
||||
|
||||
|
12
test/fixtures/ruby/corpus/delimiter.diffA-B.txt
vendored
12
test/fixtures/ruby/corpus/delimiter.diffA-B.txt
vendored
@ -1,13 +1,13 @@
|
||||
(Statements
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{ (TextElement)
|
||||
->(TextElement) }
|
||||
{+(TextElement)+}
|
||||
{ (TextElement)
|
||||
->(TextElement) }
|
||||
{ (TextElement)
|
||||
->(TextElement) }
|
||||
{+(TextElement)+}
|
||||
{-(TextElement)-}
|
||||
{-(TextElement)-}
|
||||
{-(TextElement)-}
|
||||
{ (TextElement)
|
||||
->(TextElement) }
|
||||
{-(TextElement)-}
|
||||
{-(TextElement)-})
|
||||
|
10
test/fixtures/ruby/corpus/delimiter.diffB-A.txt
vendored
10
test/fixtures/ruby/corpus/delimiter.diffB-A.txt
vendored
@ -1,11 +1,11 @@
|
||||
(Statements
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{ (TextElement)
|
||||
->(TextElement) }
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{+(TextElement)+}
|
||||
{-(TextElement)-}
|
||||
{-(TextElement)-}
|
||||
{-(TextElement)-}
|
||||
|
37
test/fixtures/ruby/corpus/for.diffB-A.txt
vendored
37
test/fixtures/ruby/corpus/for.diffB-A.txt
vendored
@ -7,34 +7,33 @@
|
||||
{+(Identifier)+})+}
|
||||
{+(Send
|
||||
{+(Identifier)+})+})+}
|
||||
{+(ForEach
|
||||
{+(Statements
|
||||
{+(Send
|
||||
{+(Identifier)+})+}
|
||||
{+(Send
|
||||
{+(Identifier)+})+})+}
|
||||
{+(Send
|
||||
{+(Identifier)+})+}
|
||||
{+(Send
|
||||
{+(Identifier)+})+})+}
|
||||
(ForEach
|
||||
(Statements
|
||||
(Send
|
||||
{ (Identifier)
|
||||
->(Identifier) }))
|
||||
->(Identifier) })
|
||||
{+(Send
|
||||
{+(Identifier)+})+})
|
||||
{ (Array
|
||||
{-(Integer)-}
|
||||
{-(Integer)-}
|
||||
{-(Integer)-})
|
||||
->(Enumeration
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Empty)+}) }
|
||||
{ (Send
|
||||
{-(Identifier)-}
|
||||
->(Send
|
||||
{+(Identifier)+}) }
|
||||
(Send
|
||||
{ (Identifier)
|
||||
->(Identifier) }
|
||||
{-(Send
|
||||
{-(Identifier)-})-})
|
||||
->(Boolean) })
|
||||
{-(Identifier)-})-}))
|
||||
{+(ForEach
|
||||
{+(Statements
|
||||
{+(Send
|
||||
{+(Identifier)+})+})+}
|
||||
{+(Enumeration
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Empty)+})+}
|
||||
{+(Boolean)+})+}
|
||||
{+(ForEach
|
||||
{+(Statements
|
||||
{+(Send
|
||||
|
11
test/fixtures/ruby/corpus/hash.diffA-B.txt
vendored
11
test/fixtures/ruby/corpus/hash.diffA-B.txt
vendored
@ -5,15 +5,14 @@
|
||||
->(SymbolElement) }
|
||||
{ (TextElement)
|
||||
->(TextElement) })
|
||||
{+(KeyValue
|
||||
{+(SymbolElement)+}
|
||||
{+(Integer)+})+}
|
||||
(KeyValue
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) }
|
||||
{ (Integer)
|
||||
->(Integer) })
|
||||
{+(KeyValue
|
||||
{+(SymbolElement)+}
|
||||
{+(Boolean)+})+}
|
||||
{-(KeyValue
|
||||
{-(SymbolElement)-}
|
||||
{-(Integer)-})-}
|
||||
{-(KeyValue
|
||||
{-(TextElement)-}
|
||||
{-(Boolean)-})-}
|
||||
|
10
test/fixtures/ruby/corpus/hash.diffB-A.txt
vendored
10
test/fixtures/ruby/corpus/hash.diffB-A.txt
vendored
@ -5,14 +5,14 @@
|
||||
->(SymbolElement) }
|
||||
{ (TextElement)
|
||||
->(TextElement) })
|
||||
{+(KeyValue
|
||||
{+(SymbolElement)+}
|
||||
{+(Integer)+})+}
|
||||
(KeyValue
|
||||
{ (SymbolElement)
|
||||
->(TextElement) }
|
||||
->(SymbolElement) }
|
||||
{ (Integer)
|
||||
->(Boolean) })
|
||||
->(Integer) })
|
||||
{+(KeyValue
|
||||
{+(TextElement)+}
|
||||
{+(Boolean)+})+}
|
||||
(KeyValue
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) }
|
||||
|
@ -4,7 +4,7 @@
|
||||
(Null)
|
||||
(SymbolElement)
|
||||
(Integer)
|
||||
(Identifier)
|
||||
(This)
|
||||
(Identifier)
|
||||
(Enumeration
|
||||
(Integer)
|
||||
|
4
test/fixtures/ruby/corpus/methods.parseA.txt
vendored
4
test/fixtures/ruby/corpus/methods.parseA.txt
vendored
@ -31,11 +31,11 @@
|
||||
(Identifier)
|
||||
(Statements))
|
||||
(Method
|
||||
(Identifier)
|
||||
(This)
|
||||
(Identifier)
|
||||
(Statements))
|
||||
(Method
|
||||
(Identifier)
|
||||
(This)
|
||||
(Identifier)
|
||||
(Identifier)
|
||||
(Identifier)
|
||||
|
@ -1,21 +1,14 @@
|
||||
(Statements
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Array
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Integer)+})+})+}
|
||||
{-(Assignment
|
||||
{-(Statements
|
||||
{-(Identifier)-}
|
||||
{-(Identifier)-}
|
||||
{-(Identifier)-})-}
|
||||
{-(Array
|
||||
{-(Integer)-}
|
||||
{-(Integer)-}
|
||||
{-(Integer)-})-})-}
|
||||
(Assignment
|
||||
(Statements
|
||||
(Identifier)
|
||||
{ (Identifier)
|
||||
->(Identifier) }
|
||||
{-(Identifier)-})
|
||||
(Array
|
||||
(Integer)
|
||||
(Integer)
|
||||
(Integer)))
|
||||
{-(Assignment
|
||||
{-(Statements
|
||||
{-(Identifier)-}
|
||||
@ -45,10 +38,10 @@
|
||||
{-(Assignment
|
||||
{-(Statements
|
||||
{-(Send
|
||||
{-(Identifier)-}
|
||||
{-(This)-}
|
||||
{-(Identifier)-})-}
|
||||
{-(Send
|
||||
{-(Identifier)-}
|
||||
{-(This)-}
|
||||
{-(Identifier)-})-})-}
|
||||
{-(Statements
|
||||
{-(Send
|
||||
|
@ -1,31 +1,28 @@
|
||||
(Statements
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Array
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Integer)+})+})+}
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Array
|
||||
{+(Integer)+}
|
||||
{+(Integer)+})+})+}
|
||||
(Assignment
|
||||
(Statements
|
||||
(Identifier)
|
||||
{ (Identifier)
|
||||
->(Identifier) })
|
||||
->(Identifier) }
|
||||
{+(Identifier)+})
|
||||
(Array
|
||||
{ (Integer)
|
||||
->(Integer) }
|
||||
(Integer)
|
||||
(Integer)
|
||||
(Integer)))
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Array
|
||||
{+(Integer)+}
|
||||
{-(Integer)-}
|
||||
{-(Integer)-}))
|
||||
{+(Integer)+})+})+}
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Identifier)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Array
|
||||
{+(Integer)+}
|
||||
{+(Integer)+})+})+}
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Identifier)+}
|
||||
@ -41,10 +38,10 @@
|
||||
{+(Assignment
|
||||
{+(Statements
|
||||
{+(Send
|
||||
{+(Identifier)+}
|
||||
{+(This)+}
|
||||
{+(Identifier)+})+}
|
||||
{+(Send
|
||||
{+(Identifier)+}
|
||||
{+(This)+}
|
||||
{+(Identifier)+})+})+}
|
||||
{+(Statements
|
||||
{+(Send
|
||||
|
@ -37,10 +37,10 @@
|
||||
(Assignment
|
||||
(Statements
|
||||
(Send
|
||||
(Identifier)
|
||||
(This)
|
||||
(Identifier))
|
||||
(Send
|
||||
(Identifier)
|
||||
(This)
|
||||
(Identifier)))
|
||||
(Statements
|
||||
(Send
|
||||
|
2
test/fixtures/ruby/corpus/number.diffB-A.txt
vendored
2
test/fixtures/ruby/corpus/number.diffB-A.txt
vendored
@ -1,11 +1,11 @@
|
||||
(Statements
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{ (Integer)
|
||||
->(Integer) }
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Integer)+}
|
||||
{+(Float)+}
|
||||
{-(Integer)-}
|
||||
{-(Integer)-}
|
||||
|
@ -1,6 +1,6 @@
|
||||
(Statements
|
||||
{-(Null)-}
|
||||
(Identifier)
|
||||
(This)
|
||||
{+(Null)+}
|
||||
{-(Boolean)-}
|
||||
(Boolean)
|
||||
|
@ -1,7 +1,7 @@
|
||||
(Statements
|
||||
{-(Identifier)-}
|
||||
{-(This)-}
|
||||
(Null)
|
||||
{+(Identifier)+}
|
||||
{+(This)+}
|
||||
{-(Boolean)-}
|
||||
(Boolean)
|
||||
{+(Boolean)+})
|
||||
|
@ -1,5 +1,5 @@
|
||||
(Statements
|
||||
(Null)
|
||||
(Identifier)
|
||||
(This)
|
||||
(Boolean)
|
||||
(Boolean))
|
||||
|
@ -1,5 +1,5 @@
|
||||
(Statements
|
||||
(Identifier)
|
||||
(This)
|
||||
(Null)
|
||||
(Boolean)
|
||||
(Boolean))
|
||||
|
@ -1,6 +1,6 @@
|
||||
(Statements
|
||||
(Class
|
||||
(Identifier)
|
||||
(This)
|
||||
(Statements))
|
||||
(Class
|
||||
(ScopeResolution
|
||||
|
8
test/fixtures/ruby/corpus/symbol.diffA-B.txt
vendored
8
test/fixtures/ruby/corpus/symbol.diffA-B.txt
vendored
@ -1,7 +1,7 @@
|
||||
(Statements
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) }
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) }
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) })
|
||||
{+(SymbolElement)+}
|
||||
{+(SymbolElement)+}
|
||||
{-(SymbolElement)-}
|
||||
{-(SymbolElement)-})
|
||||
|
8
test/fixtures/ruby/corpus/symbol.diffB-A.txt
vendored
8
test/fixtures/ruby/corpus/symbol.diffB-A.txt
vendored
@ -1,7 +1,7 @@
|
||||
(Statements
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) }
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) }
|
||||
{ (SymbolElement)
|
||||
->(SymbolElement) })
|
||||
{+(SymbolElement)+}
|
||||
{+(SymbolElement)+}
|
||||
{-(SymbolElement)-}
|
||||
{-(SymbolElement)-})
|
||||
|
@ -13,9 +13,11 @@
|
||||
{+(QualifiedAliasedImport
|
||||
{+(Identifier)+})+})+}
|
||||
{+(SideEffectImport)+}
|
||||
{+(QualifiedAliasedImport{+(Identifier)+})+}
|
||||
{+(QualifiedAliasedImport
|
||||
{+(Identifier)+})+}
|
||||
{-(Import)-}
|
||||
{-(QualifiedAliasedImport{-(Identifier)-})-}
|
||||
{-(QualifiedAliasedImport
|
||||
{-(Identifier)-})-}
|
||||
{-(Import)-}
|
||||
{-(Import)-}
|
||||
{-(Import)-}
|
||||
|
@ -51,21 +51,24 @@
|
||||
(TypeIdentifier))
|
||||
(Identifier)
|
||||
(Float))
|
||||
(PublicFieldDefinition
|
||||
{+(Identifier)+}
|
||||
(Empty)
|
||||
{-(Readonly)-}
|
||||
(Annotation
|
||||
(TypeIdentifier))
|
||||
(Identifier)
|
||||
(Float))
|
||||
{+(PublicFieldDefinition
|
||||
{+(Identifier)+}
|
||||
{+(Readonly)+}
|
||||
{+(Empty)+}
|
||||
{+(Annotation
|
||||
{+(TypeIdentifier)+})+}
|
||||
{+(Identifier)+}
|
||||
{+(TextElement)+})+}
|
||||
{+(Float)+})+}
|
||||
(PublicFieldDefinition
|
||||
{+(Identifier)+}
|
||||
{-(Empty)-}
|
||||
(Readonly)
|
||||
(Annotation
|
||||
{ (TypeIdentifier)
|
||||
->(TypeIdentifier) })
|
||||
{ (Identifier)
|
||||
->(Identifier) }
|
||||
{ (Float)
|
||||
->(TextElement) })
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
|
@ -51,34 +51,40 @@
|
||||
(TypeIdentifier))
|
||||
(Identifier)
|
||||
(Float))
|
||||
(PublicFieldDefinition
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Readonly)+}
|
||||
{+(Annotation
|
||||
{+(TypeIdentifier)+})+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Readonly)+}
|
||||
{+(Annotation
|
||||
{+(TypeIdentifier)+})+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(Annotation
|
||||
{+(TypeIdentifier)+})+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{-(PublicFieldDefinition
|
||||
{-(Identifier)-}
|
||||
(Empty)
|
||||
{+(Readonly)+}
|
||||
(Annotation
|
||||
(TypeIdentifier))
|
||||
(Identifier)
|
||||
(Float))
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Readonly)+}
|
||||
{+(Annotation
|
||||
{+(TypeIdentifier)+})+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(Annotation
|
||||
{+(TypeIdentifier)+})+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{+(PublicFieldDefinition
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(Empty)+}
|
||||
{+(Identifier)+}
|
||||
{+(Float)+})+}
|
||||
{-(Empty)-}
|
||||
{-(Annotation
|
||||
{-(TypeIdentifier)-})-}
|
||||
{-(Identifier)-}
|
||||
{-(Float)-})-}
|
||||
{-(PublicFieldDefinition
|
||||
{-(Identifier)-}
|
||||
{-(Readonly)-}
|
||||
|
Loading…
Reference in New Issue
Block a user