NET/MASTER Network Control Language (NCL) Reference Manual

Lexical Elements of NCL
Compiler Operation
106126 Tandem Computers Incorporated 8–3
Rules for Delimiting Lexical Elements
If the compiler finds an illegal character, it regards the lexical element as all characters
up to, but not including, the illegal character. The compiler uses the illegal character
to delimit the lexical element and treats the character that follows a delimiter as the
first character of the next lexical element. It uses this character to work out the lexical
element type (described later in this section). It then regards the lexical element as the
sequence of characters that is legal for that lexical element type.
The following is an example of a sequence of legal characters delimited by an illegal
character. The compiler treats the sequence of characters &abc*1 as three lexical
elements because using the asterisk (*) is illegal within a variable (and so the asterisk
acts as a lexical element delimiter). The three lexical elements are:
&abc (a variable)
* (an arithmetic operator for multiplication)
1 (a number)
The compiler treats comments as lexical element delimiters. Comments are discussed
in more detail later in this section.
The compiler treats an end-of-line marker as a lexical element delimiter.
Table 8-2 lists the rules used by the compiler for delimiting each type of lexical
element.
Table 8-2. Rules For Delimiting Lexical Elements
Lexical Element Type Rule
Symbol If the first character is a character that can make up a symbol, the compiler
treats the lexical element as a symbol. The compiler delimits the symbol by
a blank or by a character that is illegal for the symbol type.
Quoted string If the first character is a single quote (') or a double quote ("), the compiler
treats the lexical element as a quoted string. The compiler operates as if
the last character of the lexical element is a quote of the same type, and it
uses the closing quote to delimit the lexical element.
Variable If the first character is an ampersand (&), the compiler treats the lexical
element as a variable. The compiler delimits the variable by a blank, by a
character that is illegal for the variable type, or by a mismatched
parenthesis.
Operator If the character is an operator, the lexical element is the longest acceptable
number of operator characters that can follow it. Some operators have
more than one character.
Special character If the character is a special character, then the lexical element is the
character itself.