Reading Syntax Diagrams

Throughout this book, syntax is described using the structure defined below.
  • Read the syntax diagrams from left to right, and from top to bottom, following the path of the line:
    ►►───
    Indicates the beginning of a statement. Diagrams of syntactical units other than statements, such as clauses, phrases and paragraphs, also start with this symbol.
    ───►
    Indicates that the statement syntax is continued on the next line.
    ►────
    Indicates that a statement is continued from the previous line.
    ───►◄
    Indicates the end of a statement. Diagrams of syntactical units other than statements, such as clauses, phrases and paragraphs, also end with this symbol.
    Note: Statements within a diagram of an entire paragraph do not start with ►►─── and end with ───►◄ unless their beginning or ending coincides with that of the paragraph.
  • Required items appear on the horizontal line (the main path). Optional items appear below the main path:

    Read syntax diagramSkip visual syntax diagramSTATEMENTrequired itemoptional item
  • When you can choose from two or more items, they appear vertically, in a stack.

    If you must choose one of the items, one item of the stack appears on the main path. If choosing an item is optional, the entire stack appears below the main path:

    Read syntax diagramSkip visual syntax diagramSTATEMENTrequired-choice-1required-choice-2optional-choice-1optional-choice-2
  • An arrow returning to the left above an item indicates that the item can be repeated:

    Read syntax diagramSkip visual syntax diagramSTATEMENTrepeatable-item
  • A repeat arrow above a stack of required or optional choices indicates that you can make more than one choice from the stacked items, or repeat a single choice:

    Read syntax diagramSkip visual syntax diagramSTATEMENTchoice-1choice-2choice-3choice-4

The following example shows how the syntax is used:

Format

Read syntax diagramSkip visual syntax diagramSTATEMENT1identifier-12literal-1item 13TOidentifier-mROUNDED4ONSIZE ERRORimperative-statement-m5END-STATEMENT6
item 1
Read syntax diagramSkip visual syntax diagramidentifier-2literal-2arithmetic-expression-1
Notes:
  • 1 The STATEMENT key word must be specified and coded as shown.
  • 2 This operand is required. Either identifier-1 or literal-1 must be coded.
  • 3 The item 1 fragment is optional; it can be coded or not, as required by the application. If item 1 is coded, it can be repeated with each entry separated by one or more COBOL separators. Entry selections allowed for this fragment are described at the bottom of the diagram.
  • 4 The operand identifier-m and associated TO key word are required and can be repeated with one or more COBOL separators separating each entry. Each entry can be assigned the key word ROUNDED.
  • 5 The ON SIZE ERROR phrase with associated imperative-statement-m are optional. If the ON SIZE ERROR phrase is coded, the key word ON is optional.
  • 6 The END-STATEMENT key word can be coded to end the statement. It is not a required delimiter.