BNF for npl.jcc

NON-TERMINALS

program ::= scope <EOF>
scope ::= <SCOPE> literal "{" ( norm "." | rule "." | scope )* "}"
rule ::= literal ( ":-" log_expr )?
norm ::= <NORM> <ATOM> ":" log_expr "->" literal
literal ::= ( <ATOM> | <OS> ) ( "(" terms ")" )?
terms ::= term ( "," term )*
term ::= ( list | log_expr )
list ::= "[" ( term_in_list ( "," term_in_list )* ( "|" ( <VAR> | <UNNAMEDVAR> | list ) )? )? "]"
term_in_list ::= ( list | arithm_expr | string )
log_expr ::= log_expr_trm ( "|" log_expr )?
log_expr_trm ::= log_expr_factor ( "&" log_expr_trm )?
log_expr_factor ::= ( <TK_NOT> log_expr_factor | rel_expr )
rel_expr ::= ( arithm_expr | string ) ( ( "<" | "<=" | ">" | ">=" | "==" | "\\==" | "=" | "=.." ) ( arithm_expr | string | list ) )?
arithm_expr ::= arithm_expr_trm ( ( "+" | "-" ) arithm_expr )?
arithm_expr_trm ::= arithm_expr_factor ( ( "*" | "/" | <TK_INTDIV> | <TK_INTMOD> ) arithm_expr_trm )?
arithm_expr_factor ::= arithm_expr_simple ( ( "**" ) arithm_expr_factor )?
arithm_expr_simple ::= ( <NUMBER> | "-" arithm_expr_simple | "(" log_expr ")" | var | literal | time )
var ::= ( <VAR> | <UNNAMEDVAR> ) ( list )?
string ::= <STRING>
time ::= "`" ( <NUMBER> )? ( <ATOM> )? "`"