summary refs log tree commit diff
path: root/grammar.ebnf
blob: 35a70795922b7645fa2a7d63a64f4a93c436ede5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Program      ::= Statement+

Statement    ::= (AssignmentStatement | FunctionCallStatement) SEMICOLON

AssignmentStatement ::= "let" IDENTIFIER EQUALS Expression

FunctionCallStatement ::= IDENTIFIER LPAREN FunctionArguments? RPAREN

FunctionArguments ::= Expression ("," Expression)*

Expression   ::= AdditiveExpression | FunctionDefinition

AdditiveExpression ::= PrimaryExpression ("+" AdditiveExpression)

PrimaryExpression ::= NUMBER | IDENTIFIER | FunctionCallStatement

FunctionDefinition ::= LPAREN FunctionParamters? RPAREN ARROW LBRACE Statement* ReturnStatement RBRACE

FunctionParameters ::= IDENTIFIER ("," IDENTIFIER)*

ReturnStatement ::= RETURN Expression SEMICOLON --TODO: I dont like this