diff options
Diffstat (limited to 'grammar.bnf')
| -rw-r--r-- | grammar.bnf | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/grammar.bnf b/grammar.bnf new file mode 100644 index 0000000..256e58a --- /dev/null +++ b/grammar.bnf | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | program ::= (statement ';'?)*; | ||
| 2 | statement ::= definition | expression; | ||
| 3 | definition ::= 'def' def-spec '=' expression; | ||
| 4 | def-spec ::= IDENTIFIER arg-spec*; | ||
| 5 | arg-spec ::= IDENTIFIER; | ||
| 6 | expression ::= binary-expression | unary-expression; | ||
| 7 | unary-expression ::= unop+ simple-expression; | ||
| 8 | binary-expression ::= call-expression (binop call-expression)*; | ||
| 9 | call-expression ::= simple-expression+; | ||
| 10 | binop ::= '*' | '/' | '+' | '-' | '?=' | '/=' | '>' | '>=' | '<' | '<='; | ||
| 11 | unop ::= '+' | '-' | '!'; | ||
| 12 | simple-expression ::= '(' expression ')' | ||
| 13 | | 'true' | 'false' | ||
| 14 | | INTEGER | ||
| 15 | | IDENTIFIER | ||
| 16 | | STRING | ||
| 17 | | array | ||
| 18 | | if-else-expression | ||
| 19 | | let-in-expression | ||
| 20 | | fn-expression | ||
| 21 | | do-expression; | ||
| 22 | |||
| 23 | array ::= '(' ')' | '[' ']' | '[' expression (',' expression)* ','? ']'; | ||
| 24 | |||
| 25 | if-else-expression ::= 'if' expression 'then' expression 'else' expression; | ||
| 26 | let-in-expression ::= 'let' def-spec '=' expression ('and' def-spec '=' expression)* 'in' expression; | ||
| 27 | fn-expression ::= 'fn' arg-spec+ '->' expression | ||
| 28 | | 'fn' arg-spec+ do-expression; | ||
| 29 | do-expression ::= 'do' expression (';' expression)* 'end'; | ||