GnuCOBOL | |
Author: | Keisuke Nishida, Roger While |
Developer: | Edward Hart, Sergey Kashyrin, Ron Norman, Simon Sobisch and many others. |
Programming Language: | C, with a C++ branch |
Size: | 2 MB |
Language: | English, German, Italian, Japanese, Spanish |
Genre: | Programming language |
License: | GPL with runtime libraries under LGPL |
GnuCOBOL (formerly known as OpenCOBOL, and briefly as GNU Cobol) is a free implementation of the COBOL programming language that is part of the GNU project. GnuCOBOL translates the COBOL code into C and then compiles it using the native C compiler.[1]
While collaborating with Rildo Pragana on TinyCOBOL, Keisuke Nishida initiated the development of a COBOL compiler designed for integration with GCC, which led to the creation of the OpenCOBOL project. Nishida served as the lead developer until 2005, up to version 0.31. Roger While succeeded him as the lead developer and released OpenCOBOL 1.0 on December 27, 2007. Development on the OpenCOBOL 1.1 pre-release continued until February 2009. In May 2012, active development transitioned to SourceForge, and the February 2009 pre-release was officially marked as a release.[2] In late September 2013, OpenCOBOL was accepted as a GNU Project, renamed to GNU Cobol, and then finally to GnuCOBOL in September 2014.[3] Ron Norman contributed a Report Writer module as a branch of GnuCobol 2.0, and Sergey Kashyrin developed a version that uses C++ intermediates instead of C.[4]
Transfer of copyrights to the Free Software Foundation over GnuCOBOL source code (including versions with GNU Cobol and OpenCOBOL spellings) was finalized on 17 June, 2015.[5]
The latest current release is v3.2, which was released on 28 July 2023.
While aiming to adhere to COBOL standards, including the COBOL 2014 specification and features commonly found in existing compilers, the developers do not assert any formal level of standards conformance.[6] Nevertheless, the 2.2 final release successfully passes 9,688 out of 9,708 tests (99.79%) from the NIST test suite, with 20 tests excluded.[7]
GnuCOBOL translates a COBOL program (source code) into a C program. The C program can then be compiled into the actual code used by the computer (object code) or into a library where other programs can call (link to) it. On UNIX and similar operating systems (such as Linux), the GNU C compiler is used for this process. On Windows, the C compiler provided by Microsoft's Visual Studio Express package is used. Although the two-step compilation process is typically performed with a single command, an option is available to halt the process after the C code has been generated.[8]
From 2002 until 2012, the official home of the development team was the opencobol.org website, which served as the primary source of upstream development information.[9] However, more recent developments have shifted to a SourceForge project space under GnuCOBOL.
The GnuCOBOL Programmer's Guide, by Gary Cutler, was published under the GNU Free Documentation License.[8] It has been updated to include GnuCOBOL with Report Writer and is listed in the GnuCOBOL documentation overview page with latest versions in the code tree.[10] It is currently maintained by Vincent Coen and others as each new compiler version is issued and is available at GnuCOBOL - GNU Project.
id division.program-id. hello.procedure division.display "Hello, world!" end-displaygoback.Compilation and execution:
$ cobc -x -free hello.cob$ ./helloHello, world!
The shortest valid COBOL program, with the relaxed syntax option in GnuCOBOL 2.0, is a blank file. Compilation and execution:
$ cobc -x -frelax-syntax ./empty.cob./empty.cob: 1: Warning: PROGRAM-ID header missing - assumed$ ./empty$ For earlier versions and with relaxed syntax:
$ cobc -x -frelax-syntax -free hello.cobhello.cob: 1: Warning: PROGRAM-ID header missing - assumedhello.cob: 1: Warning: PROCEDURE DIVISION header missing - assumed$ ./helloHello, world!Without relaxed syntax and with any version of GnuCOBOL, GNU Cobol or OpenCOBOL. (Note, there are 7 leading spaces to conform to FIXED layout COBOL source):
$ cobc -x smallest.cob$ ./smallestHello, world!Please note that these trivia listings are not to be regarded as good COBOL form; COBOL was designed to be a readable English programming language.
The parser and lexical scanner use Bison and Flex. The GPL licensed compiler and LGPL licensed run-time libraries are written in C and use the C ABI for external program linkage.
Build packaging uses the GNU Build System. Standard tests with make check
use Autoconf, ANSI85 testsuite run by make test
use Perl scripts.
The configure script that sets up the GnuCOBOL compile has options that include: