Wildcat Cobol Compiler for .NET
home | about | docs | feedback | download | launchpad project
An open-source COBOL compiler for .NET and MonoSandy Dunlop
A 27 year old software consultant living in Glasgow.
IRC: jaavaaguru on irc.freenode.net
Email: sandy@sorn.net
home | about | docs | feedback | download | launchpad project
An open-source COBOL compiler for .NET and MonoIt's been 3 and a half months since the last release. During that time I've moved to a new flat, and been pretty busy with work, so haven't had a lot of time to work on the COBOL compiler.
This release introduces support for writing sequential data files. My target for this release was to have it compile the example "students.cbl" from the University of Limerick's Intorduction to Sequential Files correctly. I came across one issue in doing this: The tutorial has a PERFORM loop specified as:
PERFORM UNTIL StudentRec = SPACES
I've been following IBM's VS COBOL II grammar which doesn't cover non-arithmetical relational conditions in PERFORM loops. My code which makes this work is not the most elegant solution, but it does get the job done.
Version 0.1.14 of the Wildcat COBOL Compiler is available in both source and binary form here.
The other thing that's been taking up my time recently is the experimentation I've been doing with version control software (aka source code management software). Over the past 4 weeks, I've been using Bazaar a lot. It's the version control software used by Canonical's Launchpad. I have created a project on Launchpad for the Wildcat COBOL compiler.
It's that time again - a new version of the Wildcat COBOL Compiler for Mono and .NET is out. Version 0.1.13 introduces experimental support for reading sequential data files, and making use of level 88 data definitions. I'll explain these advances in some more detail...
Consider the following excerpt from the fileread.cbl program which is included in the version 0.1.13 ZIP file (click to enlarge):
This code opens a file, and reads the first line. This data is stored in the StudentFile record which has been declared in the FILE SECTION of the DATA DIVISION. The code then loops until EndOfStudentFile evaulates to be true. EndOfStudentFile was declared as a level 88 member of the StudentFile record. Level 88 is special in that it can be used to store and test for certain conditions. Here, it is used to indicate whether or not the end of the sequential data file has been reached.
Inside the loop, the DISPLAY statement prints out the values of some parts of the StudentFile record, then the next record is read from the file, until the end of the file has been reached. When the end is reached, EndOfStudentFile is set to true, and the loop exits.
The READ statement can have "AT END" and "NOT AT END" sections inside it, which specify code to execute when each of those conditions is true.
This diagram shows the logic the compiler uses when compiling READ statements:
The code used in this example is based on Introduction to Sequential Files from the University of Limerick.
Tonight I started implementing file I/O in the Wildcat COBOL Compiler for .NET. One of the examples I was testing my implementation against used the HIGH-VALUES keyword. I decided to implement this before continuing with file I/O as it provided a way for this particular example to deal with a boolean value. I derived a test program from the example, and tested in both the Wildcat COBOL compiler and in OpenCOBOL. Thankfully, both produced the same result:
This functionality will be available in version 0.1.13 of the Wildcat COBOL compiler.
Version 0.1.12 of the Wildcat COBOL compiler is out now, with bug fixes in the handling of complex IF statements, and support for all relation operators.
Pieter Baele has been working on a COBOL syntax highlighting bundle for TextMate and I have started putting together a COBOL syntax highlighting definition file for Smultron.
To make Smultron use this syntax highlighting, you will need to put this file into /Applications/Smultron.app/Contents/Resources/Syntax Definitions and add the following text into /Applications/Smultron.app/Contents/Resources/SyntaxDefinitions.plist:
<dict>
<key>name</key>
<string>COBOL</string>
<key>file</key>
<string>cobol</string>
<key>extensions</key>
<string>cbl cob</string>
</dict>
The first bug has been reported by Pieter. There was an assembly missing from the list of files to be included in the binary release. The makefile has now been corrected and version 0.1.11 has been made available with the missing assembly included in the ZIP file. This problem affects all releases from 0.1.7 to 0.1.10. The symtpoms of the problem are this error message being displayed when trying to compile COBOL programs:
** (/usr/local/lib/cobolc/cobolc.exe:26939): WARNING **: The following assembly referenced from /usr/local/lib/cobolc/cobolc.exe could not be loaded:
Assembly: Wildcat.Cobol.Compiler.References (assemblyref_index=1)
Version: 0.0.0.0
Public Key: (none)
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/usr/local/lib/cobolc).
This release now includes support for use of AND and OR in IF statements. The amount of language features remaining to be implemented before the compiler is actually useful is getting smaller :-)
As always, the latest release if available here.
The release includes updates to the NUnit tests for testing if statements like this:
Writing the rest of the IF statement unit tests will be boring, but will ensure that future changes don't break anything. I also plan on making sure the rest of the NUnit Assert methods work, as I've not used many of them yet in COBOL.