Go to the first, previous, next, last section, table of contents.


13. How COBOL for GCC Works

13.1 FILES

This file is a list of files in the source directory gcc/COBOL


ChangeLog       List of changes to the programs
COBOLInformationBulletins.txt List of corrections and clarifications to COBOL 85
COPYING         Copyright details for GPLed parts of the compiler
COPYING.LIB     Copyright details for LGPLed parts of the compiler (ie most of the runtime)
Make-lang.in    Makefile fragment, included into the gcc/Makefile by the configure process
Makefile.in     Makefile fragment, used as a basis for the gcc/COBOL/Makefile by the configure process
README          Starting point for exploring the source

cob_version.h   Include file for version string.

coba2e.c        (generated file from coba2e.l)
coba2e.l        ASCII to EBCDIC conversion program in the form of input to the lexical analyser.
coba2ex.h       ASCII to EBCDIC conversion table

cobc*           Core COBOL compiler:
cobcast.c       - abstract sytax tree maintenance  
cobcbei.c       - back end (gcc) code generation interface
cobcc1.c        - top level for COBOL, called by toplev.c; controls core compile
cobcc1.h        - core compiler header
cobckw.c        - (generated file from cobckw.tpl via *.txt)
cobckw.tpl      - keyword lookup table and code - skeleton file
cobckw.txt      - (generated file from cobckw.tpl)
cobclex.c       - (generated file from cobclex.l)
cobclex.h       - lexical analysis header file
cobclex.l       - lexical analysis
cobconst.h      - Compiler constants (used in preprocessor and main compiler)
cobcmsg.c       - message management routines specific to core compiler
cobcprs.c       - (generated file from cobcprs.tpl via *.y)
cobcprs.tpl     - parser - skeleton file
cobcprs.y       - (generated file from cobcprs.tpl)
cobcpru.c       - parser utilities
cobcpru.h       - parser utilities header file
cobcsymn.h      - (generated file from cobcsymn.tpl)
cobcsymn.tpl    - symbol numbers - skeleton file
cobcsyms.h      - (generated file from cobcsyms.tpl)
cobcsyms.tpl    - strings for symbols - skeleton file
cobcsyt.c       - symbol table management
cobcsyt.h       - symbol table management header
cobctkt.h       - (generated file from cobctkt.tpl)
cobctkt.tpl     - token types (language dial;ect affinity) - skeleton file
cobctok.def - all the variable data associated with symbols and tokens,
used with the .tpl files to generate many token related files

cobd2u.c        (generated file from cobd2u.l)
cobd2u.l        DOS to Unix text file conversion utility
cobdebug.h      Assorted debug definitions - place to turn off COB_ASSERTs
cobe2a.c        (generated file from cobe2a.l)
cobe2a.l        EBCDIC to ASCII conversion utility
cobe2ax.h       EBCDIC to ASCII conversion table
cobf2v.c        (generated file from cobf2v.l)
cobf2v.l        Fixed to variable length file conversion utility

cobol.el        Emacs text editor editing mode for COBOL.
cobol.texi      Texinfo format manual 
cobol_*.html    HTML files generated from cobol.texi

cobp*           COBOL Preprocessor (COPY, REPLACE, continuations etc):
cobplex.c       - (geenerated file from cobplex.l)
cobplex.h       - lexical analyser for preprocessor header
cobplex.l       - lexical analyser for preprocessor
cobplx2.h       - (generated file from cobppr1.y via cobppr1.h - token values)
cobpmsg.c       - message management routines specific to preprocesor
cobppr1.c       - (generated file from cobppr1.y - parser code)
cobppr1.h       - (generated file from cobppr1.y - token values)
cobppr1.y       - preprocessor parser
cobppr1b.h      - production names used in preprocessor parse tree
cobpprs1.sed    - 'sed' script to convert cobppr1.h into cobplx2.h
cobppru.c       - preprocessor parser utilities
cobpre.c        - preprocessor main
cobpre.h        - preprocessor main header
cobpre1.c       - preprocessor phase 1

cobr*           Runtime routines used by compiler generated code.

