GnuCOBOL
{{Short description|COBOL compiler}}
{{Multiple issues|
{{mos|date=November 2020}}
{{tone|date=November 2020}}
{{Puffery|date=November 2020}}
}}
{{Use dmy dates|date=November 2019}}
{{Infobox software
| name = GnuCOBOL
| logo = Heckert GNU white.svg
| author = Keisuke Nishida, Roger While
| developer = Edward Hart, Sergey Kashyrin, Ron Norman, Simon Sobisch and many others.
| released = {{Start date and age|df=yes|2002|01|25}}
| latest release version = {{wikidata|property|preferred|references|edit|P348|P548=Q2804309}}
| latest release date = {{Start date and age|{{wikidata|qualifier|preferred|single|P348|P548=Q2804309|P577}}|df=yes}}
| repo = {{URL|sf.net/p/gnucobol/code}}
| programming language = C, with a C++ branch
| size = 2 MB
| website = {{URL|gnu.org/software/gnucobol}}
| language = English, German, Italian, Japanese, Spanish
| genre = Programming language
| license = GPL with runtime libraries under LGPL
}}
{{Portal|Free and open-source software}}
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.{{cite web |url=https://ftp.gnu.org/gnu/gnucobol/README |title=README |website=ftp.gnu.org}}
History
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.{{cite web|last=Tiffin|first=Brian|title=OpenCOBOL FAQ|url=http://opencobol.add1tocobol.com/#what-is-the-current-version-of-opencobol|at=What is the current version of OpenCOBOL?|date=2013-10-19|access-date=2013-12-13}} In late September 2013, OpenCOBOL was accepted as a GNU Project, renamed to GNU Cobol, and then finally to GnuCOBOL in September 2014.{{cite web|last=Tiffin|first=Brian|title=GNU Cobol is now a real thing|url=http://sourceforge.net/p/open-cobol/discussion/109661/thread/e609011b/|access-date=1 October 2013|archive-url=https://web.archive.org/web/20131005013647/http://sourceforge.net/p/open-cobol/discussion/109661/thread/e609011b/ |archive-date=2013-10-05}} 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.{{cite web | url=http://sourceforge.net/p/open-cobol/discussion/cobol/thread/7dc2941f/#40eb | title=Work in Progress | at=GNU Cobol 2.0 C++ | date=6 November 2013 | first=Simon | last=Sobisch | access-date=11 May 2014 | archive-date=10 May 2020 | archive-url=https://web.archive.org/web/20200510184356/https://sourceforge.net/p/open-cobol/discussion/cobol/thread/7dc2941f/#40eb | url-status=dead }}
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.{{cite web|last=Tiffin|first=Brian|title=State of the Project|url=http://sourceforge.net/p/open-cobol/discussion/cobol/thread/7dc2941f/?page=1#3fcf|access-date=23 July 2015|archive-date=7 March 2016|archive-url=https://web.archive.org/web/20160307214237/https://sourceforge.net/p/open-cobol/discussion/cobol/thread/7dc2941f/?page=1#3fcf|url-status=dead}}
The latest current release is v3.2, which was released on 28 July 2023.
Philosophy
{{update|inaccurate=yes|part=number of tests passed (9732 now?), see [https://gnucobol.sourceforge.io/faq/index.html#does-gnucobol-pass-the-nist-test-suite GnuCOBOL FAQ]|date=April 2021}}
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.{{cite web | title=OpenCOBOL FAQ | date=17 October 2013 | access-date=7 June 2014 | quote=While OpenCOBOL can be held to a high standard of quality and robustness, the authors DO NOT claim it to be a “Standard Conforming” implementation of COBOL. | at=How complete is OpenCOBOL? | url=http://opencobol.add1tocobol.com/#how-complete-is-opencobol}} 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.{{cite web|at=Does OpenCOBOL pass the NIST Test Suite?|url=http://opencobol.add1tocobol.com/#does-opencobol-pass-the-nist-test-suite|title=OpenCOBOL FAQ|access-date=9 October 2013}}
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.{{cite web|url=http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf|title=OpenCOBOL Programmer's Guide|publisher=Opencobol.addltocobol.com|access-date=2012-11-20|first=Gary|last=Cutler}}
Documentation
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.{{cite web|url=http://opencobol.org |title=An open-source COBOL compiler |publisher=OpenCOBOL |date= |access-date=2012-11-20}} However, more recent{{when|date=November 2020}} developments have shifted to a SourceForge project space under [https://sourceforge.net/projects/gnucobol/ GnuCOBOL].
The GnuCOBOL Programmer's Guide, by Gary Cutler, was published under the GNU Free Documentation License. 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.{{cite web|url=http://opencobol.add1tocobol.com/guides/|title=GnuCOBOL Guides|publisher=Opencobol.addltocobol.com|access-date=2015-07-22|first=Gary|last=Cutler}} It is currently maintained by Vincent Coen and others as each new compiler version is issued and is available at [https://gnucobol.sourceforge.io/ GnuCOBOL - GNU Project].
Example programs
=Historical=
000100* HELLO.COB GnuCOBOL example
000200 IDENTIFICATION DIVISION.
000300 PROGRAM-ID. hello.
000400 PROCEDURE DIVISION.
000500 DISPLAY "Hello, world!".
000600 STOP RUN.
Compilation and execution:
$ cobc -x HELLO.COB
$ ./HELLO
Hello, world!
=Modern, free format=
- > GnuCOBOL Hello World example
id division.
program-id. hello.
procedure division.
display "Hello, world!" end-display
goback.
Compilation and execution:
$ cobc -x -free hello.cob
$ ./hello
Hello, world!
=Shortest=
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:
display"Hello, world!".
Compilation and execution:
$ cobc -x -frelax-syntax -free hello.cob
hello.cob: 1: Warning: PROGRAM-ID header missing - assumed
hello.cob: 1: Warning: PROCEDURE DIVISION header missing - assumed
$ ./hello
Hello, 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):
program-id.h.procedure division.display "Hello, world!".
Compilation occurs without errors:
$ cobc -x smallest.cob
$ ./smallest
Hello, 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.
Implementation
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:
- choice of C compiler and its options for post translation compilation
- database management system for ISAM support
- inclusion of iconv
Availability
- 1.0 release from SourceForge.{{cite web|author=|url=https://sourceforge.net/projects/open-cobol/files/open-cobol/1.0/ |title=GnuCOBOL - Browse Files at |publisher=Sourceforge.net |date=2007-12-27|access-date=2015-10-28}}
- 1.1 release from SourceForgeGnuCOBOL downloads at SourceForge
- 2.0 development release from SourceForgeGnuCOBOL downloads at SourceForge
- open-cobol Debian package.{{Cite web|url=https://packages.debian.org/stable/open-cobol|title=Debian -- Details of package open-cobol in buster|website=packages.debian.org}}
- 2.2 Final, released 7 September 2017 from SourceForgeGnuCOBOL downloads at SourceForge
- 2.2 Documentation, released September 2017 from the SourceForge Code Tree.
- 3.1 Released July 2020 along with the documentation.
- 3.2 Released July 2023 along with the documentation.
References
{{Reflist}}
External links
- [https://ftp.gnu.org/gnu/gnucobol/ GNU site, official releases of GnuCOBOL]
- {{SourceForge|open-cobol}}
- [http://www.osscons.jp/osscobol Open Source COBOL Consortium in Japan]
- [https://gnucobol.sourceforge.io/faq/ GnuCOBOL FAQ]
- [http://add1tocobol.com Add1ToCOBOL Open Source Cobol and OpenCOBOL advocacy site]
- {{SourceForge|tiny-cobol|tiny-cobol}}
{{DEFAULTSORT:Gnucobol}}