# Section 8.1.1.7:
$INSTR

###### abstract class $INSTR

#### Formal Definitions

This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.

types
SAME = object_type ;
$INSTR = set of object_type
state
multi : $INSTR
inv multi_types ==
forall obj in set multi_types & sub_type($INSTR,obj)

NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class models the process of conversion from a string of text (see class STR) to an internal Sather value representation. It provides the single feature defined below.

#### build

This feature is required for any sub-type of this abstract class. It provides a mechanism for creating a value of the class from a character string cursor (the string corresponding to which is in the default repertoire and encoding of the execution environment).

build | (
| cursor : STR_CURSOR
| ) : SAME

##### Formal Signature

build(self : SAME, cursor : STR_CURSOR) res : [SAME]

##### Pre-condition

pre not STR_CURSOR.is_done(cursor)

##### Post-condition

If the indicated text string does not have a valid representation of an object of the sub-typing class then nil should be returned and the cursor argument not be altered.

post ((cursor = cursor~)
and (res = nil))
or res <> nil

This returns a new object which has been converted from the given textual representation using the repertoire and encoding of the text string (see class STR) to which the cursor belongs provided that the string is a valid textual representation of the class defining this feature, otherwise the cursor has not been moved and void is returned.

NOTE | The return of void is the Sather equivalent of the vdm-sl value 'nil'. Although the situation giving rise to the nil is defined as corresponding to the inability to carry out the conversion, this is different from the vdm-sl concept of error which is more closely related to the Sather exception concept.

#### build

This second variant of build is required for any sub-type of this abstract class. It provides a mechanism for creating a value of the class from a character string cursor the encoding and repertoire of which corresponds to the lib argument given.

build | (
| cursor : STR_CURSOR,
| lib : LIBCHARS
| ) : SAME

##### Formal Signature

build(self : SAME, cursor : STR_CURSOR, lib : LIBCHARS) res : [SAME]

##### Pre-condition

pre not STR_CURSOR.is_done(cursor)

##### Post-condition

If the indicated text string does not have a valid representation of an object of the sub-typing class then nil should be returned and the cursor argument not be altered.

post ((cursor = cursor~)
and (res = nil))
or res <> nil

This returns a new object which has been converted from the given textual representation using the given repertoire and encoding, provided that the string is a valid textual representation of the class defining this feature, otherwise the cursor has not been moved and void is returned.

NOTE | The return of void is the Sather equivalent of the vdm-sl value 'nil'. Although the situation giving rise to the nil is defined as corresponding to the inability to carry out the conversion, this is different from the vdm-sl concept of error which is more closely related to the Sather exception concept.

| Language Index |  | Library Index |  | Basic Index

Comments or enquiries should be made to Keith Hopper . Page last modified: Tuesday, 23 May 2000. |