1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Assign class definitions

This commit is contained in:
Rick Winfrey 2017-06-09 15:39:30 -07:00
parent eb4c87313f
commit e379cb64de

View File

@ -28,6 +28,7 @@ import qualified Term
type Syntax =
'[ Comment.Comment
, Declaration.Class
, Declaration.Comprehension
, Declaration.Function
, Declaration.Import
@ -96,7 +97,7 @@ assignment :: Assignment
assignment = makeTerm <$> symbol Module <*> children (many declaration)
declaration :: Assignment
declaration = handleError $ comment <|> statement <|> expression <|> functionDefinition
declaration = handleError $ classDefinition <|> comment <|> functionDefinition <|> expression <|> statement
statement :: Assignment
statement = assertStatement
@ -173,6 +174,11 @@ functionDefinition = makeTerm <$> symbol FunctionDefinition <*> children f
functionBody <- expressionStatement
return $ Declaration.Function functionType functionName' functionParameters functionBody
classDefinition :: Assignment
classDefinition = makeTerm <$> symbol ClassDefinition <*> children (Declaration.Class <$> identifier <*> argumentList <*> (many declaration))
where argumentList = symbol ArgumentList *> children (many expression)
<|> pure []
typedParameter :: Assignment
typedParameter = makeTerm <$> symbol TypedParameter <*> children (flip Syntax.TypedIdentifier <$> identifier <*> type')