From 74ff39914bdc5c415be52160c63a4aba3dbfa125 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sat, 18 Jan 2025 01:25:19 +0100 Subject: Lang: Start introducing support for function arguments --- grammar.ebnf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'grammar.ebnf') diff --git a/grammar.ebnf b/grammar.ebnf index 65cd74e..406c2d0 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -6,7 +6,9 @@ AssignmentStatement ::= "let" IDENTIFIER EQUALS Expression PrintStatement ::= PRINT LPAREN Expression RPAREN -- TODO: this won't be needed once functions support arguments -FunctionCallStatement ::= IDENTIFIER LPAREN RPAREN +FunctionCallStatement ::= IDENTIFIER LPAREN FunctionArguments? RPAREN + +FunctionArguments ::= Expression ("," Expression)* Expression ::= AdditiveExpression | FunctionDefinition @@ -14,6 +16,8 @@ AdditiveExpression ::= PrimaryExpression ("+" AdditiveExpression) PrimaryExpression ::= NUMBER | IDENTIFIER | FunctionCallStatement -FunctionDefinition ::= ARROW LBRACE Statement* ReturnStatement RBRACE +FunctionDefinition ::= LPAREN FunctionParamters? RPAREN ARROW LBRACE Statement* ReturnStatement RBRACE + +FunctionParameters ::= IDENTIFIER ("," IDENTIFIER)* ReturnStatement ::= RETURN Expression SEMICOLON --TODO: I dont like this -- cgit 1.4.1