summary refs log blame commit diff
path: root/grammar.ebnf
blob: 35a70795922b7645fa2a7d63a64f4a93c436ede5 (plain) (tree)
1
2
3
4
5
6
7
8
9
                           
 
                                                                        
 
                                                          
 


                                                                     
 





                                                                 


                                                                                                      

                                                                        
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