about summary refs log tree commit diff
path: root/grammar.ebnf
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-01-18 01:25:19 +0100
committerBaitinq <[email protected]>2025-01-18 01:25:19 +0100
commit4f6eda71d3a5464c3402811452ddde64cb111800 (patch)
treebec2abb6d7063e6aa5dd5946022a231955be1a8a /grammar.ebnf
parentExamples: new example (diff)
downloadpry-lang-4f6eda71d3a5464c3402811452ddde64cb111800.tar.gz
pry-lang-4f6eda71d3a5464c3402811452ddde64cb111800.tar.bz2
pry-lang-4f6eda71d3a5464c3402811452ddde64cb111800.zip
Lang: Start introducing support for function arguments
Diffstat (limited to 'grammar.ebnf')
-rw-r--r--grammar.ebnf8
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