diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-18 01:25:19 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-18 01:25:19 +0100 |
commit | 74ff39914bdc5c415be52160c63a4aba3dbfa125 (patch) | |
tree | bec2abb6d7063e6aa5dd5946022a231955be1a8a /grammar.ebnf | |
parent | Examples: new example (diff) | |
download | interpreter-74ff39914bdc5c415be52160c63a4aba3dbfa125.tar.gz interpreter-74ff39914bdc5c415be52160c63a4aba3dbfa125.tar.bz2 interpreter-74ff39914bdc5c415be52160c63a4aba3dbfa125.zip |
Lang: Start introducing support for function arguments
Diffstat (limited to 'grammar.ebnf')
-rw-r--r-- | grammar.ebnf | 8 |
1 files changed, 6 insertions, 2 deletions
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 |