COBOL Words

ANS85 A COBOL word is a character-string of not more than 30 characters which forms a compiler-directive word, a context-sensitive word, user-defined word, a system-name, a reserved word, or an intrinsic-function-name. Each character of a COBOL word that is not a special character word is selected from the set of letters, digits, the hyphen

ISO2002 and the underscore

.

The hyphen

ISO2002 or the underscore

may not appear as the first or last character in such words. Each lower-case letter is considered to be equivalent to its corresponding upper-case letter.

ISO2002 The character-string may contain 31 characters.

ANS85 Within a source element the following apply:

ANS85 
  1. ANS85 For all COBOL words excluding the words LENGTH, RANDOM, and SUM:
    1. Reserved words form disjoint sets with user-defined words, system-names and intrinsic-function-names.
    2. User-defined words, system-names and intrinsic-function-names form intersecting sets. The same COBOL word may be used as a user-defined word, a system-name and an intrinsic-function-name. The classification of a specific occurrence of such COBOL words is determined by the context of the clause or phrase in which it occurs.
  2. ANS85 For the COBOL words LENGTH, RANDOM, and SUM:
    1. The reserved words LENGTH, RANDOM and SUM form an identical set with the intrinsic-function-names LENGTH, RANDOM and SUM. The same COBOL word LENGTH, RANDOM, or SUM may be used as an intrinsic-function-name and as a reserved word. The classification of a specific occurrence of such COBOL words is determined by the context in which it occurs.
    2. The COBOL words LENGTH, RANDOM, and SUM form disjoint sets with user-defined words and system-names. They may not be used as a system-name or user-defined word regardless of context.

User-Defined Words

A user-defined word is a COBOL word that must be supplied by the user to satisfy the format of a clause or statement.

The types of user-defined words are:

  • alphabet-name
  • ISO2002MF class-name for object orientation
  • ANS85 class-name for truth value proposition
  • condition-name
  • MF constant-name
  • data-name
  • NET delegate-name
  • NETJVM enum-name
  • file-name
  • ISO2002 function-prototype-name
  • index-name
  • ISO2002MF interface-name
  • level-number
  • library-name
  • ISO2002MF method-name
  • mnemonic-name
  • paragraph-name
  • ISO2002 parameter-name
  • program-name
  • ISO2002 program-prototype-name
  • ISO2002 property-name
  • record-name
  • report-name
  • MF routine-name
  • ISO2002MFXOPEN screen-name
  • section-name
  • segment-number
  • ISO2002MF split-key-name
  • ANS85 symbolic-character
  • text-name
  • MF typedef-name
  • ISO2002 user-function-name
  • NETJVM valuetype-name

Within a given source element the following user-defined words are grouped into the following disjoint sets:

  • alphabet-names
  • ISO2002MF class-names for object orientation
  • ANS85 class-names for truth value proposition
  • condition-names,

    MF constant-names,

    data-names,

    ISO2002 property-names,

    record-names,

    ISO2002MF split-key-names

    MF typedef-names

  • NET delegate-name
  • NETJVM enum-name
  • file-names
  • ISO2002 function-prototype-names
  • index-names
  • ISO2002 interface-names
  • library-names
  • ISO2002MF method-names
  • mnemonic-names
  • paragraph-names
  • ISO2002 parameter-names
  • program-names
  • ISO2002MF program-prototype-names
  • report-names
  • MF routine-names
  • ISO2002MFXOPEN screen-names
  • section-names
  • ANS85 symbolic-characters
  • text-names.
  • ISO2002 user-function-names
  • NETJVM valuetype-name

All user-defined words, except segment-numbers and level-numbers, can belong to one and only one of these disjoint sets. Furthermore, all user-defined words within a given disjoint set must be unique, except as specified in the section Uniqueness Of Reference.

With the exception of paragraph-name, section-name, level-number and segment-number, all user-defined words must contain at least one alphabetic character

MF or one occurrence of the hyphen character

.

Segment-numbers and level-numbers need not be unique; a given specification of a segment-number or level-number can be identical to any other segment-number or level-number and can even be identical to a paragraph-name or section-name.

The following user-defined words are externalized to the operating environment:

  1. Program-names of programs that are not contained in other programs,

    ISO2002MF class-names,

    ISO2002 function-prototype-names, interface-names,

    ISO2002MF method-names,

    ISO2002 program-prototype-names, user-function-names

    .

  2. ANS85 Data-names, file-names, and record-names of items described with the EXTERNAL attribute.

