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

Assign ChannelTypeDeclarations

This commit is contained in:
Rick Winfrey 2017-09-19 12:03:10 -07:00
parent f3895a1a68
commit c0b68de47e

View File

@ -46,6 +46,9 @@ type Syntax =
, Syntax.Program
, Type.Annotation
, Type.Array
, Type.BiDirectionalChannel
, Type.ReceiveChannel
, Type.SendChannel
, []
]
@ -159,9 +162,12 @@ arrayType = handleError $ makeTerm <$> symbol ArrayType <*> children (Type.Array
-- Type Declarations
channelTypeDeclaration :: Assignment
channelTypeDeclaration = mkChannel <$> symbol TypeSpec <*> children ((,) <$> typeLiteral <*> channelType)
channelTypeDeclaration = symbol TypeSpec >>= mkChannelTypeDeclaration
where
mkChannel loc (name, channel) = makeTerm loc $ Type.Annotation channel name
mkChannelTypeDeclaration loc = children (typeIdentifier >>= mkChannelType loc)
mkChannelType loc channelName = symbol ChannelType *> children ( (token AnonChan *> token AnonLAngleMinus *> (makeTerm loc <$> (Type.SendChannel channelName <$> typeIdentifier)))
<|> (token AnonLAngleMinus *> token AnonChan *> (makeTerm loc <$> (Type.ReceiveChannel channelName <$> typeIdentifier)))
<|> (token AnonChan *> (makeTerm loc <$> (Type.BiDirectionalChannel channelName <$> typeIdentifier))))
interfaceTypeDeclaration :: Assignment
interfaceTypeDeclaration = mkInterface <$> symbol TypeSpec <*> children ((,) <$> typeLiteral <*> interfaceType)