An object is specified by an object-descriptor:
super
Item1
Item2
...
Itemn
where super
is an optional super pattern – if no super
is specified, then the object is a subpattern of pattern Object
. Pattern Object
is the top superpattern in the pattern- and object hierarchy.
The main-part of an object is a list of Items, Item1
, Item2
, …, Itemn
.
An Item is either a Declaration or a Statement.
There must be exactly one item per line, and all the items must be indented to the same level.
Objects may be nested in which case the indentation level determines the nesting levels – see the section on block-structure.
Example
Record
name: ref String
age: var Integer
spouse: ref Person
isMarried -> B: var Boolean:
B := spouse <> none
The superpattern of this object is Record
. The object has 4 Items: name
, age
, spouse
, and isMarried
.
Alternative syntax
Instead of using indentation and line shifts to define the block levels and separation between statements, it is possible to use curly brackets and semicolon:
super{Item1; Item2; ... Itemsn }
Examples
Record{ name: ref String; age: var Integer }
Record{
name: ref String;
age: var Integer;
spouse: ref Person;
isMarried -> B: var Boolean:{ B := spouse <> none }
}
Grammar
The grammar for an object is as follows. It is defined using curly brackets and semicolon, but as mentioned, indentation and line shifts may be used instead.
<ObjectDescriptor> ::= [ <Super> ] '{' <Items> '}'
<Items> ::= empty | <Item> { ';' <Item> }