• No results found

INTRODUCTION.

In document hal s language specification pdf (Page 155-158)

DECLARE X ARRAY(2,3) SCALAR;

PRECEDENCE RULE:

11.1 INTRODUCTION.

The systems language features of HAL/S are described in this section. The features presented here are in three sections. The new Program Organization features are “Inline Function Blocks” and “%macros”. A data-related feature of this systems language extension is the concept of “TEMPORARY variables”. The NAME facility concerns a new concept in HAL/S, the addition of NAME variables pointing to data or blocks of code. The information contained in this section constitutes an extension of material presented earlier. Accordingly, many of the syntax diagrams presented here are modified versions of earlier diagrams reflecting the extended features. Such modified diagrams are

indicated by appending the small letter “s” to the diagram number. 11.2 PROGRAM ORGANIZATION FEATURES

The addition of Inline Function Blocks and “%macros” to HAL/S extends the information presented in Section 3 concerning program organization. Inline functions are a modified kind of user function in which invocation is simultaneous with block definition. %macros may be viewed as a class of special purpose implementation dependent built-in

functions.

11.2.1 Inline Function Blocks.

The HAL/S Inline Function Block is a method of simultaneously defining and invoking a restricted version of the ordinary user function construct. Its primary purpose is to widen the utility of the parametric REPLACE statement described in Section 4.2. Its

appearance is generally in the form of an operand of an expression.

An Inline Function Block, like other blocks, has a new level of name scoping and error recovery.

17. The title indicates that the usage of these constructs is more suited to systems programming rather than applications programming. The programmer is warned that unrestrained and indiscriminate use of certain of these constructs can lead to software unreliability.

SYNTAX:

Figure 11-1 Inline Function Block - #69 SEMANTIC RULES:

1. The syntactical form is actually equivalent to that of a function block except that:

2. The semantic rules for an <§inline function> block definition are the same as those for the <function block> definition described in Section 3.3, subject to the restrictions listed below.

3. A <§inline function> may not contain the following syntactical forms: • All forms of I/O statements;

• All forms of reference to user-defined PROCEDURE and FUNCTION blocks; • Real Time statements;

4. A <§inline function> may only contain one form of nested block, the <update block>. The following block forms are thus excluded:

• <function block> definitions; • <procedure block> definitions; • Further nested <§inline function>s.

5. In use, the following semantic restriction holds: <§inline function>s may not appear as operands of subscript or exponent expressions.

a The <§inline function> has no label;

b The <§inline function> has no parameters;

c The <§inline function> definition becomes an operand in an expression.

FUNCTION closing declare group type spec statement update block inline function 69 ; arith bit char struct example:

IF X =Y THEN R=FUNCTION VECTOR; DECLARE A, B; A =3X+Y; B=X/Y; RETURN VECTOR(A, B, 0); CLOSE;; T=R*V . . . 17 10 4 11 44 § §

6. The <§inline function> falls into one of the following four categories:

The use of inline functions as operands of HAL/S expressions is discussed in Section 11.2.3.

11.2.2 %macro References.

The HAL/S %macro facility provides a means of adding functional, special-purpose extensions to the language without requiring syntax changes or extensive rewriting of the compiler programs. The details of the implementation of any given %macro will depend upon its nature and purpose. Possible options include inline generation of code or links to an external routine performing the processing of the %macro.

The syntax of %macro reference is presented in this section. The invocation of %macro routines in various expression or statement contexts is described below in Sections 11.2.3 and 11.2.4.

SYNTAX:

Figure 11-2 %Macro Statement - #70 SEMANTIC RULES:

1. The §macro reference falls into one of the five following categories based upon data type:

• <arith %macro> is a reference to a §macro which returns an arithmetic value of INTEGER, SCALAR, VECTOR, or MATRIX data type.

• <bit %macro> is a reference to a §macro which returns a bit string value.

• <char %macro> is a reference to a §macro which returns a value of CHARACTER data type.

• <struct %macro> is a reference to a §macro which returns a structure data value. <arith inline> - <type spec> specifies an inline function of an arithmetic data type:

SCALAR, INTEGER, VECTOR, or MATRIX.

<bit inline> - <type spec> specifies an inline function of a bit type: BOOLEAN or BIT.

<char inline> - <type spec> specifies an inline function of the CHARACTER data type.

<struct inline> - <type spec> specifies an inline function with a structure type specification. %macro <%macro-arg> ( ) 70 , % label § § arith bit char struct typeless

• <typeless %macro> is a reference to a §macro which performs some systems function but returns no value and may only be referenced from a §macro call statement (see Section 11.2.4 below).

Available %macros in any implementation will be provided in the appropriate User’s Manual.

2. The <%label> is a reserved word beginning with the character “%” which identifies the %macro in question. The character “%” distinguishes %macro names from all other reserved words in the HAL/S language.

3. A series of one or more arguments of the %macro reference may be supplied. The type, organization, and number of the arguments supplied to the %macro must be consistent with the requirements of the routine.

4. Details of <%macro arg>s will be supplied with the definition of a given %macro. 11.2.3 Operand Reference Invocations.

Inline Function Blocks are always invoked at the point of their definition as operands of <expression>s. %macros are also invoked as operands of <expression>s when they are of a definite data type and thus return a value. Similar modifications of several syntax diagrams from Section 6 add these features to arithmetic, bit, and character operands, and to structure expressions.

In document hal s language specification pdf (Page 155-158)