Tuesday, December 2, 2008

General Syntax

Syntactic notation

The syntax of occam programs is described in a modified Backus-Naur Form (BNF). As an example, the following shows the syntax of assignment
assignment = variable := expression

This means “An assignment is a variable followed by the symbol :=, followed by an expression”. A vertical bar (|) means “or”, so for example:

Action= assignment
| input
| output
is the same as
action =assignment
action = input
action =output

The meaning of this syntax is “An action is an assignment, an input, or an output”.

The written structure of occam programs is specified by the syntax. Each statement in an occam program normally occupies a single line, and the indentation of each statement forms an intrinsic part of the syntax of the language. The following example shows the syntax for sequence:
Sequence = SEQ
{process}

The syntax here means “A sequence is the keyword SEQ followed by zero or more processes, each on a separate line, and indented two spaces beyond SEQ”. Curly brackets and are used to indicate the number of times some syntactic object occurs. process means, “zero or more processes, each on a separate line”. Similarly, 0 , expression , means “A list of zero or more expressions, separated by commas”, and 1 , expression , means “A list of one or more expressions, separated by commas”.

A complete summary of the syntax of the language is given at the end of the main body of the manual

No comments:


Find It