mirror of
https://github.com/github/semantic.git
synced 2024-12-23 14:54:16 +03:00
Add global declaration and simple variable
This commit is contained in:
parent
45d7262423
commit
8728b28761
@ -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))
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user