diff --git a/src/Data/Syntax/Expression.hs b/src/Data/Syntax/Expression.hs index bf25eb971..1649c2265 100644 --- a/src/Data/Syntax/Expression.hs +++ b/src/Data/Syntax/Expression.hs @@ -41,3 +41,10 @@ data Times a = Times a a instance Eq1 Times where liftEq = genericLiftEq instance Show1 Times where liftShowsPrec = genericLiftShowsPrec + +-- | Binary exponentiation. +data Power a = Power a a + deriving (Eq, Foldable, Functor, Generic1, Show, Traversable) + +instance Eq1 Power where liftEq = genericLiftEq +instance Show1 Power where liftShowsPrec = genericLiftShowsPrec diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 71cdd018c..89f0e6beb 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -27,6 +27,7 @@ type Syntax' = , Expression.Not , Expression.Plus , Expression.Times + , Expression.Power , Literal.Array , Literal.Boolean , Literal.Hash @@ -87,9 +88,10 @@ statement = exit Statement.Return Return <|> for <|> literal <|> symbol OperatorAssignment *> term <*> children (lvalue >>= \ var -> Statement.Assignment var <$> - (symbol AnonPlusEqual *> term <*> (Expression.Plus var <$> expression) - <|> symbol AnonMinusEqual *> term <*> (Expression.Minus var <$> expression) - <|> symbol AnonStarEqual *> term <*> (Expression.Times var <$> expression))) + (symbol AnonPlusEqual *> term <*> (Expression.Plus var <$> expression) + <|> symbol AnonMinusEqual *> term <*> (Expression.Minus var <$> expression) + <|> symbol AnonStarEqual *> term <*> (Expression.Times var <$> expression) + <|> symbol AnonStarStarEqual *> term <*> (Expression.Power var <$> expression))) where exit construct sym = symbol sym *> term <*> children (construct <$> optional (symbol ArgumentList *> children statement)) lvalue :: Assignment (Node Grammar) (Term Syntax Location)