mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
ruby: implement blocks in Send
This commit is contained in:
parent
08b581c02b
commit
4f30c84add
@ -295,9 +295,9 @@ pair = makeTerm <$> symbol Pair <*> children (Literal.KeyValue <$> expression
|
||||
methodCall :: Assignment
|
||||
methodCall = makeTerm' <$> symbol MethodCall <*> children (require <|> load <|> funcCall <|> regularCall)
|
||||
where
|
||||
funcCall = inj <$> (Ruby.Syntax.Send Nothing <$> methodSelector <*> args) -- TODO block
|
||||
funcCall = inj <$> (Ruby.Syntax.Send Nothing <$> methodSelector <*> args <*> (block <|> emptyTerm))
|
||||
|
||||
regularCall = inj <$> (symbol Call *> children (Ruby.Syntax.Send <$> (Just <$> expression) <*> methodSelector) <*> args) -- TODO block
|
||||
regularCall = inj <$> (symbol Call *> children (Ruby.Syntax.Send <$> (Just <$> expression) <*> methodSelector) <*> args <*> (block <|> emptyTerm))
|
||||
|
||||
require = inj <$> (symbol Identifier *> do
|
||||
s <- source
|
||||
@ -317,7 +317,7 @@ methodSelector = mk Identifier <|> mk Identifier'
|
||||
mk s = makeTerm <$> symbol s <*> (Syntax.Identifier <$> (name <$> source))
|
||||
|
||||
call :: Assignment
|
||||
call = makeTerm <$> symbol Call <*> children (Ruby.Syntax.Send <$> (Just <$> expression) <*> methodSelector <*> pure [])
|
||||
call = makeTerm <$> symbol Call <*> children (Ruby.Syntax.Send <$> (Just <$> expression) <*> methodSelector <*> pure [] <*> (block <|> emptyTerm))
|
||||
|
||||
rescue :: Assignment
|
||||
rescue = rescue'
|
||||
|
@ -36,7 +36,7 @@ maybeFailNotFound name = maybeFail notFound
|
||||
cleanNameOrPath :: ByteString -> String
|
||||
cleanNameOrPath = BC.unpack . dropRelativePrefix . stripQuotes
|
||||
|
||||
data Send a = Send { sendReceiver :: Maybe a, sendSelector :: a, sendArgs :: [a] }
|
||||
data Send a = Send { sendReceiver :: Maybe a, sendSelector :: a, sendArgs :: [a], sendBlock :: a }
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1)
|
||||
|
||||
instance Eq1 Send where liftEq = genericLiftEq
|
||||
@ -44,7 +44,7 @@ instance Ord1 Send where liftCompare = genericLiftCompare
|
||||
instance Show1 Send where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
instance Evaluatable Send where
|
||||
eval (Send _ _ _) = fail "send unimplemented!"
|
||||
eval (Send _ _ _ _) = fail "send unimplemented!"
|
||||
|
||||
data Require a = Require { requireRelative :: Bool, requirePath :: !a }
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable, FreeVariables1)
|
||||
|
Loading…
Reference in New Issue
Block a user