From 57496d5877998aec58578ed9238ff08c4bd744af Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 15 Dec 2017 16:21:10 -0800 Subject: [PATCH] Add include, include once expressions --- src/Language/PHP/Assignment.hs | 13 +++++++++++-- src/Language/PHP/Syntax.hs | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Language/PHP/Assignment.hs b/src/Language/PHP/Assignment.hs index d99e58d0e..7bec78f0f 100644 --- a/src/Language/PHP/Assignment.hs +++ b/src/Language/PHP/Assignment.hs @@ -35,6 +35,8 @@ type Syntax = '[ , Declaration.VariableDeclaration , Syntax.Identifier , Syntax.VariableName + , Syntax.IncludeOnce + , Syntax.Include , Syntax.RequireOnce , Syntax.Require , [] ] @@ -83,12 +85,19 @@ expression = choice [ -- yieldExpression, -- unaryExpression, -- binaryExpression, - -- includeExpression, - -- includeOnceExpression, + includeExpression, + includeOnceExpression, requireExpression, requireOnceExpression ] +includeExpression :: Assignment +includeExpression = makeTerm <$> symbol IncludeExpression <*> children (Syntax.Include <$> expression) + + +includeOnceExpression :: Assignment +includeOnceExpression = makeTerm <$> symbol IncludeOnceExpression <*> children (Syntax.IncludeOnce <$> expression) + requireExpression :: Assignment requireExpression = makeTerm <$> symbol RequireExpression <*> children (Syntax.Require <$> expression) diff --git a/src/Language/PHP/Syntax.hs b/src/Language/PHP/Syntax.hs index f9ad4cffc..8f59123c0 100644 --- a/src/Language/PHP/Syntax.hs +++ b/src/Language/PHP/Syntax.hs @@ -35,3 +35,17 @@ newtype Require a = Require a instance Eq1 Require where liftEq = genericLiftEq instance Ord1 Require where liftCompare = genericLiftCompare instance Show1 Require where liftShowsPrec = genericLiftShowsPrec + +newtype Include a = Include a + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) + +instance Eq1 Include where liftEq = genericLiftEq +instance Ord1 Include where liftCompare = genericLiftCompare +instance Show1 Include where liftShowsPrec = genericLiftShowsPrec + +newtype IncludeOnce a = IncludeOnce a + deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable) + +instance Eq1 IncludeOnce where liftEq = genericLiftEq +instance Ord1 IncludeOnce where liftCompare = genericLiftCompare +instance Show1 IncludeOnce where liftShowsPrec = genericLiftShowsPrec