The Command Execution

The execution of commands is done in three steps:
 Analysis:
The command line is parsed into verb, parameters and qualifiers.
 Interpretation:
The verb is used to find the routine that actually does the job.
 Execution:
The routines which execute the commands get their control information by evaluating parameters and qualifiers.
Steps 1 and 2 are done by the same functions for all commands. The implementation of a new feature requires no changes in step 1, adding just one item to the branch table for step 2 and the coding of a new routine.

When the interpreter is called, it tries to translate the whole input line as one symbol. Then it checks whether the command string contains any separators which are not enclosed in double quotation marks. If so, the interpreter cuts the command string into pieces that contain one command only and calls itself, passing the substrings as arguments.

The command line is cut into tokens, which SPECTRA tries to translate as symbols. There is no translation for the first token of a symbol assignment. This takes care of the following situation: pi = 4$*$atan(1) followed by the command pi = that deletes the symbol. If the first token of the last command were translated, pi would be replaced by 3.14..., resulting in the command 3.14... = -- nonsense. For the same reason, no symbol translations are done for inquire and help commands.

A token is a string of characters, terminated by one of the following delimiter: blank space, tabulator, "$/$" and "=". In case of calc commands there are additional delimiter: *, +, -, (, ), >, <, ,.

If the user wants text that contains one of the delimiter, to be interpreted as one token, he has to enclose it in quotation marks, e.g.: create test 0 "2/pi" 100 or in square brackets, e.g.: text = [guten morgen]. Except for blank space, the delimiter are tokens of their own.

After the tokens have been translated, SPECTRA rebuilds the command line, which is then parsed into a verb, parameter and qualifier. Except for symbol assignments, the verb is always the first token.

Qualifiers are identified by a preceding "$/$". They consist of a keyword, e.g.: read/ascii ..., or a keyword and a value, e.g.: set alhe01 /x_min=100. There are no qualifiers in symbol assignments and calc commands. That means, the following assignment is valid:

SPECTRA> hardcopy = post/nocon/dina4/print
When analysing this command, SPECTRA finds the "=" as the second token which makes this command a symbol assignment. As a consequence, every "/" is treated as a parameter. After this assignment, hardcopy can be used as a synonym for post/....

The other tokens are parameters. There can be only one verb in a command line, but more than one parameter and qualifier.

In case of symbol assignments, the parameter list is compressed to two parameters: the symbol name and its value.

Next, the parameters are converted to upper case letters, if they do not contain a double quotation mark or belong to symbol assignments. If a parameter or qualifier is enclosed in double quotation marks, they are removed.

Qualifiers, parameters, symbols and results of scalar calculations are text strings. Because of this, the user does not have to worry about type conversions. The function which executes the command evaluates a parameter or qualifier as text, an integer number or a floating point number depending on the context. Lets look at the following example which demonstrates how the comment function is used in two different ways:

SPECTRA> read bpu1
SPECTRA> set bpu1/com_1="Energie 4711"
SPECTRA> set bpu1.3/text=com(bpu1,1,1)
The third command sets the TEXT GQE bpu1.3 to Energie , using com(...) as a string of characters. Com(i,j,k) selects the k$^{th}$ token of the j$^{th}$ comment line of SCAN number i. In more detail: The function GRA_SET, which executes set commands, finds the qualifier keyword TEXT and and evaluates the following qualifier value, com(bpu1, 1, 1) as a text string.

The next command line shows the same comment function, this time acting as a floating point parameter 4711.:

SPECTRA> calc bpu1 = bpu1/com(bpu1,1,2)