-
Notifications
You must be signed in to change notification settings - Fork 0
/
quest2.ebnf
37 lines (32 loc) · 979 Bytes
/
quest2.ebnf
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
35
36
37
program := {<ast-definition> | <expr>} ;
ast-definition := '$syntax' {<ast-pattern>} ':=' {<ast-replacement>} ';' ;
(*ast-pattern
:= '[' <ast-pattern> ']'
| '{' <ast-pattern> '}'
| '(' <ast-pattern> ')' [<single-quote-literal>] ['+' | '*'] (* `+` indicates 1+ *)
| '<' [<ast-binding> ':'] <ident> '>'
| <single-quote-literal>
;
ast-binding := '$' <ident> ;
ast-replacement :=
;*)
program := {expr} ;
expr := primary | assignment | expr BINARY_OP expr ;
assignment
:= ident '=' expr
| primary ('.' | '::') atom '=' expr
| primary '[' fn-args ']' '=' expr
;
fn-args := {['*'] expr ','} [['*'] expr] ;
primary
:= atom
| block
| '[' fn-args ']' (* array *)
| UNARY_OP primary
| primary '(' fn-args ')'
| primary '[' fn-args ']'
| primary ('.' | '::') atom
;
block := [block-args '->'] '{' {expr ';'} [expr] '}' ;
block-args := ident | '(' {ident ','} ident ')' ;
atom := integer | float | string | ident | stackframe-literal | '(' expr ')' ;