summary refs log tree commit diff
path: root/grammar.ebnf
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-18 23:29:31 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-18 23:29:31 +0100
commit1da51fff503411454d5665bbc325a8a846862b88 (patch)
tree3c651c35d9de5e2897b9a1225d7965b8d3071feb /grammar.ebnf
parentExamples: add future examples :^) (diff)
downloadinterpreter-1da51fff503411454d5665bbc325a8a846862b88.tar.gz
interpreter-1da51fff503411454d5665bbc325a8a846862b88.tar.bz2
interpreter-1da51fff503411454d5665bbc325a8a846862b88.zip
Feature: Add basic support for if statements
Diffstat (limited to 'grammar.ebnf')
-rw-r--r--grammar.ebnf11
1 files changed, 8 insertions, 3 deletions
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