# BNF for AS2JavaParser.jcc

## NON-TERMINALS

agent | ::= | ( directive )* ( belief ( directive )* )* ( initial_goal ( directive )* )* ( plan ( belief )* ( directive )* )* <EOF>
directive | ::= | "{" ( <TK_BEGIN> pred "}" agent | pred "}" )
belief | ::= | literal ( ":-" log_expr )? "."
initial_goal | ::= | "!" literal "."
plan | ::= | ( <TK_LABEL_AT> pred )? trigger ( ":" log_expr )? ( "<-" plan_body )? "."
trigger | ::= | ( "+" | "-" | "^" ) ( ( "!" | "?" ) )? ( literal | var )
plan_body | ::= | ( stmtIF | stmtFOR | stmtWHILE | body_formula ) ( ";" )? ( plan_body )?
stmtIF | ::= | <TK_IF> "(" log_expr ")" plan_term ( ( <TK_ELSE> )? plan_term )?
stmtFOR | ::= | <TK_FOR> "(" log_expr ")" plan_term
stmtWHILE | ::= | <TK_WHILE> "(" log_expr ")" plan_term
body_formula | ::= | ( "!" | "!!" | "?" | "+" | ( "-" ( "+" )? ) )? log_expr
plan_term | ::= | "{" ( ( <TK_LABEL_AT> pred )? trigger ( ":" log_expr )? ( ( "<-" | ";" ) )? )? ( plan_body )? "}"
literal | ::= | ( ( ( <TK_NEG> )? pred ) | <TK_TRUE> | <TK_FALSE> )
pred | ::= | ( <ATOM> | <TK_BEGIN> | <TK_END> ) ( "(" terms ")" )? ( plan_term )* ( list )?
terms | ::= | term ( "," term )*
term | ::= | ( list | plan_term | log_expr )
list | ::= | "[" ( term_in_list ( "," term_in_list )* ( "|" ( <VAR> | <UNNAMEDVAR> | list ) )? )? "]"
term_in_list | ::= | ( list | arithm_expr | string | plan_term )
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 | plan_term ) )?
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 | function )
function | ::= | literal
var | ::= | ( <VAR> | <UNNAMEDVAR> ) ( list )?
string | ::= | <STRING>