[an error occurred while processing this directive]

Implementing ADM - Mike Slade's Version

Program Specification

An ADM program is specified by a set of entity descriptions, each of which consists of a header and a body. The entity descriptions describe the sets of variables and actions which can be instantiated.

entity description
An entity description is of the form
entity name (parameter_list)
{ body }
The name of the entity is an alphanumeric identifier, and must start with a letter. The parameter list is a possibly empty list of comma-separated parameter names, where each parameter name starts with an underscore ("_"), e.g. (_bank, _number). A set of entity descriptions gives a program specification. Any occurrence of "//" is the start of a comment, which is terminated by a newline.
entity body
An entity body is of the form
definition variable_list
action action_list
where variable_list is a list of variables, each of which can be optionally initialised with a definition (e.g. a = b * c * d). The action_list is a comma-separated list of actions.
action
An action is of the form
guard procedural_action -> command
where a guard is an arithmetic or boolean expression involving constants and other variables. It is false or zero, and true otherwise. A procedural_action is of the form
print (message)
where message is a comma-separated list of quoted strings (e.g. "Number: "), parameters and parametric variables. The value of supplied paramteres or variables is printed. A command is a semicolon-separated list of dynamic actions and definitions, or the keyword stop, which halts execution.
dynamic action
A dynamic action involves the instantiation or deletion of an entity. An entity instantiation is of the form
name (parameter_list)
where name is the name of the entity to be instantiated, and parameter_list is the comma-separated list of parameters. Each parameter can be an arithmetic or boolean expression involving either parameters of the entity or constants, but not variables. An entity deletion is of the same form, but prefixed with the keyword delete. Parameters are used in a call-by-value manner, so a parameter cannot be redefined.
definition
A definition is of the form
variable = expression
where expression is a boolean or integer arithmetic expression. The boolean operators available are <, <=, ==, >=, >, !=, && and ||, and the arithmetic operators available are the four standard operators (+, -, *, /), unary minus (-), the rand() function where rand(n) returns a value between 1 and n, and the arithmetic if...then...else... construct. Expressions can also contain constants (true, false, @ and integers), the evaluation operator (e.g. |date|), and other variables.
variable
A variable is an identifier and possibly an associated parameter list. An identifier is an alphanumeric string which starts with a letter. The associated parameter list may be empty, or may consist of a list of parameters enclosed in square brackets. Parameters are identifiers prefixed by an underscore (_). Examples of variables include valid, book[_number] and cheque[_date,_signed].

[an error occurred while processing this directive]