From f347bf358dbca2443f80cd19249b27293daa90ba Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 5 Feb 2018 16:49:24 -0500 Subject: [PATCH] Add declare directive --- src/Language/PHP/Assignment.hs | 6 ++++-- src/Language/PHP/Syntax.hs | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Language/PHP/Assignment.hs b/src/Language/PHP/Assignment.hs index 8e9a8aad0..60760469c 100644 --- a/src/Language/PHP/Assignment.hs +++ b/src/Language/PHP/Assignment.hs @@ -106,6 +106,7 @@ type Syntax = '[ , Syntax.Echo , Syntax.Unset , Syntax.Declare + , Syntax.DeclareDirective , Statement.Finally , Statement.Catch , Statement.Try @@ -576,11 +577,12 @@ finallyClause :: Assignment finallyClause = makeTerm <$> symbol FinallyClause <*> children (Statement.Finally <$> term compoundStatement) declareStatement :: Assignment -declareStatement = makeTerm <$> symbol DeclareStatement <*> children (Syntax.Declare <$> (term (declareDirective <|> statement <|> (makeTerm <$> location <*> manyTerm statement)) <|> emptyTerm)) +declareStatement = makeTerm <$> symbol DeclareStatement <*> children (Syntax.Declare <$> term declareDirective <*> (makeTerm <$> location <*> manyTerm statement)) + -- | TODO: Figure out how to parse assignment token declareDirective :: Assignment -declareDirective = emptyTerm +declareDirective = makeTerm <$> symbol DeclareDirective <*> children (Syntax.DeclareDirective <$> literal) echoStatement :: Assignment diff --git a/src/Language/PHP/Syntax.hs b/src/Language/PHP/Syntax.hs index 0442563fc..3e3c0a13d 100644 --- a/src/Language/PHP/Syntax.hs +++ b/src/Language/PHP/Syntax.hs @@ -376,13 +376,20 @@ instance Eq1 Unset where liftEq = genericLiftEq instance Ord1 Unset where liftCompare = genericLiftCompare instance Show1 Unset where liftShowsPrec = genericLiftShowsPrec -newtype Declare a = Declare a +data Declare a = Declare a a deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) instance Eq1 Declare where liftEq = genericLiftEq instance Ord1 Declare where liftCompare = genericLiftCompare instance Show1 Declare where liftShowsPrec = genericLiftShowsPrec +data DeclareDirective a = DeclareDirective a + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) + +instance Eq1 DeclareDirective where liftEq = genericLiftEq +instance Ord1 DeclareDirective where liftCompare = genericLiftCompare +instance Show1 DeclareDirective where liftShowsPrec = genericLiftShowsPrec + data LabeledStatement a = LabeledStatement { _labeledStatementIdentifier :: a } deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)