From b63e86a9a5d8df2cd210af96d53c2aa08d9097ba Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 7 Jul 2017 10:51:18 -0700 Subject: [PATCH] Alias and undef just as function calls --- src/Data/Syntax/Statement.hs | 16 ---------------- src/Language/Ruby/Syntax.hs | 8 ++++---- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Data/Syntax/Statement.hs b/src/Data/Syntax/Statement.hs index f565d7794..154e7d9ca 100644 --- a/src/Data/Syntax/Statement.hs +++ b/src/Data/Syntax/Statement.hs @@ -154,19 +154,3 @@ newtype ScopeExit a = ScopeExit [a] instance Eq1 ScopeExit where liftEq = genericLiftEq instance Show1 ScopeExit where liftShowsPrec = genericLiftShowsPrec - - --- | Alias statement. -data Alias a = Alias { aliasFrom :: !a, aliasTo :: !a } - deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) - -instance Eq1 Alias where liftEq = genericLiftEq -instance Show1 Alias where liftShowsPrec = genericLiftShowsPrec - - --- | Undef statement. -newtype Undef a = Undef [a] - deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable) - -instance Eq1 Undef where liftEq = genericLiftEq -instance Show1 Undef where liftShowsPrec = genericLiftShowsPrec diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 6f9d0b63c..782822d2a 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -48,7 +48,6 @@ type Syntax = '[ , Literal.String , Literal.Symbol , Literal.TextElement - , Statement.Alias , Statement.Assignment , Statement.Break , Statement.Catch @@ -62,7 +61,6 @@ type Syntax = '[ , Statement.ScopeEntry , Statement.ScopeExit , Statement.Try - , Statement.Undef , Statement.While , Statement.Yield , Syntax.Empty @@ -223,10 +221,12 @@ comment :: Assignment comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source) alias :: Assignment -alias = makeTerm <$> symbol Alias <*> children (Statement.Alias <$> methodName <*> methodName) +alias = makeTerm <$> symbol Alias <*> children (Expression.Call <$> name <*> some methodName) + where name = makeTerm <$> location <*> (Syntax.Identifier <$> source) undef :: Assignment -undef = makeTerm <$> symbol Undef <*> children (Statement.Undef <$> some methodName) +undef = makeTerm <$> symbol Undef <*> children (Expression.Call <$> name <*> some methodName) + where name = makeTerm <$> location <*> (Syntax.Identifier <$> source) if' :: Assignment if' =