2023-09-27 18:18:05 +00:00
|
|
|
PROG ::= INSTR*
|
2023-09-27 21:05:04 +00:00
|
|
|
INSTR ::=
|
|
|
|
| DIR
|
|
|
|
| EXPR semicolon
|
2023-09-28 19:37:10 +00:00
|
|
|
| FUNDECL
|
|
|
|
| return EXPR semicolon
|
|
|
|
| EXTERN semicolon
|
|
|
|
EXTERN ::= extern fun ident opar PARAMS cpar RET
|
|
|
|
FUNDECL ::= fun ident opar PARAMS cpar RET BLOCK
|
|
|
|
PARAMS ::= (ident type? (comma ident type?)*)
|
|
|
|
RET ::= type?
|
|
|
|
BLOCK ::= obrace INSTR* cbrace
|
2023-09-27 21:05:04 +00:00
|
|
|
|
2023-09-29 16:26:05 +00:00
|
|
|
DIR ::= hash ident EXPR (as ident)?
|
2023-09-27 21:05:04 +00:00
|
|
|
|
|
|
|
EXPR ::=
|
2023-09-29 18:11:39 +00:00
|
|
|
| OR
|
2023-09-27 21:05:04 +00:00
|
|
|
|
2023-09-29 18:11:39 +00:00
|
|
|
OR ::= AND (or AND)*
|
|
|
|
AND ::= EQNE (and EQNE)*
|
|
|
|
|
|
|
|
EQNE ::= CMP ((eq|ne) CMP)?
|
|
|
|
CMP ::= ADDSUB ((lt|le|gt|ge) ADDSUB)?
|
2023-09-28 19:37:10 +00:00
|
|
|
|
2023-09-27 21:05:04 +00:00
|
|
|
ADDSUB ::= MULDIVMOD ((add|sub) MULDIVMOD)*
|
|
|
|
MULDIVMOD ::= LITERAL ((mul|div|mod) LITERAL)*
|
|
|
|
|
|
|
|
LITERAL ::=
|
|
|
|
| ident
|
|
|
|
| int
|
2023-09-28 19:37:10 +00:00
|
|
|
| CALL
|
2023-09-29 09:18:03 +00:00
|
|
|
| NS
|
2023-09-29 18:11:39 +00:00
|
|
|
| not LITERAL
|
2023-09-28 19:37:10 +00:00
|
|
|
|
|
|
|
CALL ::= ident opar ARGS cpar
|
|
|
|
ARGS ::= (EXPR (comma EXPR)*)?
|
2023-09-29 09:18:03 +00:00
|
|
|
|
2023-09-29 16:26:05 +00:00
|
|
|
NS ::= ident (dot (ident|CALL))+
|