A singular object is declared in the following way:
name: obj super
Item1
Item2
...
Itemn
where name
is the name of a constant reference to the object and the object-descriptor super{Item1; Items2; ...; Itemn}
specifies the structure of the object.
The object is generated as part of the generation of the object containing the declaration.
Example
The following example shows the declaration of a singular object with the name Peter
.
Peter: obj Record
name: ref String
age: var Integer
spouse: ref Person
isMarried -> B: var Boolean
B := spouse <> none
Grammar
<ObjectDecl> ::= <ObjectName> ':' obj <ObjectDescriptor>