1
1
mirror of https://github.com/github/semantic.git synced 2025-01-05 05:58:34 +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 = type Syntax =
'[ Comment.Comment '[ Comment.Comment
, Declaration.Class
, Declaration.Comprehension , Declaration.Comprehension
, Declaration.Function , Declaration.Function
, Declaration.Import , Declaration.Import
@ -96,7 +97,7 @@ assignment :: Assignment
assignment = makeTerm <$> symbol Module <*> children (many declaration) assignment = makeTerm <$> symbol Module <*> children (many declaration)
declaration :: Assignment declaration :: Assignment
declaration = handleError $ comment <|> statement <|> expression <|> functionDefinition declaration = handleError $ classDefinition <|> comment <|> functionDefinition <|> expression <|> statement
statement :: Assignment statement :: Assignment
statement = assertStatement statement = assertStatement
@ -173,6 +174,11 @@ functionDefinition = makeTerm <$> symbol FunctionDefinition <*> children f
functionBody <- expressionStatement functionBody <- expressionStatement
return $ Declaration.Function functionType functionName' functionParameters functionBody 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 :: Assignment
typedParameter = makeTerm <$> symbol TypedParameter <*> children (flip Syntax.TypedIdentifier <$> identifier <*> type') typedParameter = makeTerm <$> symbol TypedParameter <*> children (flip Syntax.TypedIdentifier <$> identifier <*> type')