COMTRAN Reconstruction

The language reference is this project’s reading of the two manuals, not IBM’s text. Every claim in it cites a page, and each citation opens that page beside its scan.

Part 2 of 10 of the COMTRAN Language Definition.

2. Overall program structure and procedure organisation

This section defines what a complete COMTRAN (Commercial Translator) program is: its three descriptions (divisions), the physical source-deck structure that delivers them to the processor, the expression → clause → sentence → section hierarchy of the procedure text, procedure-names and sectioning, the default flow of control, and the full verb inventory divided into program verbs and processor verbs. F28-8043 (June 1960) gives the language design; J28-6169-1 (Jan 1962) is authoritative for the implemented 709/7090 language. Divergences are flagged inline.

2.1 The three descriptions (divisions) of a complete program

"All Commercial Translator programs are composed of three divisions, the Procedure Description, the Data Description, and the Environment Description. The first of these contains the procedure statements of which the program is composed. The second provides the processor with information about the data to be used in the object program. The third is used to make certain technical connections between the program and the machine system on which it will be run" (F p. 26). Informally, "A Commercial Translator program consists primarily of procedure description and data description" (F p. 16); the environment description is machine-dependent and in 1960 was deferred to the individual processor publications (F p. 26). For the 709/7090, the compiler "analyzes Commercial Translator Data, Procedure and Environment Descriptions and CRYPT symbolic machine language instructions and produces a relative binary object program deck" (J 02.00).

Division roles, in brief:

Division Header Contents Detailed in
Procedure Description *PROCEDURE Procedure statements (clauses, sentences, sections); both program and processor commands (F p. 16, p. 37) see the Procedure verbs/commands section of this reference
Data Description *DATA Entries reserving storage and describing organization, format, level structure of every named datum, named constant, and condition-name (F p. 16, p. 26) see §3 (Data description and storage model)
Environment Description *ENVIRONMENT External physical factors: FILE, SPECIF, POOL, GROUP, CONTRL, OPTION, COND cards (J 02.06.01.01, 02.06.01.01–02.06.02) see the Environment description section of this reference

Key architectural principles the manuals state explicitly:

Division headers and interleaving

"It is not necessary that these three divisions appear as separate entities. If appropriate, the programmer may write a portion of one, then a portion of another, and so on. However, each such portion must be properly labeled with a division header. Each header consists of the name of the division, preceded by an asterisk" (F p. 27). The three headers are, verbatim:

*PROCEDURE
*DATA
*ENVIRONMENT

(F p. 27)

F/J divergence / confirmation: J never restates the interleaving rule, but its diagnostic list presupposes it: compiler message 87,00 reads PROBABLE PROGRAM CONTINUITY ERROR. PROGRAM FLOWS INTO *DATA. (J 90.04.01), which can only arise if a *DATA portion may physically follow procedure text. The compiled sample program uses one portion of each division in the order *DATA, *ENVIRONMENT, *PROCEDURE (J 90.05, listing PDF pp. 192–197); treat that as the canonical ordering, with interleaving permitted (see Ambiguity register). Within the environment division, "The SPECIF card(s) may appear anywhere within the environment division" (J 02.06.07).

CRYPT (709/7090 symbolic machine language) portions may additionally be embedded "at any logical point in his program" via ENTER CRYPT, terminated by ENTER COMMERCIAL TRANSLATOR (J 02.08.01, 02.08.03); see §2.7 under ENTER.

2.2 Source deck structure: how a program reaches the compiler

Source programs are read "in the form of a deck of punched cards or their equivalent on tape; each line of the programming form becomes one card in the source program deck" (F p. 37).

2.2.1 The $CMPLE card

"A $CMPLE card must precede each source language program. It is recognized by the Commercial Translator Monitor (CTM) for purposes of operational control and interpreted by the Commercial Translator compiler to initiate processing of source language statements" (J 02.01.01). Its general form, verbatim:

1  -  6      8  -  13       16
$CMPLE       deck.name      [NODECK]        [,LIST]         [,DICT]
                            [,LOAD]         [,LOGIC]        [,FILES]
                            [,MAP]          [,NOGO]

             55        -        72
             [secondary.identifier]

(J 02.01.01)

Rules a compiler writer needs:

