From 79c0f45847dee608747eca6b8e36e68cb9c881e3 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sat, 18 Jan 2025 23:29:31 +0100 Subject: Feature: Add basic support for if statements --- grammar.ebnf | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'grammar.ebnf') diff --git a/grammar.ebnf b/grammar.ebnf index 35a7079..caf8c73 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -1,21 +1,26 @@ Program ::= Statement+ -Statement ::= (AssignmentStatement | FunctionCallStatement) SEMICOLON +Statement ::= (AssignmentStatement | FunctionCallStatement | IfStatement | ReturnStatement) SEMICOLON AssignmentStatement ::= "let" IDENTIFIER EQUALS Expression FunctionCallStatement ::= IDENTIFIER LPAREN FunctionArguments? RPAREN +IfStatement ::= "if" Expression LBRACE Statement* RBRACE -- TODO: Should function definitions be allowed? + +ReturnStatement ::= RETURN Expression + FunctionArguments ::= Expression ("," Expression)* +--TODO: == + Expression ::= AdditiveExpression | FunctionDefinition AdditiveExpression ::= PrimaryExpression ("+" AdditiveExpression) PrimaryExpression ::= NUMBER | IDENTIFIER | FunctionCallStatement -FunctionDefinition ::= LPAREN FunctionParamters? RPAREN ARROW LBRACE Statement* ReturnStatement RBRACE +FunctionDefinition ::= LPAREN FunctionParamters? RPAREN ARROW LBRACE Statement* ReturnStatement SEMICOLON RBRACE FunctionParameters ::= IDENTIFIER ("," IDENTIFIER)* -ReturnStatement ::= RETURN Expression SEMICOLON --TODO: I dont like this -- cgit 1.4.1