cobr_bin128.h    - 128 bit support header
cobr_bin128LLL.c  - 128 bit signed support
cobr_bin128LLL.h  - 128 bit signed support header
cobr_bin128ULLL.c - 128 bit unsigned support
cobr_bin128ULLL.h - 128 bit unsigned support header
cobr_bin128_readme.txt - doco on the 128 bit support

cobr_decbin.c - decimal to bniary conversion routines
cobr_decbin.h
cobr_decbin.readme.txt
cobr_decbin128.c - 128 bit not working yet
cobr_decbin16.c - 16 bit
cobr_decbin32.c - 32 bit
cobr_decbin64.c - 64 bit
cobr_decbxx.h   - skeletons used by specific size routines

cobr_display.c  - display routines
cobr_display.h  - header for display routines

cobr_stop.c  - stop routines
cobr_stop.h  - header for stop routines

cobr_editMove.c  - move with edit
cobr_editMove.h  - header for move with edit

cobr_globals.c - common runtime routines - error message
cobr_globals.h

cobr_temp_config.h - temp int sizes until we get configure all set up

cobu2d.c        (generated file from cobu2d.l)
cobu2d.l        Unix to DOS text file conversion utility

cobumem.c       Memory management routines
cobumem.h       Memory management routines header
cobumsc.c       Miscellaneous routines
cobumsc.h       Miscellaneous routines header
cobumsg.c       Message management routines
cobumsg.h       Message management routines header

cobutab.c       (generated file from cobutab.l)
cobutab.l       Untab utility routine

cobutil.c       Various compiler utility routines - being phased out
cobutil.h       Compiler utility routines header

config-lang.in  Instructions to configure on building the make files - including which make files to build

filter.lhs      Haskell program originally used to build cobctok.def

index.html      Web page for Source Forge project Cobol For GCC

lang-options.h  List of unique options for COBOL, included into toplev.c
lang-specs.h    Specifications of how to call the COBOL compiler from the gcc master driver.

test_cobutil.c  Program to test various compiler utility routines
test_cobr_bin128.c Test driver for 128 bit binary routines
test_cobr_bin128_debug.c Test driver for 128 bit binary routines debug
test_cobr_bin128_debug.h Test driver for 128 bit binary routines debug header

test_cobr_editMove.c Test driver for edit move
test_cobr_display.c Test driver for display
test_cobr_stop.c Test driver for stop run/literal

13.2 Processing Strategy

The compiler usually executes under the control of `gcc' which execs the other components: the preprocessor, the main compiler and then the assembler and linker.

First there is the preprocessor `cobpre', which is analagous to the C preprocessor and takes care of continuation lines, copy, replace, removes comment-entries (like AUTHOR etc) etc. That outputs a new text file that is pretty clean in format, it passes line numbers through.

In the compiler proper, `cobcc1', there is not really a 'pass' concept in the sense that older compilers used it. This was largely a way of managing very limited memory plus magnetic tapes. The flow is basially as follows:

  1. Read the file into memory.
  2. Lexical analysis and keyword detection (dependent on the dialect selected eg pedantic will only recognize ansi standard keywords - see cobclex.l). This outputs a linked list of tokens.
  3. Parse up to procedure divison. This fills in a basic symbol table needed for the hacks that follow. It also creates part of the parse tree.
  4. Hack tokens in procedure division to allow parsing with bison to work (ie magic tokens to give bison some help with what's coming up).
  5. Parse procedure division, completing the parse tree. The parse phase does as little as possible, beyond build the parse tree. See `coibcprs.tpl'.
  6. Build full symbol table, analyse the parse tree to check all references are there and are valid and unique. Minimal work done here at present. See `cobcast.c' for this and the next step.
  7. Convert parse tree into something closer to the gcc TREE concept - ie simplify the constructs into smaller units like move, add, if from the original constructs like search, perform etc. This phase tiny at the moment.
  8. COBOL specific optimization. Nonexistent at present.
  9. Interface to gcc tree to optimize and output the code. See `cobcbei.c'.

So you have access to all the parse information at once, and there should be no issue with being constrained by the number of passes.


Go to the first, previous, next, last section, table of contents.