mirror of
https://github.com/github/semantic.git
synced 2024-12-26 08:25:19 +03:00
Add ZSuper syntax node (#2292)
Previously, invocations of `super` were captured as an `Identifier`. It is straightforward enough to return a ZSuper instead.
This commit is contained in:
parent
844664f636
commit
0d361e9b0b
@ -126,6 +126,7 @@ type Syntax = '[
|
|||||||
, Ruby.Syntax.Module
|
, Ruby.Syntax.Module
|
||||||
, Ruby.Syntax.Require
|
, Ruby.Syntax.Require
|
||||||
, Ruby.Syntax.Send
|
, Ruby.Syntax.Send
|
||||||
|
, Ruby.Syntax.ZSuper
|
||||||
, []
|
, []
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -214,12 +215,12 @@ withNewScope inner = withExtendedScope $ do
|
|||||||
identifier :: Assignment Term
|
identifier :: Assignment Term
|
||||||
identifier =
|
identifier =
|
||||||
vcallOrLocal
|
vcallOrLocal
|
||||||
|
<|> zsuper
|
||||||
<|> mk Constant
|
<|> mk Constant
|
||||||
<|> mk InstanceVariable
|
<|> mk InstanceVariable
|
||||||
<|> mk ClassVariable
|
<|> mk ClassVariable
|
||||||
<|> mk GlobalVariable
|
<|> mk GlobalVariable
|
||||||
<|> mk Operator
|
<|> mk Operator
|
||||||
<|> mk Super
|
|
||||||
<|> mk Setter
|
<|> mk Setter
|
||||||
<|> mk SplatArgument
|
<|> mk SplatArgument
|
||||||
<|> mk HashSplatArgument
|
<|> mk HashSplatArgument
|
||||||
@ -227,6 +228,7 @@ identifier =
|
|||||||
<|> mk Uninterpreted
|
<|> mk Uninterpreted
|
||||||
where
|
where
|
||||||
mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source)
|
mk s = makeTerm <$> symbol s <*> (Syntax.Identifier . name <$> source)
|
||||||
|
zsuper = makeTerm <$> symbol Super <*> (Ruby.Syntax.ZSuper <$ source)
|
||||||
vcallOrLocal = do
|
vcallOrLocal = do
|
||||||
(loc, ident, locals) <- identWithLocals
|
(loc, ident, locals) <- identWithLocals
|
||||||
case ident of
|
case ident of
|
||||||
|
@ -245,3 +245,18 @@ instance Show1 LowPrecedenceOr where liftShowsPrec = genericLiftShowsPrec
|
|||||||
|
|
||||||
instance Tokenize LowPrecedenceOr where
|
instance Tokenize LowPrecedenceOr where
|
||||||
tokenize LowPrecedenceOr{..} = lhs *> yield (Token.Run "or") <* rhs
|
tokenize LowPrecedenceOr{..} = lhs *> yield (Token.Run "or") <* rhs
|
||||||
|
|
||||||
|
-- | A call to @super@ without parentheses in Ruby is known as "zsuper", which has
|
||||||
|
-- the semantics of invoking @super()@ but implicitly passing the current function's
|
||||||
|
-- arguments to the @super()@ invocation.
|
||||||
|
data ZSuper a = ZSuper
|
||||||
|
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Ord, Show, ToJSONFields1, Traversable, Named1, Message1, NFData1)
|
||||||
|
|
||||||
|
instance Evaluatable ZSuper
|
||||||
|
|
||||||
|
instance Eq1 ZSuper where liftEq = genericLiftEq
|
||||||
|
instance Ord1 ZSuper where liftCompare = genericLiftCompare
|
||||||
|
instance Show1 ZSuper where liftShowsPrec = genericLiftShowsPrec
|
||||||
|
|
||||||
|
instance Tokenize ZSuper where
|
||||||
|
tokenize _ = yield $ Run "super"
|
||||||
|
@ -609,6 +609,7 @@ instance Taggable Ruby.Require
|
|||||||
instance Taggable Ruby.Load
|
instance Taggable Ruby.Load
|
||||||
instance Taggable Ruby.LowPrecedenceAnd
|
instance Taggable Ruby.LowPrecedenceAnd
|
||||||
instance Taggable Ruby.LowPrecedenceOr
|
instance Taggable Ruby.LowPrecedenceOr
|
||||||
|
instance Taggable Ruby.ZSuper
|
||||||
|
|
||||||
instance Taggable TypeScript.JavaScriptRequire
|
instance Taggable TypeScript.JavaScriptRequire
|
||||||
instance Taggable TypeScript.Debugger
|
instance Taggable TypeScript.Debugger
|
||||||
|
@ -474,6 +474,9 @@ instance Listable1 Ruby.Syntax.Module where
|
|||||||
instance Listable1 Ruby.Syntax.Require where
|
instance Listable1 Ruby.Syntax.Require where
|
||||||
liftTiers tiers' = liftCons2 tiers tiers' Ruby.Syntax.Require
|
liftTiers tiers' = liftCons2 tiers tiers' Ruby.Syntax.Require
|
||||||
|
|
||||||
|
instance Listable1 Ruby.Syntax.ZSuper where
|
||||||
|
liftTiers tiers = cons0 Ruby.Syntax.ZSuper
|
||||||
|
|
||||||
instance Listable1 Ruby.Syntax.Send where
|
instance Listable1 Ruby.Syntax.Send where
|
||||||
liftTiers tiers = liftCons4 (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) Ruby.Syntax.Send
|
liftTiers tiers = liftCons4 (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) (liftTiers tiers) Ruby.Syntax.Send
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
(SymbolElement)
|
(SymbolElement)
|
||||||
(Integer)
|
(Integer)
|
||||||
(This)
|
(This)
|
||||||
(Identifier)
|
(ZSuper)
|
||||||
(Enumeration
|
(Enumeration
|
||||||
(Integer)
|
(Integer)
|
||||||
(Integer)
|
(Integer)
|
||||||
|
Loading…
Reference in New Issue
Block a user