diff --git a/src/Language/PHP/Assignment.hs b/src/Language/PHP/Assignment.hs index 23476874a..5d5ee32c3 100644 --- a/src/Language/PHP/Assignment.hs +++ b/src/Language/PHP/Assignment.hs @@ -99,6 +99,8 @@ type Syntax = '[ , Declaration.Method , Syntax.PropertyModifier , Syntax.PropertyDeclaration + , Syntax.InterfaceBaseClause + , Syntax.InterfaceDeclaration , [] ] type Term = Term.Term (Data.Union.Union Syntax) (Record Location) @@ -136,7 +138,7 @@ statement = handleError everything -- , constDeclaration -- , functionDefinition -- , classDeclaration - -- , interfaceDeclaration + , interfaceDeclaration , traitDeclaration , namespaceDefinition , namespaceUseDeclaration @@ -456,6 +458,15 @@ castExpression = makeTerm <$> symbol CastExpression <*> children (flip Expressio castType :: Assignment castType = makeTerm <$> symbol CastType <*> (Syntax.CastType <$> source) +interfaceDeclaration :: Assignment +interfaceDeclaration = makeTerm <$> symbol InterfaceDeclaration <*> children (Syntax.InterfaceDeclaration <$> name <*> (interfaceBaseClause <|> emptyTerm) <*> manyTerm interfaceMemberDeclaration) + +interfaceBaseClause :: Assignment +interfaceBaseClause = makeTerm <$> symbol InterfaceBaseClause <*> children (Syntax.InterfaceBaseClause <$> someTerm qualifiedName) + +interfaceMemberDeclaration :: Assignment +interfaceMemberDeclaration = classConstDeclaration <|> methodDeclaration + traitDeclaration :: Assignment traitDeclaration = makeTerm <$> symbol TraitDeclaration <*> children (Syntax.TraitDeclaration <$> name <*> manyTerm traitMemberDeclaration) diff --git a/src/Language/PHP/Syntax.hs b/src/Language/PHP/Syntax.hs index 52ee9661a..26865bf68 100644 --- a/src/Language/PHP/Syntax.hs +++ b/src/Language/PHP/Syntax.hs @@ -347,3 +347,17 @@ data PropertyModifier a = PropertyModifier a a instance Eq1 PropertyModifier where liftEq = genericLiftEq instance Ord1 PropertyModifier where liftCompare = genericLiftCompare instance Show1 PropertyModifier where liftShowsPrec = genericLiftShowsPrec + +data InterfaceDeclaration a = InterfaceDeclaration a a [a] + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) + +instance Eq1 InterfaceDeclaration where liftEq = genericLiftEq +instance Ord1 InterfaceDeclaration where liftCompare = genericLiftCompare +instance Show1 InterfaceDeclaration where liftShowsPrec = genericLiftShowsPrec + +newtype InterfaceBaseClause a = InterfaceBaseClause [a] + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) + +instance Eq1 InterfaceBaseClause where liftEq = genericLiftEq +instance Ord1 InterfaceBaseClause where liftCompare = genericLiftCompare +instance Show1 InterfaceBaseClause where liftShowsPrec = genericLiftShowsPrec