1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Add global declaration and simple variable

This commit is contained in:
joshvera 2017-12-15 16:46:46 -08:00
parent 45d7262423
commit 8728b28761
2 changed files with 25 additions and 2 deletions

View File

@ -40,6 +40,8 @@ type Syntax = '[
, Syntax.RequireOnce
, Syntax.Require
, Statement.Yield
, Syntax.SimpleVariable
, Syntax.GlobalDeclaration
, Syntax.ArrayElement
, [] ]
@ -77,8 +79,8 @@ statement = handleError everything
-- , traitDeclaration
-- , namespaceDefinition
-- , namespaceUseDeclaration
-- , globalDeclaration
functionStaticDeclaration
globalDeclaration
, functionStaticDeclaration
]
expression :: Assignment
@ -93,6 +95,13 @@ expression = choice [
requireOnceExpression
]
globalDeclaration :: Assignment
globalDeclaration = makeTerm <$> symbol GlobalDeclaration <*> children (Syntax.GlobalDeclaration <$> manyTerm simpleVariable)
simpleVariable :: Assignment
simpleVariable = makeTerm <$> symbol SimpleVariable <*> children (Syntax.SimpleVariable <$> (variableName <|> simpleVariable <|> expression))
yieldExpression :: Assignment
yieldExpression = makeTerm <$> symbol YieldExpression <*> children (Statement.Yield <$> (arrayElementInitializer <|> expression))

View File

@ -56,3 +56,17 @@ newtype ArrayElement a = ArrayElement a
instance Eq1 ArrayElement where liftEq = genericLiftEq
instance Ord1 ArrayElement where liftCompare = genericLiftCompare
instance Show1 ArrayElement where liftShowsPrec = genericLiftShowsPrec
newtype GlobalDeclaration a = GlobalDeclaration [a]
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 GlobalDeclaration where liftEq = genericLiftEq
instance Ord1 GlobalDeclaration where liftCompare = genericLiftCompare
instance Show1 GlobalDeclaration where liftShowsPrec = genericLiftShowsPrec
newtype SimpleVariable a = SimpleVariable a
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
instance Eq1 SimpleVariable where liftEq = genericLiftEq
instance Ord1 SimpleVariable where liftCompare = genericLiftCompare
instance Show1 SimpleVariable where liftShowsPrec = genericLiftShowsPrec