The full grammar of the control language
This page is generated from the GROOVE 7.5.3 source code by manual/make-refs.sh; do not edit it by hand.
The grammar of the control language (see the Control language chapter), one nonterminal per section, as also shown in the help panel of the control editor in the Simulator. The first alternative of every nonterminal appears in the heading of its section.
program
| Syntax |
Explanation |
[package] import* ( function | recipe | stat )* |
Main program, consisting of a sequence top-level statements, control function definitions and recipe definitions. Java-like packages and imports are provided for modularity. |
package_decl
| Syntax |
Explanation |
package qual_name |
Causes all rules and procedures to be implicitly qualified by qual_name |
import_decl
| Syntax |
Explanation |
import qual_name |
Declares the last part of qual_name to stand for the entire name |
qual_name
| Syntax |
Explanation |
[qual_name .] name |
Name name in namespace qual_name. ; qual_name - optional namespace; name - sub-name; use backward quotes for reserved words, e.g., any or out |
recipe
| Syntax |
Explanation |
recipe name par_list [priority int] block |
Declares an atomic rule name, with parameters par_list and body block. The optional priority int assigns preference in a group call. ; name - name of the declared recipe; par_list - parameter list for the recipe; int - optional non-negative priority; block - recipe body |
function
| Syntax |
Explanation |
function name par_list block |
Declares the function name, with parameters par_list and body block. ; name - name of the declared function; par_list - parameter list for the function; block - function body |
par_list
| Syntax |
Explanation |
[ par (, par)* ] |
Possibly empty, comma-separated list of parameters |
par
| Syntax |
Explanation |
out var_type id |
Output parameter Variable id will receive a value in the course of the function or recipe. |
var_type id |
Input parameter Variable id is initialised by the argument passed into the call. |
block
| Syntax |
Explanation |
{ stat* } |
Possibly empty sequence of statements, surrounded by curly braces. |
stat
| Syntax |
Explanation |
var_decl ; |
A variable declaration. |
block |
|
alap stat |
The body stat is repeated as long as it remains enabled. Enabledness is determined by the first rule of the statement. |
< stat* > |
Atomically evaluated sequence of statements, surrounded by angle brackets. The transitions in the body are only added to the transition system if they complete successfully |
while ( cond ) stat |
As long as the condition cond is successfully applied, the body stat is repeated. This is equivalent to “alap { cond ; stat }”. |
until ( cond ) stat |
As long as the condition cond fails, the body stat is repeated. Note that if this terminates, the last action is an application of cond. |
do stat while ( cond ) |
Statement stat is executed repeatedly, as long as afterwards the condition cond is enabled. If enabled, cond is also executed. Equivalent to “stat while ( cond ) stat” |
do stat until ( cond ) |
Statement stat is executed repeatedly, as long as afterwards the condition cond is not enabled. Note that if this terminates, the last action is an application of cond. Equivalent to “stat until ( cond ) stat” |
if ( cond ) stat1 [else stat2] |
If condition cond is enabled, it is executed and next stat1 is executed; otherwise, the optional stat2 is executed. |
try stat1 [else stat2] |
Statement stat1 is executed if it is enabled, otherwise the (optional) stat2 is executed. |
choice stat (or stat)+ |
Nondeterministic choice of statements. |
expr ; |
An expression used as a statement. |
halt |
Stops exploration, without marking the state as final |
var_decl
| Syntax |
Explanation |
var_type id (, id)* [ := call ] |
Declares a list of variables, all of the same var_type. Optionally simultaneously initialises the declared variables through an assignment call. |
cond
| Syntax |
Explanation |
cond1 | cond2 |
Nondeterministic choice between cond1 and cond2. |
true |
Condition that always succeeds. |
call |
Tests the enabledness of a given function or rule. Note that the function or rule is in fact executed if enabled. |
expr
| Syntax |
Explanation |
expr1 | expr2 |
Nondeterministic choice between expr1 and expr2. Equivalent to “choice expr1 ; or expr2 ;”, except that this is an expression and choice is a statement. |
expr + |
Nondeterministically executes expr one or more times. Equivalent to “expr ; expr *”. |
expr * |
Nondeterministically executes expr zero or more times. Note that this is not equivalent to “expr #” or “alap expr ;”. |
# expr |
Executes expr as long as possible. Equivalent to “alap expr ;”, except that this is an expression and alap is a statement. |
( expr ) |
Bracketed expression. |
assign |
Invokes a function or rule, assigning the output parameters to target variables |
call |
Invokes a function or rule. |
assign
| Syntax |
Explanation |
id1 (, id2)* := call |
Rule call of call with assignment syntax for output parameters. The argument list of call contains only non-output parameters. The id1/id2-list corresponds to the output parameters of the call. ; id1 - variable serving as output parameter ; id2 - optional further output parameters; call - the call, with only (optionally) non-output arguments |
call
| Syntax |
Explanation |
rule_name [ ( arg_list ) ] |
Invokes a rule, procedure or group rule_name, with optional arguments arg_list. ; rule_name - the rule, procedure or group name; arg_list - optional comma-separated list of arguments |
rule_name
| Syntax |
Explanation |
[ qual_name . ] name |
Explicit rule or procedure (i.e., recipe or function) call of name, optionally qualified with qual_name ; qual_name - optional (qualified) package name; name - rule or procedure name; use backward quotes for reserved words, e.g., any or out |
[ qual_name . ] [ * . ] group |
Invokes all (if group is any) or all not explicitly invoked (if group is other) actions in qual_name (including all subpackages if group is preceded by *) or in the current scope if qual_name and * are absent ; qual_name - optional (qualified) package name; group - any or other |
arg_list
| Syntax |
Explanation |
[ arg (, arg)* ] |
Possibly empty, comma-separated list of arguments |
arg
| Syntax |
Explanation |
out id |
Output argument Variable id will receive a value through the call. |
DONT_CARE |
Don’t-care argument The parameter does not affect the match or the control state. |
true |
Boolean value for truth. |
false |
Boolean value for falsehood. |
"text" |
String constant with value text. |
number |
Integer constant with value number. |
number . number |
Real number constant. |
in_arg
| Syntax |
Explanation |
unary in_arg |
Unary operator expression as input argument Applies unary operator unary to in_arg and passes the result into the call ; unary - unary operator symbol; in_arg - expression to which unary is applied |
in_arg1 binary in_arg2 |
Binary operator expression as input argument Applies binary operator in_arg1 to binary and in_arg2 and passes the result into the call ; in_arg1 - first argument for in_arg1; binary - binary operator symbol; in_arg2 - second argument for in_arg1 |
id |
Variable input argument Variable id must be bound to a value, which will be passed into the call. |
op(in_arg (, in_arg)*) |
Operator invocation as input argument Applies operator op to the comma-separated list of in_arg, and passes the result into the call ; op - operator name; in_arg - first argument for op; in_arg - optional further arguments for op |
( in_arg ) |
Parenthesised input argument |
var_type
| Syntax |
Explanation |
node |
The type of all non-value nodes. |
bool |
The type of boolean values. |
string |
The type of string values. |
int |
The type of integer values. |
real |
The type of real number values. |
user |
User-defined type. |