-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
34 lines (23 loc) · 1000 Bytes
/
grammar.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
expr : KEYWORD:var IDENTIFIER EQ expr
: comp-expr ((KEYWORD:and|KEYWORD:or) comp-expr)*
comp-expr : NOT comp-expr
: arith-expr ((EE|LT|GT|LTE|GTE) arith-expr)*
arith-expr : term ((PLUS|MINUS) term)*
term : factor ((MUL|DIV) factor)*
factor : (PLUS|MINUS) factor
: power
power : call (POW factor)*
call : atom (LPAREN (expr (COMMA expr)*)? RPAREN)?
atom : INT|FLOAT|STRING|IDENTIFIER
: LPAREN expr RPAREN
: if-expr
: func-def
if-expr : KEYWORD:if expr KEYWORD:then expr
(KEYWORD:elif expr KEYWORD:then expr)*
(KEYWORD:else expr)?
for-expr : KEYWORD:for IDENTIFIER EQ expr KEYWORD:to expr
(KEYWORD:step expr)? KEYWORD:then expr
while-expr : KEYWORD:while expr KEYWORD:then expr
func-def : KEYWORD:func IDENTIFIER?
LPAREN (IDENTIFIER (COMMA IDENTIFIER)*)? RPAREN
ARROW expr