1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Assign function type declarations

This commit is contained in:
Rick Winfrey 2017-09-19 17:44:48 -07:00
parent fa225a8dbb
commit f45a145c5f

View File

@ -47,6 +47,7 @@ type Syntax =
, Type.Annotation , Type.Annotation
, Type.Array , Type.Array
, Type.BiDirectionalChannel , Type.BiDirectionalChannel
, Type.Function
, Type.Interface , Type.Interface
, Type.Map , Type.Map
, Type.Pointer , Type.Pointer
@ -72,6 +73,7 @@ expression = choice
, expressionList , expressionList
, fieldDeclaration , fieldDeclaration
, functionDeclaration , functionDeclaration
, functionType
, identifier , identifier
, importDeclaration , importDeclaration
, importSpec , importSpec
@ -159,6 +161,11 @@ qualifiedType = makeTerm <$> symbol QualifiedType <*> children (Expression.Membe
arrayType :: Assignment arrayType :: Assignment
arrayType = makeTerm <$> symbol ArrayType <*> children (Type.Array . Just <$> intLiteral <*> typeLiteral) arrayType = makeTerm <$> symbol ArrayType <*> children (Type.Array . Just <$> intLiteral <*> typeLiteral)
functionType :: Assignment
functionType = makeTerm <$> symbol FunctionType <*> children (Type.Function <$> parameters <*> returnType)
where parameters = symbol Parameters *> children (many expression)
returnType = symbol Parameters *> children expressions <|> expression <|> emptyTerm
sliceType :: Assignment sliceType :: Assignment
sliceType = makeTerm <$> symbol SliceType <*> children (Type.Slice <$> typeLiteral) sliceType = makeTerm <$> symbol SliceType <*> children (Type.Slice <$> typeLiteral)
@ -191,6 +198,9 @@ fieldDeclaration = mkFieldDeclarationWithTag <$> symbol FieldDeclaration <*> ch
channelTypeDeclaration :: Assignment channelTypeDeclaration :: Assignment
channelTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> channelType) channelTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> channelType)
functionTypeDeclaration :: Assignment
functionTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> functionType)
interfaceTypeDeclaration :: Assignment interfaceTypeDeclaration :: Assignment
interfaceTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> interfaceType) interfaceTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotation <$> typeIdentifier <*> interfaceType)
@ -215,6 +225,7 @@ pointerTypeDeclaration = makeTerm <$> symbol TypeSpec <*> children (Type.Annotat
typeDeclaration :: Assignment typeDeclaration :: Assignment
typeDeclaration = handleError $ makeTerm <$> symbol TypeDeclaration <*> children (many ( arrayTypeDeclaration typeDeclaration = handleError $ makeTerm <$> symbol TypeDeclaration <*> children (many ( arrayTypeDeclaration
<|> channelTypeDeclaration <|> channelTypeDeclaration
<|> functionTypeDeclaration
<|> interfaceTypeDeclaration <|> interfaceTypeDeclaration
<|> qualifiedTypeDeclaration <|> qualifiedTypeDeclaration
<|> pointerTypeDeclaration <|> pointerTypeDeclaration