module lang::cobol85::\syntax::Copybook
The start nonterminal Copybook for parsing a copybook on its own.
Usage
import lang::cobol85::\syntax::Copybook;
Dependencies
extend lang::cobol85::\syntax::Main;
Description
A copybook is a fragment of a program whose kind depends on where it is copied, so it can not be parsed with
the start nonterminal for whole programs. This module defines Copybook with one alternative per kind of complete
fragment: procedure paragraphs and sections, data description entries, the clauses of a file description,
environment division entries, the remaining divisions after the environment division header, and SPECIAL-NAMES
content. A copybook that fits several alternatives parses as an ambiguity at the top, which
parseCobol85Copybook accepts. A fragment that is only part of an entry or a statement, such as the end of a data
description entry or a single operand, does not parse on its own.
syntax Copybook
start syntax Copybook
= procedure: Paragraphs SectionWithHeader*
| dataEntries: DataDescriptionEntry+
| fileClauses: FileAndSortDescriptionEntryClause+ "."
| environment: EnvironmentEntry+
// the rest of a program after `ENVIRONMENT DIVISION.`, as in `COPY K6SCA.`
| divisions: EnvironmentEntry* DataDivision ProcedureDivision?
| specialNames: SpecialNamesParagraphPhrase+ SpecialNamesParagraphClause* "."?
| specialNames: SpecialNamesParagraphClause+ "."?
;