Skip to main content

module lang::cobol85::\syntax::Program

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

Composing an entire COBOL program from its constituents

Usage​

import lang::cobol85::\syntax::Program;

Dependencies​

extend lang::cobol85::\syntax::ProcedureDivision;
extend lang::cobol85::\syntax::IdentificationDivision;
extend lang::cobol85::\syntax::EnvironmentDivision;
extend lang::cobol85::\syntax::DataDivision;
extend lang::cobol85::\syntax::Expression;
extend lang::cobol85::\syntax::Functions;

Description​

This module puts the four divisions together into a complete source program: the IDENTIFICATION DIVISION with PROGRAM-ID and the optional COMMON and INITIAL attributes, followed by the environment, data and procedure divisions, each optional, and REPLACE directives after the PROGRAM-ID paragraph. Nested programs follow the procedure division of the program that contains them, and each ends with END PROGRAM and its name; an outermost program needs END PROGRAM only when it contains nested programs. The module also brings in the intrinsic functions from the Functions module, so they can be used in expressions.

syntax CobolSourceProgram​

syntax CobolSourceProgram = programId: Identification 'DIVISION' "." 'PROGRAM-ID' "."? Id ('IS'? CommonInitial 'PROGRAM'?)? "."? ReplaceDirective* IdentificationDivisionContent EnvironmentDivision? DataDivision? ProcedureDivision? (NestedCobolSourceProgram* 'END' 'PROGRAM' Id ".")?;

syntax NestedCobolSourceProgram​

syntax NestedCobolSourceProgram = programId: Identification 'DIVISION' "." 'PROGRAM-ID' "."? Id ('IS'? CommonInitial 'PROGRAM'?)? "."? ReplaceDirective* IdentificationDivisionContent EnvironmentDivision? DataDivision? ProcedureDivision? NestedCobolSourceProgram* 'END' 'PROGRAM' Id ".";

syntax CommonInitial​

syntax CommonInitial
= initial: 'INITIAL' 'COMMON'?
| common: 'COMMON' 'INITIAL'?
;

syntax CobwordKeywords​

keyword CobwordKeywords
= 'COMMON'
| 'DIVISION'
| 'END'
| 'INITIAL'
| 'IS'
| 'PROGRAM'
| 'PROGRAM-ID'
;