mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Add intrinsics
This commit is contained in:
parent
5352559835
commit
b8e1bac739
@ -66,6 +66,11 @@ type Syntax = '[
|
||||
, Syntax.TypeDeclaration
|
||||
, Syntax.ReturnType
|
||||
, Syntax.UseClause
|
||||
, Syntax.PrintIntrinsic
|
||||
, Syntax.IssetIntrinsic
|
||||
, Syntax.EvalIntrinsic
|
||||
, Syntax.EmptyIntrinsic
|
||||
, Syntax.ExitIntrinsic
|
||||
, Type.Annotation
|
||||
, Declaration.Function
|
||||
, Expression.New
|
||||
@ -148,7 +153,7 @@ primaryExpression = choice [
|
||||
-- qualifiedName,
|
||||
literal,
|
||||
-- arrayCreationExpression,
|
||||
-- intrinsic,
|
||||
intrinsic,
|
||||
anonymousFunctionCreationExpression,
|
||||
objectCreationExpression,
|
||||
updateExpression,
|
||||
@ -156,6 +161,30 @@ primaryExpression = choice [
|
||||
expression
|
||||
]
|
||||
|
||||
intrinsic :: Assignment
|
||||
intrinsic = choice [
|
||||
emptyIntrinsic,
|
||||
evalIntrinsic,
|
||||
exitIntrinsic,
|
||||
issetIntrinsic,
|
||||
printIntrinsic
|
||||
]
|
||||
|
||||
emptyIntrinsic :: Assignment
|
||||
emptyIntrinsic = makeTerm <$> symbol EmptyIntrinsic <*> children (Syntax.EmptyIntrinsic <$> expression)
|
||||
|
||||
evalIntrinsic :: Assignment
|
||||
evalIntrinsic = makeTerm <$> symbol EvalIntrinsic <*> children (Syntax.EvalIntrinsic <$> expression)
|
||||
|
||||
exitIntrinsic :: Assignment
|
||||
exitIntrinsic = makeTerm <$> symbol ExitIntrinsic <*> children (Syntax.ExitIntrinsic <$> expression)
|
||||
|
||||
issetIntrinsic :: Assignment
|
||||
issetIntrinsic = makeTerm <$> symbol IssetIntrinsic <*> children (Syntax.IssetIntrinsic <$> expression)
|
||||
|
||||
printIntrinsic :: Assignment
|
||||
printIntrinsic = makeTerm <$> symbol PrintIntrinsic <*> children (Syntax.PrintIntrinsic <$> expression)
|
||||
|
||||
anonymousFunctionCreationExpression :: Assignment
|
||||
anonymousFunctionCreationExpression = makeTerm <$> symbol AnonymousFunctionCreationExpression <*> children (makeFunction <$> emptyTerm <*> parameters <*> functionUseClause <*> returnType <*> compoundStatement)
|
||||
where makeFunction identifier parameters functionUseClause returnType statement = Declaration.Function [functionUseClause, returnType] identifier parameters statement
|
||||
|
@ -200,3 +200,38 @@ data ScalarType a = ScalarType ByteString
|
||||
instance Eq1 ScalarType where liftEq = genericLiftEq
|
||||
instance Ord1 ScalarType where liftCompare = genericLiftCompare
|
||||
instance Show1 ScalarType where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data EmptyIntrinsic a = EmptyIntrinsic a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 EmptyIntrinsic where liftEq = genericLiftEq
|
||||
instance Ord1 EmptyIntrinsic where liftCompare = genericLiftCompare
|
||||
instance Show1 EmptyIntrinsic where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data ExitIntrinsic a = ExitIntrinsic a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 ExitIntrinsic where liftEq = genericLiftEq
|
||||
instance Ord1 ExitIntrinsic where liftCompare = genericLiftCompare
|
||||
instance Show1 ExitIntrinsic where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data IssetIntrinsic a = IssetIntrinsic a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 IssetIntrinsic where liftEq = genericLiftEq
|
||||
instance Ord1 IssetIntrinsic where liftCompare = genericLiftCompare
|
||||
instance Show1 IssetIntrinsic where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data EvalIntrinsic a = EvalIntrinsic a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 EvalIntrinsic where liftEq = genericLiftEq
|
||||
instance Ord1 EvalIntrinsic where liftCompare = genericLiftCompare
|
||||
instance Show1 EvalIntrinsic where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
data PrintIntrinsic a = PrintIntrinsic a
|
||||
deriving (Diffable, Eq, Foldable, Functor, GAlign, Generic1, Mergeable, Ord, Show, Traversable)
|
||||
|
||||
instance Eq1 PrintIntrinsic where liftEq = genericLiftEq
|
||||
instance Ord1 PrintIntrinsic where liftCompare = genericLiftCompare
|
||||
instance Show1 PrintIntrinsic where liftShowsPrec = genericLiftShowsPrec
|
||||
|
Loading…
Reference in New Issue
Block a user