If a literal is specified in place of or in addition to one of these names, the content of the literal is the name that is externalized to the operating environment in a case-sensitive manner. If no literal is specified, the externalized name is created by folding the name to upper case. The Compiler directive FOLD-CALL-NAME can be used to control the case of externalized class-names, interface-names and program-names. The F and U options of the Compiler directive OOCTRL can be used to control the case of externalized method-names. +F and -U cause method-names to be folded to lower case, which is the default.

Condition-name: A condition-name is a name which is assigned to a specific value, set of values, or range of values, within a complete set of values that a data item can assume. The data item itself is called a conditional variable. Condition-names can be defined in the Data Division or in the Special-Names paragraph within the Environment Division where a condition-name must be assigned to one or both of the ON STATUS or OFF STATUS of the run-time switches.

A condition-name is used only as follows:

  1. In the RERUN clause.
  2. In conditions as an abbreviation for a relation condition. This relation condition posits that the associated conditional variable is equal to one of the set of values to which that condition-name is assigned.
  3. In a SET statement indicating that the associated value is to be moved to the conditional variable.
Constant-name: A constant-name is a name which is assigned as the name of a fixed value.
Mnemonic-name: A mnemonic-name assigns a user-defined word to an implementor-name. These associations are established in the Special-Names paragraph of the Environment Division. (See the topic The Special-Names Paragraph.)
Paragraph-name: A paragraph-name is a word that names a paragraph in the Procedure Division. Paragraph-names are equivalent if, and only if, they are composed of the same sequence of the same number of characters.
Section-name: A section-name is a word that names a section in the Procedure Division. Section-names are equivalent if, and only if, they are composed of the same sequence of the same number of characters.
Other user-defined words: See the Glossary for definitions of all other types of user-defined words.

System-names

A system-name is a COBOL word that is used to communicate with the operating environment.

System-names must contain at least one alphabetic character

MF or one occurrence of the hyphen character

.

There are three types of system-names:

  • Computer-name
  • Implementor-name
  • Language-name.

Within a given implementation these three types of system-names form disjoint sets; a given system-name can belong to one and only one of them.

The system-names listed above are individually defined in the Glossary.

Intrinsic-function-names

ANS85 An intrinsic-function-name is a word that is one of a specified list of words which can be used in COBOL source elements. The same word, with the exception of LENGTH, RANDOM and SUM, in a different context, can appear in a source element as a user-defined word or a system-name. (See the topic Definitions of Functions.)

Reserved words

A reserved word is a COBOL word that is one of a specified list of words which can be used in COBOL compilation groups, but which must not appear in the compilation groups as user-defined words or system-names. Reserved words can be used only as specified in the general formats. (See the topic Reserved Words.)

The types of reserved words are:

  • Key words
  • Optional words
  • Special registers
  • Figurative constants
  • Special-character words
  • ISO2002MF Predefined object identifiers.

Key words: A key word is a word whose presence is required when the format in which it appears is used in a compilation group. Within each format, such words are upper-case and underlined.

Key words are of three types:

  1. Verbs such as ADD, READ, and ENTER
  2. Required words, which appear in statement and entry formats
  3. Words which have a specific functional meaning, such as NEGATIVE, SECTION, and so on.
Optional words: Within each format, upper-case words that are not underlined are called optional words and can appear at the user's discretion. The presence or absence of an optional word does not alter the semantics of the COBOL source element in which it appears.
Special registers: Certain words are used to name and reference special registers: special registers are certain storage areas created by your COBOL system, whose primary use is to store information produced in conjunction with the use of specific COBOL features. They are specified in the section Special Registers.
Figurative constants: Certain reserved words are used to name and reference specific constant values. These reserved words are specified in the section Figurative Constant Values.
Special character words: The arithmetic operators and relation characters are reserved words.
Predefined object identifiers: Certain reserved words are used as predefined object identifiers. The predefined object identifiers are:
  • SELF
  • SUPER
  • MF SELFCLASS

Context-sensitive words

ISO2002 A context-sensitive word is a COBOL word that is reserved only in the general formats in which it is specified. The same word may also be used as an intrinsic-function-name, a user-defined word or a system-name. Context-sensitive words and the contexts in which they are reserved are specified in the section Context-sensitive Words Table in the appendix Reserved Words.