• No results found

RULES FOR BIT, BOOLEAN, EVENT, AND CHARACTER TYPES:

In document hal s language specification pdf (Page 60-62)

1. If the <identifier> has no array specification, the <initial list> must contain exactly one value.

2. If the <identifier> has an array specification, then one of the following must hold: • the number of values in the <initial list> is exactly one, in which case all elements of

the array are initialized to that value;

• the number of values in the <initial list> is exactly equal to the number of array elements to be initialized;

• the <initial list> ends with an asterisk, in which case the number of values must be less than the number of array elements to be initialized, and partial initialization is indicated.

3. If an <identifier> of Bit, Boolean, or Event type is being initialized, <expression> must be an unarrayed <bit exp> computable at compile time (see Appendix F). If an Event <identifier> has the LATCHED attribute, then it may be initialized to the value TRUE or FALSE (or their equivalent). If it does not have the LATCHED attribute, then it cannot be initialized (see Section 8.8). In the absence of <initialization> all Events are implicitly initialized to FALSE and all Bit variables are set to zero. If the memory location containing the Bit type is larger than the declared size of the Bit <identifier>, then the bits that do not correspond to an <identifier> will also be initialized to zero. 4. If an <identifier> of CHARACTER type is being initialized, <expression> must be an

unarrayed <char exp> computable at compile time (see Appendix F). RULES FOR STRUCTURE TYPES:

1. Only a major structure <identifier> may be initialized.

2. If the <identifier> has only one copy, then one of the following must hold: • the number of values in the <initial list> is equal to the total number of data

elements in the whole structure;

• the <initial list> ends with an asterisk, in which case the number of values must be less than the number of data elements in the whole structure, and partial

initialization is indicated.

3. If the <identifier> has multiple copies, then one of the following must hold:

• the total number of values in the <initial list> is exactly equal to the total number of data elements in one copy of the structure, in which case each copy is identically initialized;

• the number of values in the <initial list> is equal to the total number of data elements in all copies of the structure;

• the <initial list> ends with an asterisk, in which case the number of values must be less than the total number of data elements in all copies of the structure, and partial initialization is indicated.

The type of each <expression> must be legal for the type of corresponding structure terminal initialized (see the Semantic Rules for initialization of simple variables of each type).

5.0 DATA REFERENCING CONSIDERATIONS

Central to the HAL/S language is the ability to access and change the values of variables. Section 4 dealt comprehensively with the way in which data names are defined. This section addresses itself to the various ways these names can be compounded and modified when they are referenced.

5.1 Referencing Simple Variables.

In Section 4.5 the term “simple variable” was introduced to describe a data name which was not a structure, or part of one. When a simple variable is defined in a <declare group>, it is syntactically denoted by the <identifier> primitive. Thereafter, since its attributes are known, it is denoted syntactically by the <§ var name> primitive, where § stands for any of the types arithmetic, bit, character, or event.

5.2 Referencing Structures

When an <identifier> is declared to be a structure, its tree organization is that of the template whose <template name> appears in the structure declaration (see Section 4.7). References to the structure as a whole (the “major structure”), are obviously made by using the declared <identifier>, which syntactically becomes a <structure var name>. The way in which parts of the structure (its minor structures and terminals) are

referenced depends on whether the structure is “qualified” or “unqualified” (see Section 4.7).

• If a structure is “unqualified”, then any part of it, either minor structure or structure terminal, may be referenced by using the name of the part as it appears in the <structure template>. If a minor structure is referenced, the name becomes syntactically a <structure var name>. If a structure terminal is referenced, then syntactically the name becomes a <§var name>, where § stands for any of the types arithmetic, bit, character, or event, as specified in its <attributes> in the template.

• If the structure is “qualified”, then any part of it, either minor structure or structure terminal, is referenced as follows. First the major structure name is taken. Then starting at the template name, the branches of the template are traversed down to the minor structure or structure terminal to be referenced. On passing through every intervening minor structure, the name is compounded by right catenating a period followed by the name of the minor structure passed through. The process ends with the catenation of the name of the minor structure or structure terminal to be referenced. If a minor structure is being referenced, the resulting “qualified” name becomes syntactically a <structure var name>. If a structure terminal is referenced, then syntactically it becomes a <§var name>, where § stands for any of the types arithmetic, bit, character, or event, as specified in its <attributes> in the template.

Figure 5-1 Referencing Structures 5.3 Subscripting

For the remainder of the section, a data name with known <attributes> is denoted syntactically by <§var name>, where § stands for any of the types arithmetic, bit,

character, event, or structure. It is convenient to introduce the syntactical term <§var> to

denote any subscripted or unsubscripted <§var name>. SYNTAX:

Figure 5-2 Subscripting - #19

It is also useful to introduce the syntactical term <variable> as a collective definition meaning any type of <§var>.

STRUCTURE A:

In document hal s language specification pdf (Page 60-62)