2.2.2 The *FINISH card and end-of-file

"The *FINISH card delimits the extent of the source language statements to be compiled. The form of the card is:"

7
*FINISH

"Note that this card must be followed by an end of file" (J 02.01.02, referring to J 04.02 and 05.03). "Each Commercial Translator job must be followed by an end-of-file" (J 04.02.01). The end-of-file card "should be thought of as an integral part of every job deck" (J 05.03.01, which gives its physical punch format — operator-procedure detail outside this definition's scope). A missing *FINISH is diagnosed: 132,00 END OF FILE ON JOB TAPE WITHOUT *FINISH CARD. (J 90.04.01).

A complete compile job deck on the system input, from the manual's own stacked-input example (J 05.03.02):

$ID            JOB1                Accounting card is optional
$CMPLE
                BCD
                Source
                Program
                Cards
        *FINISH                    This card precedes end-of-file on COMPILE jobs.
End-of-file-card

(J 05.03.02; $ID is optional. The "Source Program Cards" are the division portions of §2.1, each introduced by its division header.)

If the object program itself reads SYSIN, "the input cards must be placed in a separate file immediately following the job to be run" (J 05.03.01).

2.2.3 Compiler output (as it reveals source structure)

Normal output is a relocatable column-binary deck: Symbolic Control cards, *CTEXT, Relative Binary Program Deck (Control Break Table, File Check Table, Text), *CTEND (J 02.02; deck format in Appendix 90.03 — see the object-deck section of this reference). Note the 90.01 deferrals: no control break table and no file check table are actually punched (J 90.01.04). The list tape carries the source listing with, per line: (a) source card sequence number; (b) "statement number assigned by the Compiler to the Procedure sentence, Data Description entry or Environment card. It is of the form xxxxx,00"; (c) card body, columns 7–72, in which "In some cases, names generated by the Compiler, i.e., GN)nnn, are shown in the name field of Procedure statements or Data entries unnamed by the programmer" (J 02.02). Statement numbers have three to six digits; "The last two are separated from the preceding digit(s) by a comma and they tell which clause is being referenced. The digit(s) preceding the comma tell which line is being referenced. The statement number 9999,99 is an exception. It is used to reference errors which are not confined to a single source statement" (J 02.02). This confirms that the compiler tracks structure to the granularity of individual clauses within a sentence.

2.2.4 The procedure coding form (card columns)

The procedure description is written "in 'free-form' text on a programming form ... it has just four fields" (F p. 37):

Field Columns Rules
Ctl. + Serial 1–6 One field; the first three spaces are "the same for all lines on one page"; used for card sequence via numbers and/or alphabetics; column 6 usually blank or zero so inserts 011…019 can go between 010 and 020 (F p. 37)
Procedure Name 7–12 The "name margin"; procedure-names written left-justified here, "sticking out" into the margin (F p. 37)
Text 13–72 Free-form procedure statements (F p. 37)
Identification 73–80 Optional program identification, same for all lines of a page (F p. 37)

F/J divergence (sequence checking): F states the Ctl./Serial information "will be sequence-checked by the processor" (F p. 37); J states flatly "Card serial numbers in columns 1-6 of source decks are not sequence checked by the compiler" (J 02.03.01). J governs.

Line-placement rules for text (F p. 37, verbatim in substance):

  1. "A named sentence follows its name. That is, it begins to the right of the name margin, on the same line as its name."
  2. "An unnamed sentence must begin on a separate line and to the right of the name margin."
  3. "Succeeding lines of a sentence must begin to the right of the name margin. (If desired, they may be indented to facilitate reading the text.)"
  4. "When a section of procedure is begun, only the BEGIN SECTION command may appear on the same line as the name of the section."
  5. "To end a section, the command 'END section.name' is written as a sentence, i.e., on a separate line."

Continuation and break-point rules (J 02.03.01):

Statement/entry termination (J 02.03.01–02.03.02):

For files read from the on-line card reader, "only columns 1 through 72 are read" (J 02.06.04), relevant to object-time data, not source decks, but stated on the Environment FILE card.

2.3 The structural hierarchy: expressions → clauses → sentences → sections → divisions

The language "may be helpful to think of ... as existing on two different levels": the elements (characters, fixed words, punctuation, names, literals; see the language-elements section of this reference) and the syntax, "how to fit elements together properly" (F p. 7).

Expressions

"[O]ne basic structural building block is an expression; this is defined as any grouping of elements which always establishes a unique value. An arithmetic expression can take on any numeric value whereas a conditional expression may only be true or false" (F p. 7). Expressions are components of clauses; their formation rules (operators, relations, AND/OR/NOT, truth functions, subscripts, functions) are covered in the expressions section of this reference (F pp. 20–24; operator hierarchy J 02.04.05.01).

Clauses

"Sentences ... are composed of one or more shorter units, known as clauses. There are two kinds of clauses: imperative and conditional" (F p. 24).

Sentences

"A Commercial Translator sentence ... expresses a complete and independent thought. It must contain at least one imperative clause and may contain, in addition, one conditional clause and one or more additional imperative clauses. It is terminated by a period, which must be followed by a blank ... Imperative clauses within the same sentence must be separated by commas" (F p. 25).

Structural/punctuation semantics of the sentence:

Sample sentences (F p. 25):

ADD 1 TO COUNTER.
GO TO TAX.CALCULATION.
STOP.
IF MARRIED THEN MOVE NAME TO MAILING.LIST.M,
    ADD 1 TO COUNTER.
IF GROSS.PAY LT NET.PAY THEN GO TO ERROR.ROUTINE.
IF OUT.OF.ZONE THEN DO BILLING.ROUTINE.A OTHERWISE
    DO BILLING.ROUTINE.B.

Sections and divisions

Sections group successive sentences under one name (§2.5); divisions are the three descriptions (§2.1). "Sentences are not grouped into sections for the purpose of clarifying the logic or the structure of the program for the benefit of the system ... Sectioning, in the Commercial Translator, is used for the purpose of naming portions of procedure" (F p. 26).

2.4 Procedure-names: how statements are labeled

"Procedure-names are names assigned to individual portions of the program so that one procedure can refer to another" (F p. 14). "Procedure-names may be assigned to any sentence or section of the program. (A section consists of one or more successive sentences.) ... Procedure-names may also be referred to as sentence-names or section-names, as appropriate" (F p. 14). "A procedure-name identifies a fixed set of procedure statements", unlike a data-name, which identifies a storage area with varying contents (F p. 16). Assignment "consists merely of writing the procedure-name before the statement or statements to which it refers" (F p. 16).

Formation and placement rules:

  1. General name-formation rules apply (letters, digits, imbedded periods; begin with a letter; no blanks; see the names/elements section of this reference, F p. 15).
  2. "Procedure-names, like data-names, may contain up to thirty characters. Unlike data-names, however, they must be followed by a period and a blank" (F p. 37).
  3. "Procedure-names are written left-justified in the name margin and, if longer than six characters, extend into the 'Text' area" (F p. 37).
  4. A named sentence begins on the same line as its name; see the line rules in §2.2.4 (F p. 37).

F/J divergence (the trailing period): J notes "Procedure.names not followed by a period (.) and blank are handled properly; no diagnostic message is given" (J 90.01.03). The period-blank is thus mandatory in the language definition but not enforced by the 7090 compiler.

J-side behaviours:

2.5 Sections: BEGIN SECTION … END

"A section consists of one sentence, or a group of successive sentences, which has been given a name for reference purposes" (F p. 26). BEGIN SECTION and END "are used to delimit sections of procedure and thus extend the range of a procedure-name. ... Unless BEGIN SECTION and END are used, a procedure-name applies only to the sentence which follows it" (F p. 56). "If a procedure consists of more than one sentence, it must be defined as a section in order to be named" (F p. 49).

General form, verbatim:

procedure.name.  BEGIN SECTION.
     any sentence.
     .
     .
     .
     any sentence.
END procedure.name.

(F p. 57)

Rules:

BEGIN SECTION USING parameter.1, parameter.2, ...
     parameter.n GIVING function.1, function.2, ... function.n

(F p. 57). The parameters are replaced at object time by the data of the DO command's USING phrase; the functions are results delivered to the DO's GIVING phrase; function-names may also be invoked directly in arithmetic expressions with arguments in double parentheses (F pp. 57–58; details in the DO/functions coverage of the verbs section of this reference). F/J divergence: the Data Description type codes PARAM and FUNCT that F requires for these names (F p. 34) "are no longer in the language" (J 02.05.03); the J compiler still processes USING/GIVING and function references (diagnostics 30,00; 68,00; 72,00–75,00, J 90.04.01); see Ambiguity register.

Significance of sections beyond naming (things a compiler writer must support):

Numeric limits on sections (approximate maxima, J 90.01.05): number of SECTIONS 35; depth of nested sections 18. Exceeding the section table gives 149,00 NUMBER OF SECTIONS IN PROGRAM EXCEEDS INTERNAL TABLE CAPACITY. (J 90.04.01).

2.6 Default flow of control and program termination

2.7 Verbs: program verbs vs processor verbs, and the complete inventory

"In the Commercial Translator language, a verb is a word that prescribes an action. Verbs are not used in a declarative sense" (F p. 12). Two categories:

Verbs are distinct from operators (IF, THEN, arithmetic symbols, relations, etc.), which also cause operations but are not verbs (F p. 13). "Commercial Translator verbs may be easily recognized by the fact that all of them are words which serve also as verbs in the English language" (F p. 13). The system is "open-ended": "the list of verbs and associated commands is never closed" (F p. 35).

The complete F verb inventory, verbatim (F p. 35):

OPEN     \
GET       |  Input/Output
FILE      |
CLOSE    /

MOVE        Data Transmission

SET      \
ADD      /  Arithmetic

GO TO    \
DO        |  Control
STOP     /

LOAD      \
DISPLAY   /  Miscellaneous
OVERLAP
BEGIN SECTION
END
INCLUDE
CALL
NOTE
ENTER

Program verbs

Verb Category (F p. 35) One-line purpose Where detailed
OPEN Input/Output Initiates handling of one or more files (OPEN file.name... / OPEN ALL FILES); required before GET/FILE (F p. 39) I/O section of this reference; J 02.07
GET Input/Output Makes the next record of an open file available (GET RECORD FROM file.name / GET record.name), optional AT END clause (F pp. 39–40; J replaces F's definition of the second form — J 02.07.04) I/O section; J 02.07.04–02.07.06
FILE Input/Output Places a record in an output file (FILE record.name / FILE record.name IN file.name); record remains available (F pp. 40–41) I/O section; J 02.07.08
CLOSE Input/Output Terminates use of files (CLOSE file.name... / CLOSE ALL FILES); every opened file must ultimately be closed (F p. 41); J: CLOSE ALL FILES'd files may not be reopened (J 02.04.06) I/O section; J 02.04.06
MOVE Data Transmission Moves data (with automatic editing) from one storage area to one or more others; MOVE CORRESPONDING moves same-named fields of groups (F pp. 42–43; J 02.04.03–02.04.05) verbs section; §3 for editing/pictorials
SET Arithmetic SET variable(s) = arithmetic expression (replacement; TRUNCATED, ON OVERFLOW options); also SET condition.name to set a conditional variable (F pp. 44–46; J 02.04.05) verbs section
ADD Arithmetic Adds a quantity to one or more variables; ADD CORRESPONDING adds same-named fields (F p. 47) verbs section
GO TO Control Transfer of control: unconditional, conditional (...WHEN...), and assigned (GO TO (p1,...,pn) ON index) forms (F pp. 48–49) verbs section
DO Control Executes a closed subroutine (sentence or section) and returns; EXACTLY n TIMES, up-to-3-index looping FOR i = p(q)r, and USING…GIVING data substitution (F pp. 49–53) verbs section
STOP Control Halts the object program displaying n; restart resumes in sequence (F p. 54); J adds mandatory STOP RUN terminator (J 02.04.06) verbs section; §2.6
LOAD Miscellaneous Brings an overlapped procedure from external storage into the shared area (F p. 54). Deferred in J (J 90.01.03) verbs section
DISPLAY Miscellaneous Presents low-volume information/messages on the display device (on-line 716 printer for 709/7090) (F pp. 54–55; J 02.04.02.01) verbs section

Processor verbs

Verb One-line purpose J status Where detailed
OVERLAP Assigns two or more procedures to the same storage area for LOAD-time alternation (F pp. 55–56) Deferred: "Implementation of these verbs [LOAD and OVERLAP] has been deferred" (J 90.01.03); no program segmentation (J 90.01.05) verbs section
BEGIN SECTION Opens a named section; optional USING…GIVING for parameterised procedures (F pp. 56–57) Implemented (J 90.05 passim); PARAM/FUNCT data type codes removed (J 02.05.03) §2.5
END Closes the named section; sentence must contain nothing else (F p. 57; J 90.04.01 message 179,00) Implemented §2.5
INCLUDE Extracts a library procedure into the program (INCLUDE at end / INCLUDE HERE in place), with AS and WITH…FOR name substitution (F p. 58) Deferred: "Mechanization of the INCLUDE verb has been deferred, and consequently no library facilities are currently available" (J 90.01.02) verbs section
CALL Declares synonyms: CALL (old.name.1) new.name.1, ...; synonyms must be single names; may rename compound names (F p. 59) Implemented; (old.name) must be unique, may not be subscripted; avoid record.names (J 02.04.05; J 90.01.01); needed to give one-word names for Environment/CRYPT use (J 02.03.03) verbs section
NOTE Places explanatory commentary in the listing only; "will not produce instructions in the object program"; terminated by the first period followed by a blank (F p. 59) Implemented verbs section
ENTER Switches source language: ENTER coding.language / ENTER COMMERCIAL TRANSLATOR (F p. 59) Restricted: "There are only two forms which this command may take: ENTER CRYPT and ENTER COMMERCIAL TRANSLATOR" (J 02.04.02.01); CRYPT rules at J 02.08 verbs section; CRYPT coverage

Relationship between program and processor commands

"they cannot be intermixed in source program sentences. For example, it is meaningless to write sentences such as: IF A = B THEN GO TO C OTHERWISE OVERLAP SECTION.1, SECTION.2." (F p. 60). "Processor commands, with the exception of BEGIN SECTION and END, should be written as unnamed sentences. This rule makes it impossible for a program command to transfer control to a processor command. ... This is not to say, however, that the two types of commands cannot appear in sequence in a source program" (F p. 60). The sample program's first *PROCEDURE statement is an unnamed CALL sentence, listed under generated name GN)000 (J 90.05, listing PDF p. 195).

Presentation convention used throughout both manuals (and this reference): each command has a "general form" in which fixed words are boldface capitals and programmer-supplied items lower-case; "except for imbedded periods within italicized words, any punctuation shown in the general form of a command is a fixed and necessary part of the command" (F p. 38). The concise collected forms are in F Appendix 2. In J, [ ] denotes an option, { } a choice, upper case must appear as shown, lower case is generic, and "The order in which options are exercised on the various cards is not critical unless otherwise specified" (J 01.01.01).

2.8 How procedures connect to the data and environment descriptions

2.9 Program size and structural limits (7090 implementation)

Internal table size limitations, "Appox-Max Size" (J 90.01.05, reproduced in full):

Item Approx. max
Internal dictionary including all program names whether defined by the programmer or generated by the Compiler 3500
Number of SECTIONS 35
Number of different edited field formats 35
Number of base locators (for the field test version this is the number of located records) 127
Number of QUANTITY IN specifications 25
Depth of nested sections 18
Number of index expressions (a * VARIABLE ± b) 50
Number of positional indicators (each unique combination of array and subscript notation, e.g., A(I), A(I + 1) B(I) requires 3 positional indicators) 90
Number of array dimensions (explicit or implicit Quantity specifications) 85
Number of levels in a data hierarchy 23
Number of generated constants in the constant pool -CP)+NN 500

Other structural limits and constraints:

2.10 Ambiguities affecting this section (summary)

Recorded in detail in the ambiguity register accompanying this reference: (1) the undefined PROGRAM.START entry-point mechanism; (2) division ordering/interleaving under the J compiler; (3) treatment of cards preceding the first division header; (4) the F-vs-J sequence-checking contradiction; (5) GO TO out of a DO-addressed section (used by IBM's own sample program despite the closed-subroutine rule); (6) parameter/function declaration after removal of PARAM/FUNCT; (7) survival of the STOP n form alongside J's mandatory STOP RUN; (8) section-scoped name uniqueness.