Skip to main content

module lang::cobol85::\syntax::EnvironmentDivision

rascal-0.43.3
org.rascalmpl.cobol-air-0.1.2

The ENVIRONMENT DIVISION as one flat list of its sections, paragraphs and entries.

Usage​

import lang::cobol85::\syntax::EnvironmentDivision;

Dependencies​

extend lang::cobol85::\syntax::ConfigurationSection;
extend lang::cobol85::\syntax::InputOutputSection;

Description​

This module composes the environment division from the configuration section and the input-output section. Instead of nesting sections, paragraphs and entries, EnvironmentDivision is one flat list of EnvironmentEntry items in any order: section headers, the SOURCE-COMPUTER, OBJECT-COMPUTER, SPECIAL-NAMES, FILE-CONTROL and I-O-CONTROL paragraphs, SELECT and I-O-CONTROL entries, and COPY statements. The flat list gives a COPY statement exactly one place to go, wherever it occurs between entries, and keeps the grammar unambiguous for copybooks that contain the rest of a paragraph or of the division. A checker can reject the orders COBOL does not allow.

syntax EnvironmentDivision​

syntax EnvironmentDivision = environmentDivision: 'ENVIRONMENT' 'DIVISION' "." EnvironmentEntry*;

syntax EnvironmentEntry​

syntax EnvironmentEntry
= configurationSection: 'CONFIGURATION' 'SECTION' "."
// not `(Id Computer_clause* ".")?`: rascal 0.43.1-RC1 fails on that group when the list in it is empty
| sourceComputer: 'SOURCE-COMPUTER' "." Id? ComputerClause* "."?
| objectComputer: 'OBJECT-COMPUTER' "." Id? ComputerClause* "."?
| specialNames: 'SPECIAL-NAMES' "." SpecialNamesParagraphPhrase* SpecialNamesParagraphClause* "."?
| inputOutputSection: 'INPUT-OUTPUT' 'SECTION' "."
| fileControl: 'FILE-CONTROL' "."
// the clauses may come in any order, also before ASSIGN (as in `SELECT SQ-FS4 RESERVE 1 ASSIGN "SEQ1.DAT"`)
| select: 'SELECT' 'OPTIONAL'? Id FileControlClause* 'ASSIGN' 'TO'? AltAssignmentNameLiteral+ FileControlClause* "."
| ioControl: 'I-O-CONTROL' "."
| ioControlEntries: IoControlEntry+ "."
// the rest of a paragraph, of the division, or even of the program can come from a copybook
| copy: CopyStatement
;

syntax CobwordKeywords​

keyword CobwordKeywords
= 'ASSIGN'
| 'CONFIGURATION'
| 'DIVISION'
| 'ENVIRONMENT'
| 'FILE-CONTROL'
| 'I-O-CONTROL'
| 'INPUT-OUTPUT'
| 'OBJECT-COMPUTER'
| 'OPTIONAL'
| 'SECTION'
| 'SELECT'
| 'SOURCE-COMPUTER'
| 'SPECIAL-NAMES'
| 'TO'
;