mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Assign function definitions
This commit is contained in:
parent
f5e91ef793
commit
55816f3127
@ -96,7 +96,7 @@ assignment :: Assignment
|
||||
assignment = makeTerm <$> symbol Module <*> children (many declaration)
|
||||
|
||||
declaration :: Assignment
|
||||
declaration = handleError $ comment <|> statement <|> expression
|
||||
declaration = handleError $ asyncFunctionDefinition <|> comment <|> functionDefinition <|> statement <|> expression
|
||||
|
||||
statement :: Assignment
|
||||
statement = assertStatement
|
||||
@ -127,8 +127,7 @@ expressionStatement :: Assignment
|
||||
expressionStatement = symbol ExpressionStatement *> children expression
|
||||
|
||||
expression :: Assignment
|
||||
expression = asyncFunctionDefinition
|
||||
<|> await
|
||||
expression = await
|
||||
<|> binaryOperator
|
||||
<|> booleanOperator
|
||||
<|> call
|
||||
@ -170,6 +169,14 @@ asyncFunctionDefinition = makeTerm <$> symbol AsyncFunctionDefinition <*> childr
|
||||
functionBody <- expressionStatement
|
||||
return $ Declaration.Function functionType functionName' functionParameters functionBody)
|
||||
|
||||
functionDefinition :: Assignment
|
||||
functionDefinition = makeTerm <$> symbol FunctionDefinition <*> children (do
|
||||
functionName' <- identifier
|
||||
functionParameters <- (symbol Parameters *> children (many expression))
|
||||
functionType <- optional (type')
|
||||
functionBody <- expressionStatement
|
||||
return $ Declaration.Function functionType functionName' functionParameters functionBody)
|
||||
|
||||
typedParameter :: Assignment
|
||||
typedParameter = makeTerm <$> symbol TypedParameter <*> children (flip Syntax.TypedIdentifier <$> identifier <*> type')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user