about summary refs log tree commit diff
path: root/grammar.ebnf
diff options
context:
space:
mode:
authorBaitinq <[email protected]>2025-01-15 00:46:15 +0100
committerBaitinq <[email protected]>2025-01-15 00:46:15 +0100
commit6ac60ae592458c0aa5cc46cf44822f31e3ab58c3 (patch)
treef389b076a0bcf2451f7a88595fc63016b1725e7c /grammar.ebnf
parentParser: clean (diff)
downloadpry-lang-6ac60ae592458c0aa5cc46cf44822f31e3ab58c3.tar.gz
pry-lang-6ac60ae592458c0aa5cc46cf44822f31e3ab58c3.tar.bz2
pry-lang-6ac60ae592458c0aa5cc46cf44822f31e3ab58c3.zip
Add basic support for parsing functions
Diffstat (limited to 'grammar.ebnf')
-rw-r--r--grammar.ebnf20
1 files changed, 14 insertions, 6 deletions
diff --git a/grammar.ebnf b/grammar.ebnf
index 5340ba4..65cd74e 100644
--- a/grammar.ebnf
+++ b/grammar.ebnf
@@ -1,11 +1,19 @@
-Program ::= Statement+
+Program      ::= Statement+
 
-Statement ::= (VariableStatement | PrintStatement | ReturnStatement) SEMICOLON
+Statement    ::= (AssignmentStatement | PrintStatement | FunctionCallStatement) SEMICOLON
 
-VariableStatement ::= ("let" IDENTIFIER | IDENTIFIER) EQUALS Expression
+AssignmentStatement ::= "let" IDENTIFIER EQUALS Expression
 
-PrintStatement :== PRINT LPAREN Expression RPAREN
+PrintStatement ::= PRINT LPAREN Expression RPAREN -- TODO: this won't be needed once functions support arguments
 
-ReturnStatement :== RETURN Expression
+FunctionCallStatement ::= IDENTIFIER LPAREN RPAREN
 
-Expression :== NUMBER | IDENTIFIER | Expression + Expression
+Expression   ::= AdditiveExpression | FunctionDefinition
+
+AdditiveExpression ::= PrimaryExpression ("+" AdditiveExpression)
+
+PrimaryExpression ::= NUMBER | IDENTIFIER | FunctionCallStatement
+
+FunctionDefinition ::= ARROW LBRACE Statement* ReturnStatement RBRACE
+
+ReturnStatement ::= RETURN Expression SEMICOLON --TODO: I dont like this