1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Update Increment/Decrement constructors; Go assignment

This commit is contained in:
Rick Winfrey 2017-10-10 11:41:29 -07:00
parent 9d18da5e91
commit b2a8973faf
3 changed files with 18 additions and 18 deletions

View File

@ -179,17 +179,3 @@ data Cast a = Cast { castSubject :: !a, castType :: !a }
instance Eq1 Cast where liftEq = genericLiftEq
instance Ord1 Cast where liftCompare = genericLiftCompare
instance Show1 Cast where liftShowsPrec = genericLiftShowsPrec
-- | Increment (e.g. 1++ in C or Go).
newtype Increment a = Increment a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable)
instance Eq1 Increment where liftEq = genericLiftEq
instance Show1 Increment where liftShowsPrec = genericLiftShowsPrec
-- | Decrement (e.g. 1-- in C or Go).
newtype Decrement a = Decrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable)
instance Eq1 Decrement where liftEq = genericLiftEq
instance Show1 Decrement where liftShowsPrec = genericLiftShowsPrec

View File

@ -171,3 +171,17 @@ newtype ScopeExit a = ScopeExit [a]
instance Eq1 ScopeExit where liftEq = genericLiftEq
instance Show1 ScopeExit where liftShowsPrec = genericLiftShowsPrec
-- | Post increment operator (e.g. 1++ in Go, or i++ in C).
newtype PostIncrement a = PostIncrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable)
instance Eq1 PostIncrement where liftEq = genericLiftEq
instance Show1 PostIncrement where liftShowsPrec = genericLiftShowsPrec
-- | Post decrement operator (e.g. 1-- in Go, or i-- in C).
newtype PostDecrement a = PostDecrement a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Show, Traversable)
instance Eq1 PostDecrement where liftEq = genericLiftEq
instance Show1 PostDecrement where liftShowsPrec = genericLiftShowsPrec

View File

@ -37,8 +37,8 @@ type Syntax =
, Expression.Boolean
, Expression.Call
, Expression.Comparison
, Expression.Decrement
, Expression.Increment
, Statement.PostDecrement
, Statement.PostIncrement
, Expression.MemberAccess
, Literal.Array
, Literal.Channel
@ -385,7 +385,7 @@ breakStatement :: Assignment
breakStatement = makeTerm <$> symbol BreakStatement <*> children (Statement.Break <$> labelName)
decStatement :: Assignment
decStatement = makeTerm <$> symbol DecStatement <*> children (Expression.Decrement <$> expression)
decStatement = makeTerm <$> symbol DecStatement <*> children (Statement.PostDecrement <$> expression)
gotoStatement :: Assignment
gotoStatement = makeTerm <$> symbol GotoStatement <*> children (Statement.Goto <$> expression)
@ -393,7 +393,7 @@ gotoStatement = makeTerm <$> symbol GotoStatement <*> children (Statement.Goto <
ifStatement :: Assignment
ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> expression <*> expression <*> (expression <|> emptyTerm))
incStatement :: Assignment
incStatement = makeTerm <$> symbol IncStatement <*> children (Expression.Increment <$> expression)
incStatement = makeTerm <$> symbol IncStatement <*> children (Statement.PostIncrement <$> expression)
labelName :: Assignment
labelName = makeTerm <$> symbol LabelName <*> (Syntax.Identifier <$> source)