Posts tagged with 'cobol'

Wildcat COBOL 0.1.14 Released

It'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.

Wildcat COBOL 0.1.13 Introduces Sequential File Support

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):

example from fileread.cbl

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.

HIGH VALUES

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:

Wildcat COBOL vs OpenCOBOL

This functionality will be available in version 0.1.13 of the Wildcat COBOL compiler.

tags: cobol, prog

More COBOL Updates

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.

COBOL Syntax Highlighting on OS X

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>

tags: apps, cobol, osx, prog

Wildcat COBOL Compiler Bug Fix

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).

tags: cobol, dotnet, mono

Wildcat COBOL 0.1.10 Released

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:

Unit testing an IF statement in COBOL

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.

Wildcat COBOL Compiler 0.1.9 Released

This is another milestone in the development of the compiler - being able to compile COBOL programs that use GTK#. Again, I believe this may be the first time anyone's written a GTK# program in COBOL. The screenshot below shows the example from Mono's GTK Sharp beginners guide translated into COBOL and running on Mono on OS X.

The compiler can be downloaded from here. Some GTK# COBOL source code will be in the example section soon.

tags: cobol, dotnet, mono

Wildcat COBOL Cocoa Application Support

Today I compiled and ran my first Cocoa# application in COBOL - probably the first time anyone's ever had a working Cocoa# application written in COBOL.

The Wildcat COBOL Compiler now supports referencing packages like mcs does, which made this strange mix of technologies possible. It feels strange running a COBOL .NET GUI application on OS X.

The updated compiler and source is available here and the example is available here. Here's a screenshot of my Cocoa# test application running:

Cocoa# Test App

Compiling if Statements

I hadn't realised that explaining how a COBOL "IF x AND y" statement translates into CIL code differs from a simple "IF x" one from the compiler's point of view could be the subject of a multi-thousand word essay. Sitting at 500 words of bullet points and code snippets here, with no solution yet. This is *NOT* over-documenting - it's barely touching on the complexities of implementing conditional statements in a compiler for a high-level language. I just know that the solution will be *MUCH* simpler than the explanation though.

tags: cobol, prog

Towers of Hanoi with Wildcat COBOL .NET

Tonight I got the Towers of Hanoi from kernelthread.com compiling with the Wildcat COBOL .NET compiler. I've packaged up version 0.1.6 of the compiler which can be downloaded from here, and the release notes are here.

Wildcat COBOL Compiler 0.1.5 Released

The Wildcat COBOL compiler has been updated so that all math operations are implemented, although rounding and error handling are not finished yet. The latest release includes this update, the NUnit tests for the changes, and a version of Hello World using classes from the .NET framework which has been tested on Microsoft .NET, Mono and Portable.NET. This release also has improved compiler error handling. The development of the compiler is now taking a test-driven approach as support for NUnit progresses.

tags: cobol, dotnet, mono

NUnit Tests with COBOL .NET

After adding experimental support for using .NET classes and attributes in COBOL source code, and some playing around with System.Reflection, I was able to get the Wildcat COBOL Compiler to compile a program that contains an NUnit test, and run it from NUnit's command line utility.

More information about running NUnit tests for COBOL programs, including example source code and GUI screenshots, is available here.

NUnit with COBOL .NET

I had to add a couple of new things to the COBOL syntax, but kept them in line with what Fujitsu have already done in their NETCOBOL implementation for .NET.

Here is the program I wrote - you can see the simple NUnit test at the end:

000010 IDENTIFICATION DIVISION.
000020 PROGRAM-ID. FRAMEWORK-TEST.
000030 AUTHOR. SANDY DUNLOP.
000040*Testing .NET COBOL Extensions
000050
000060 ENVIRONMENT DIVISION.
000070 CONFIGURATION SECTION.
000080 ATTRIBUTES "TestFixture".
000090 REPOSITORY.
000100     CLASS SYS-STRING AS "System.String"
000125     CLASS SYS-CONSOLE AS "System.Console"
000136     CLASS NUNIT-ASSERT AS "NUnit.Framework.Assert"
000140 DATA DIVISION.
000150 WORKING-STORAGE SECTION.
000160 77 NET-STRING OBJECT REFERENCE SYS-STRING.
000170
000180 PROCEDURE DIVISION.
000190 MAIN-PARAGRAPH.
000200     MOVE "Test Prog" TO NET-STRING
000210     INVOKE SYS-CONSOLE "WriteLine"
000220         USING BY VALUE NET-STRING
000210     STOP RUN.
000230 TEST-PARAGRAPH WITH ATTRIBUTES "Test".
000240     MOVE "teststring" TO NET-STRING
000250     INVOKE NUNIT-ASSERT "AreEqual"
000260         USING BY VALUE "teststring"
000270         USING BY VALUE NET-STRING
000280 END PROGRAM FRAMEWORK-TEST.

I plan on writing some NUnit tests for the compiler now, and making it all available online over the coming week.

99 Bottles of Beer in COBOL .NET

The Wildcat COBOL Compiler for .NET can now compile the 99 Bottles of Beer program, and the output runs perfectly on both Mono and Microsoft .NET. Version 0.1.2 of the compiler is available for download here. The program that I compiled is slightly different to the one I found on the Web - two of the strings in the Working Storage section are defined differently.

Almost There

As of this evening, the Wildcat COBOL Compiler for .NET is now able to compile the 99 Bottles of Beer program, although when executed, the PERFORM loop runs one extra time at the end producing the following output:

Two bottles of beer on the wall, two bottles of beer! Take one down, pass it around, one bottles of beer on the wall!

One bottles of beer on the wall, one bottles of beer! Take one down, pass it around, one bottle of beer on the wall!

One bottle of beer on the wall, one bottle of beer! Take that down, pass it around, no more bottles of beer on the wall!

I'll fix that later when I'm not so tired, and get the next build online.

Wildcat COBOL Compiler 0.1.1

The first Wildcat COBOL compiler for .NET build has been made avialable here this evening. Some more general information is available here. This release has the ability to compile the simple "Hello World" program. I intend releasing another build fairly soon, with more complete support for variable subscripts and substrings - the only things preventing it from compiling the 99 bottles of beer program at the moment.

COBOL .Net Compiling with Types

In my limited spare time, I've managed to add integer and string types to my COBOL compiler for .Net, and also add the ability to type stuff in at the command line. Numbers, strings and things typed in at the command line can now be set as the values of existing variables. The next step will include floating point numbers, the COBOL equivalent of structs, and maybe some maths.

Click the image to watch the flash movie...

Compiling COBOL for .Net

I spent a little time this evening beginning to write my .Net COBOL compiler. After that, I played around with software for recording what I'm doing on my desktop and saving it as a Flash movie. Click on the image below to view a quick preview of the compiler in Flash...