1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Assign **=.

This commit is contained in:
Rob Rix 2017-05-03 11:31:36 -04:00
parent 6e51415cfb
commit f408214d85
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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)