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

                                                                     



                                                                                                         
                                                  
 
                                                                                                        
 

                                                                 
                                                                         
 
                                                                           
 
                                                                                                                

                                                   
Program      ::= Statement+

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)*

Expression   ::= EqualityExpression | AdditiveExpression | FunctionDefinition | LPAREN Expression RPAREN

EqualityExpression ::= AdditiveExpression "==" AdditiveExpression

AdditiveExpression ::= PrimaryExpression (("+" | "-") PrimaryExpression)*

PrimaryExpression ::= NUMBER | BOOLEAN | IDENTIFIER | FunctionCallStatement

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

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