The BigraphER language

A model is a list of declarations followed by a reactive system in a begin ... end block. Declarations define constants of type int, float or string, controls with ctrl, bigraphs with big and reactions with react. A reactive system has a kind (brs, pbrs, sbrs or abrs), an initial bigraph given by init, a list of rules, and optional parameters, actions and predicates.

Lexical conventions

name_char::=a…z ∣ A…Z ∣ 0…9 ∣ _ ∣ '
ident::=a…z name_char*
ctrl_ident::=A…Z name_char*
digit_or_underscore::=0…9 ∣ _
int::=0…9 digit_or_underscore*
float::=inf
 ∣0…9 digit_or_underscore* (. digit_or_underscore* )?
  (e ∣ E (+ ∣ -)? 0…9 digit_or_underscore* )?
string::=" (name_char ∣ -)* "
eof::=end of file

Identifiers must start with the letter shown; control names use an uppercase letter, all other names a lowercase one. Integer and float literals may contain underscore separators. Strings may contain no spaces and have no escape sequences. Whitespace (space, tab, form feed and newline) and # comments (to end of line) may appear between any two tokens.

Syntax

bracketed_exp::=[ exp ]
model::=dec_list rs eof
dec_list::=( dec; )+
dec::=int dec_gen
 ∣float dec_gen
 ∣string dec_gen
 ∣dec_ctrl
 ∣dec_big
 ∣dec_react
dec_gen::=ident = exp
dec_ctrl::=atomic ctrl_exp
 ∣ctrl_exp
ctrl_exp::=ctrl ctrl_ident = int
 ∣fun ctrl ctrl_ident ( ide_list_nonempty ) = int
dec_big::=big ident = bexp
 ∣fun big ident ( ide_list_nonempty ) = bexp
dec_react::=react ident = bexp arrow bexp [ eta_exp ] [ conds ]
 ∣fun react ident ( ide_list_nonempty ) = bexp arrow bexp [ eta_exp ] [ conds ]
arrow::=-->
 ∣-[ exp ]->
conds::=if cond ( , cond )*
cond::=[ ! ] bexp in place
place::=param
 ∣ctx
eta_exp::=@ [ int_list ]
int_list::=[ int ( , int )* ]
end_pos::=end
rs_type::=brs
 ∣pbrs
 ∣sbrs
 ∣abrs
params::=[ ( param; )+ ]
preds::=[ preds = { pred_def ( , pred_def )* } ; ]
pred_def::=ident [ bracketed_exp ]
 ∣ident ( exp_list ) [ bracketed_exp ]
actions::=[ actions = [ action_def ( , action_def )* ] ; ]
action_def::=ident [ [ exp ] ] = { rule_with_loc ( , rule_with_loc )* }
rule_with_loc::=ident
init::=init ident
 ∣init ident ( exp_list )
exp_list::=exp ( , exp )*
exp::=add_exp
add_exp::=mul_exp
 ∣add_exp + mul_exp
 ∣add_exp - mul_exp
unary_exp::=pow_exp
 ∣- unary_exp
pow_exp::=atom_exp
 ∣atom_exp ^ unary_exp
atom_exp::=int
 ∣float
 ∣string
 ∣ident
 ∣abs ( exp )
 ∣( exp )
ide_list_nonempty::=ident ( , ident )*
param_int_exp::=exp
 ∣{ exp_list }
 ∣[ exp : exp : exp ]
param_float_exp::=exp
 ∣{ exp_list }
 ∣[ exp : exp : exp ]
param_str_exp::=exp
 ∣{ exp_list }
priority_class::={ rule_ide ( , rule_ide )* }
 ∣( rule_ide ( , rule_ide )* )
rules::=rules = [ [ priority_class ( , priority_class )* ] ] ;
rule_ide::=ident
 ∣ident ( exp_list )
bexp::=bpar_exp
btens_exp::=bcomp_exp ( + bcomp_exp )*
bcomp_exp::=bprefix_exp ( * bprefix_exp )*
simple_bexp::=( bexp )
 ∣( bexp ) ( bexp )
 ∣id_exp
 ∣merge [ ( int ) ]
 ∣split [ ( int ) ]
 ∣/ ident
 ∣ident / { ide_list_nonempty }
 ∣{ ident }
 ∣int
 ∣( [ [ { int_list } ( , { int_list } )* ] ] , int )
 ∣ident
 ∣ident ( exp_list )
 ∣ion_exp
 ∣ion_exp . simple_bexp
 ∣par ( exp , bexp )
 ∣ppar ( exp , bexp )
id_exp::=id [ ( int ) ]
 ∣id { ide_list_nonempty }
 ∣id ( int , { ide_list_nonempty } )
ion_exp::=ctrl_ident [ { ide_list_nonempty } ]
 ∣ctrl_ident ( ctrl_param_exp_top ( , ctrl_param_exp_top )* ) [ { ide_list_nonempty } ]
ctrl_param_exp_top::=exp
 ∣[ ident ]
 ∣[ ident : constraint_exp ]
 ∣[ constraint_exp ]
 ∣[ [ ctrl_param_exp ] ]
ctrl_param_exp::=ctrl_param_add
ctrl_param_unary::=ctrl_param_atom
 ∣- ctrl_param_unary
ctrl_param_atom::=$
 ∣int
 ∣float
 ∣string
 ∣ident
 ∣abs ( ctrl_param_exp )
 ∣( ctrl_param_exp )
constraint_exp::=constraint_or
constraint_or::=constraint_and ( || constraint_and )*
constraint_and::=constraint_atom ( && constraint_atom )*
constraint_atom::=comparison
 ∣! ( constraint_exp )
 ∣( constraint_exp )
wire_exp::=closure+
 ∣ident / { ide_list_nonempty }
 ∣/ { ide_list_nonempty }
closure::=/ ident

Precedence

Bigraph expressions

Bigraph expressions (bexp) can be combined using these operators. They have the following precedence, from strongest to weakest:

*
+
| and ||

The operators | and || have the same precedence and associate to the left. For example, the expression

A | B + C * D || E

is parsed as

(A | (B + (C * D))) || E

Parentheses can be used to override this convention.

Arithmetic expressions

Arithmetic expressions (exp), as used in actions, parameters, rewards, rates and arguments, combine the following operators. Their precedence, from strongest to weakest, is:

^
- (unary)
* and /
+ and -

The operator ^ associates to the right, so a ^ b ^ c is a ^ (b ^ c). The remaining operators associate to the left. The unary - is weaker than ^, so -a ^ b is -(a ^ b).

Control parameter expressions

Control parameter expressions (ctrl_param_exp), the arguments of a control ion, use the same operators as arithmetic expressions except ^, with the same precedence and associativity.

Constraints

Constraint expressions (constraint_exp), in the square brackets of a control ion's parameters, combine the following operators. Their precedence, from strongest to weakest, is:

=  !=  <  <=  >  >=
!
&&
||

Comparison expressions cannot be chained. The operator ! applies to a parenthesised constraint. The operators && and || associate to the left.