ccm/doc/grammar.bnf

28 lines
586 B
BNF

MODULE ::= EXPR*
EXPR ::=
| OR
| ASSERT
ASSERT ::= (assert_eq|assert_ne) tuple
OR ::= AND (or AND)*
AND ::= EQNE (and EQNE)*
EQNE ::= CMP ((eq|ne) CMP)?
CMP ::= TERM ((lt|le|gt|ge) TERM)?
TERM ::= FACTOR ((add|sub) FACTOR)*
FACTOR ::= USUB ((mul|div|mod) USUB)*
USUB ::= sub* NOT
NOT ::= not* POW
POW ::= IN (pow IN)?
IN ::= LITERAL (in LITERAL)?
LITERAL ::=
| BUILTIN
| TUPLE
| INDEX
| ARRAY
| opar EXPR cpar
ARRAY ::= osquare (EXPR (comma EXPR)*)? csquare
INDEX ::=
| (TUPLE|str|ARRAY) osquare (EXPR (comma EXPR)*)? csquare
TUPLE ::=
| opar EXPR+ cpar
BUILTIN ::= num | bool | str