Skip to main content

module lang::cobol85::\syntax::DataDescriptionEntry

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

Data description entries: level numbers, data names and clauses such as PICTURE, USAGE, OCCURS and VALUE.

Usage​

import lang::cobol85::\syntax::DataDescriptionEntry;

Dependencies​

extend lang::cobol85::\syntax::ConfigurationSection;
extend lang::cobol85::\syntax::Lexical;
extend lang::cobol85::\syntax::Expression;

Description​

This module defines the entries that describe data items in every section of the data division. An entry has a level number, a data name or FILLER, and its clauses in any order: PICTURE, USAGE, VALUE, OCCURS with DEPENDING ON, ASCENDING or DESCENDING KEY and INDEXED BY, REDEFINES, RENAMES for level 66, SIGN, SYNCHRONIZED, JUSTIFIED, BLANK WHEN ZERO, EXTERNAL and GLOBAL. Entries can also be COPY statements or REPLACE directives, because copybooks often supply record descriptions. The entries form one flat list; the hierarchy that the level numbers imply is not built by the parser, and the clause combinations that COBOL does not allow are left to a checker.

syntax DataDescriptionEntry​

syntax DataDescriptionEntry
= // the follow restriction ensures that digits are eaten up by picture strings.
entry: Num ! decimal ! signedDecimal ! signedInteger !>> [.,] AltDataNameFiller? DataDescriptionEntryClause* "."?
| copy: CopyStatement
| replaceDirective: ReplaceDirective
;

syntax AltDataNameFiller​

syntax AltDataNameFiller
= filler: 'FILLER'
| dataName: Id
;

syntax DataDescriptionEntryClause​

syntax DataDescriptionEntryClause
= externalClause: ExternalClause
| globalClause: GlobalClause
| synchronized: Synchronized AltLeftRight?
| blank: 'BLANK' 'WHEN'? Zeroes
| sign: AltLeadingTrailing
| sign: 'SIGN' 'IS'? AltLeadingTrailing
| sign: AltLeadingTrailing 'SEPARATE' 'CHARACTER'?
| sign: 'SIGN' 'IS'? AltLeadingTrailing 'SEPARATE' 'CHARACTER'?
| values: Values Are? LiteralThroughLiteral+
| picture: Picture 'IS'? PictureString
| redefines: 'REDEFINES' Id
| usage: Usage
| usage: 'USAGE' 'IS'? Usage
| renames: 'RENAMES' QualifiedDataName
| renames: 'RENAMES' QualifiedDataName Through QualifiedDataName
| justified: Justified 'RIGHT'?
| occursClause: OccursClause
;

syntax ExternalClause​

syntax ExternalClause = external: 'IS'? 'EXTERNAL';

syntax GlobalClause​

syntax GlobalClause = global: 'IS'? 'GLOBAL';

syntax Synchronized​

syntax Synchronized
= synchronized: 'SYNCHRONIZED'
| sync: 'SYNC'
;

syntax AltLeftRight​

syntax AltLeftRight
= \left: 'LEFT'
| \right: 'RIGHT'
;

syntax Zeroes​

syntax Zeroes
= zeros: 'ZEROS'
| zero: 'ZERO'
| zeroes: 'ZEROES'
;

syntax AltLeadingTrailing​

syntax AltLeadingTrailing
= trailing: 'TRAILING'
| leading: 'LEADING'
;

syntax Picture​

syntax Picture
= pic: 'PIC'
| picture: 'PICTURE'
;

syntax Usage​

syntax Usage
= comp1: 'COMP-1'
| display: 'DISPLAY'
| index: 'INDEX'
| comp3: 'COMP-3'
| comp2: 'COMP-2'
| pointer: 'POINTER'
| computational4: 'COMPUTATIONAL-4'
| computational1: 'COMPUTATIONAL-1'
| computational2: 'COMPUTATIONAL-2'
| binary: 'BINARY'
| packedDecimal: 'PACKED-DECIMAL'
| comp: 'COMP'
| computational: 'COMPUTATIONAL'
| comp4: 'COMP-4'
| display1: 'DISPLAY-1'
| computational3: 'COMPUTATIONAL-3'
;

syntax Justified​

syntax Justified
= justified: 'JUSTIFIED'
| just: 'JUST'
;

syntax OccursClause​

syntax OccursClause
= occursDepending: 'OCCURS' Integer ('TO' Integer)? 'TIMES'? 'DEPENDING' 'ON'? QualifiedDataName OccursClauseKey* IndexedBy?
| occurs: 'OCCURS' Integer 'TIMES'? OccursClauseKey* IndexedBy?
;

syntax OccursClauseKey​

syntax OccursClauseKey = ascendingDescending: AltAscendingDescending 'KEY'? 'IS'? QualifiedDataName+;

syntax IndexedBy​

syntax IndexedBy = indexed: 'INDEXED' 'BY'? Id+;

syntax CobwordKeywords​

keyword CobwordKeywords
= 'BINARY'
| 'BLANK'
| 'BY'
| 'CHARACTER'
| 'COMP'
| 'COMP-1'
| 'COMP-2'
| 'COMP-3'
| 'COMP-4'
| 'COMPUTATIONAL'
| 'COMPUTATIONAL-1'
| 'COMPUTATIONAL-2'
| 'COMPUTATIONAL-3'
| 'COMPUTATIONAL-4'
| 'DEPENDING'
| 'DISPLAY'
| 'DISPLAY-1'
| 'EXTERNAL'
| 'FILLER'
| 'GLOBAL'
| 'INDEX'
| 'INDEXED'
| 'IS'
| 'JUST'
| 'JUSTIFIED'
| 'KEY'
| 'LEADING'
| 'LEFT'
| 'OCCURS'
| 'ON'
| 'PACKED-DECIMAL'
| 'PIC'
| 'PICTURE'
| 'POINTER'
| 'REDEFINES'
| 'RENAMES'
| 'RIGHT'
| 'SEPARATE'
| 'SIGN'
| 'SYNC'
| 'SYNCHRONIZED'
| 'TIMES'
| 'TO'
| 'TRAILING'
| 'USAGE'
| 'WHEN'
| 'ZERO'
| 'ZEROES'
| 'ZEROS'
;