Note: The Integrated Preprocessor is supported for native COBOL only.
There are two example integrated preprocessors for you to look at; these have been designed to be stacked. Also provided are an example source program and an example copybook for the preprocessors to process. By copying and pasting these, you could create projects to contain these files and see how they work, or you could create your own preprocessors based on these examples.
The example preprocessors can be used as a basis for other preprocessors. They demonstrate the following:
- How the preprocessor is invoked and opens source input
- How source is passed without editing to the Compiler
- How source is edited and then passed to the Compiler
- How lines containing more than one verb are expanded
- How COPY statements are processed
- How warnings and errors are produced
- How preprocessors can be stacked
Specification of the Example Preprocessors
The example preprocessors recognize and process several verbs as follows:
- MOV is converted to MOVE
- DIS is converted to two lines, the first being DISPLAY SPACE UPON CRT and the second containing the original line with the word DIS replaced by DISPLAY
- PRINT is converted to DISPLAY
- CPY is converted to COPY, and thus expanded by the Compiler: COPY is expanded by the preprocessor
- WARN causes a warning message to be placed in the listing file
- ERROR causes a serious error message to be displayed. If you request that compilation should continue, the serious error count is increased.
In order to demonstrate stackable preprocessors, these functions are split into two separate programs. The two preprocessors are very similar, containing much common code.
The preprocessors include an example of a lexical analyzer for COBOL, which handles lexical tokens that do not continue across records.
Example Programs
The files
asmcobol.cbl and
working.cbl contain commands that can be interpreted by preprocessing the files using compiled versions of the Preproc or Preprox example preprocessors.