module lang::cobol85::\syntax::ProcedureDivision
rascal-0.43.3
org.rascalmpl.cobol-air-0.1.2
The PROCEDURE DIVISION: its header, declaratives, sections, paragraphs and sentences.
Usage
import lang::cobol85::\syntax::ProcedureDivision;
Dependencies
extend lang::cobol85::\syntax::Statement;
extend lang::cobol85::\syntax::Expression;
Description
This module defines the structure of the procedure division: the header with its optional USING phrase, the DECLARATIVES part with its sections and USE statements, and the body as paragraphs that may be grouped into sections with a header and an optional segment priority number. A paragraph consists of sentences, and a sentence is a list of statements from the Statement module ending with a period; COPY statements may also stand in place of a sentence. Paragraphs before the first section header are allowed, as in programs without sections.
syntax ProcedureDivision
syntax ProcedureDivision
= procedureDivision: 'PROCEDURE' 'DIVISION' UsingPhrase Paragraphs SectionWithHeader*
| procedureDivision: 'PROCEDURE' 'DIVISION' UsingPhrase 'DECLARATIVES' "." DeclarativesContent+ 'END' 'DECLARATIVES' "." Paragraphs SectionWithHeader*
;
syntax UsingPhrase
syntax UsingPhrase
= copy: CopyStatement
| copy: 'USING' Id* CopyStatement
| using: UsingDataNamePluslist? "."
;
syntax SectionWithHeader
syntax SectionWithHeader = sectionHeader: SectionHeader "." Paragraphs;
syntax DeclarativesContent
syntax DeclarativesContent = sectionHeader: SectionHeader "." UseStatement "." Paragraphs;
syntax SectionHeader
syntax SectionHeader = section: SectionName 'SECTION' PriorityNumber?;
syntax Paragraphs
syntax Paragraphs = items: ParagraphItem* Paragraph*;
syntax Paragraph
syntax Paragraph
= items: ParagraphName "." ParagraphItem*
| go: ParagraphName "." 'GO' 'TO'? "."
;
syntax ParagraphItem
syntax ParagraphItem
= sentence: Sentence
| replaceDirective: ReplaceDirective
;
syntax Sentence
syntax Sentence
= statementList: StatementList "."+
| copy: StatementList? CopyStatement
;
syntax CobwordKeywords
keyword CobwordKeywords
= 'DECLARATIVES'
| 'DIVISION'
| 'END'
| 'GO'
| 'PROCEDURE'
| 'SECTION'
| 'TO'
| 'USING'
;