A Word on Format

All portions of a statement may be specified as expressions. The examples given in preceding sections show, for the most part, constants in the label field and opcode field. In fact, both of these fields may be specified as complex expressions. Preprocessor statements, however, can be specified only with constant opcodes. An expression cannot be used to generate a preprocessor keyword.

Statements may be assigned more than one label, as illustrated in the following examples.

a:
b:
c: 'macro

a:;b:;c: 'macro

When more than one label is used on a macro call, the 'label variable contains the value of the first label. The built-in list variable 'llist can be used to access the entire list of variables attached to the macro call. Also, the built-in function of the same name can be used to access various portions of the label list.

Macros may be assigned more than one name by placing several labels on the 'macro statement, or by placing additional names in the operand field of the 'macro statement. (If only one name is used, it may appear either in the label field or in the operand field.) When a macro is given more than one name, any of the assigned names may be used as an opcode to invoke the macro. The actual name used can be determined in the macro definition by using the 'opcode variable. If "function call" macros are given more than one name, the 'opcode variable must be used to return the function value. This is because the name of the "return" variable always matches the name used to invoke the function. If one of the macro's other names is used, an "undefined variable" message will be issued. The precise method for doing this is explained below.

The six statements used to define variables may have label fields. If labels are used on these statements, the labels are taken to be the names of additional variables to be defined. Thus the following statement defines six integer variables.

a:
b:
c: 'int d,e,f

When a label of a 'macro statement or one of the six variable-defining statements contains commas, the label is treated as several names. Thus the following statement assigns three names to a macro.

x,y,z: 'macro

And the following statement defines three integer variables.

a,b 'int c

The previous examples also illustrate another syntactic principle of the macro processor. The expression 'x means "the value of x". The expression x means "the variable x". Although it is less confusing to use the form 'x everywhere, it is not syntactically correct to do so. HOWEVER, the macro processor permits the syntactically incorrect form to be used in variable definitions and in assignments. The syntactically correct way to increment the value of the variable 'i is as follows.

'assign i,'i+1

However, the preprocessor accepts the following statement as incrementing the value of 'i.

'assign 'i,'i+1

The syntactically correct meaning of this statement is "obtain the value of i and use the value as the name of the variable to be assigned." Since indirect assignment tends to be quite rare, this is taken to be a miswritten direct assignment. It is actually good practice to use the syntactically incorrect forms, since this will tend to lessen the frequency with which you forget to use the leading ' mark. When it is necessary to do an indirect assignment this can be done by enclosing the name of the variable in parentheses as the following statement illustrates.

'assign ('indvar),'i+1

Anything other than a user defined variable as the first operand of an 'assign statement will cause the syntactically correct rules to be applied. Thus, returning a value from a function-call macro with more than one name can be done using a statement similar to the following.

'assign 'opcode,"return value"

In the examples given above, the error message on the 'error statement was specified as a single string. In fact an arbitrary expression may be used, as illustrated below.

'error s,"input count="#'count('ilist)#" should be 3"

The severity code may also be supplied as a complex expression. Only the first character of the operand is significant. Therefore a severity code of "severe" or "superfluous" is the same as "s".

Comments may be included in macros. There are two types of comment statements. If the opcode "comment" is used (without the leading ' mark) the comments will be included in the generated text. If the opcode 'comment is used, the comments will not appear in the generated text. The first type of comments are used to include informational messages in the generated text. The second type are used to comment the macro itself. In either case the body of the comment may contain any printable character. A semicolon or a newline character marks the end of a comment.

Within a macro the order of variable definition statements is irrelevant. The first use of a variable may precede its definition. Similarly the first use of a macro may precede the definition of the macro. It is necessary, however, for all macro definitions to precede all non-macro text in an input file. The non-macro text in an input file is treated as an unnamed macro, so preprocessor statements may appear in the non-macro text. In particular 'include statements may appear in non-macro text.