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








                                                                        
Program      ::= Statement+

Statement    ::= (AssignmentStatement | PrintStatement | FunctionCallStatement) SEMICOLON

AssignmentStatement ::= "let" IDENTIFIER EQUALS Expression

PrintStatement ::= PRINT LPAREN Expression RPAREN -- TODO: this won't be needed once functions support arguments

FunctionCallStatement ::= IDENTIFIER LPAREN RPAREN

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