This repository has been archived on 2024-03-07. You can view files and clone it, but cannot push or open issues/pull-requests.
wongola/doc/grammar.bnf

39 lines
699 B
BNF

PROG ::= INSTR*
INSTR ::=
| DIR
| EXPR semicolon
| 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
DIR ::= hash ident EXPR (as ident)?
EXPR ::=
| OR
OR ::= AND (or AND)*
AND ::= EQNE (and EQNE)*
EQNE ::= CMP ((eq|ne) CMP)?
CMP ::= ADDSUB ((lt|le|gt|ge) ADDSUB)?
ADDSUB ::= MULDIVMOD ((add|sub) MULDIVMOD)*
MULDIVMOD ::= LITERAL ((mul|div|mod) LITERAL)*
LITERAL ::=
| ident
| int
| CALL
| NS
| not LITERAL
CALL ::= ident opar ARGS cpar
ARGS ::= (EXPR (comma EXPR)*)?
NS ::= ident (dot (ident|CALL))+