July 07, 2010

Koopa 1up

I just updated the Koopa Cobol Parser with a new version. It now supports parsing Cobol code in either fixed format or free format. Don't know what I'm talking about ? Here are the definitions as found on COBOLPortal:

Fixed Format Source - Each COBOL source line consists of 80 characters which are divided into various fixed areas. There are restrictions on the syntax that can appear in each area.
Free Format Source - Each COBOL source line can consist of up to 250 bytes of characters. There is no restriction on where syntax may appear on the line.

I don't restrict lines to either 80 characters or 250 bytes (note the difference in units btw.), but other than that it should be as described.

The GUIs and the command line application have been updated to give the user the choice of which Cobol format to use. Default is fixed. Just pick what you want in the "Parser settings" menu, or by passing "--free-format" as an option on the command line.

As usual there is an executable jar available on the sourceforge project page.

8 comments:

Crimson13 said...

Pitty I won't learn Cobol just to try out Koopa :-)

KrisDS said...

Hey, it's your loss for not learning this great and ancient language. Really, it's like the Elvish of the programming languages.

Well, maybe more like the dwarvish of the programming languages. ;-)

dk said...

I would like an example of how to use it that works. I can not even get it to open the hello world-cobol program from wikipedia...

IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, world'.
STOP RUN.

It fails with
Error: [1:22|DIVISION|1:29] Not all input was consumed.

Although I am not a cobol programmer I think that ought to work.

I need a parser to do some static analysis of cobol code I do not want to read, I prefer writing java to reading cobol. :-)

KrisDS said...

Hello dk,

Yes, that example should work just fine. Here are the steps:

1. Download the executable jar.
2. Run it by double clicking the jar.
3. Go the parser settings menu and pick "Free format". (Guessing here based on the example and the error you got.)
4. Go to the file menu and choose "pick and parse".
5. Navigate to the file you want to see parsed and click ok.
6. Done.

You can then double-click the result to see the contents of the Cobol file with syntax highlighting and an outline.

Let me know if this doesn't work for you. I tested it on my machine with the wikipedia example, and it works fine here.

dk said...
This comment has been removed by the author.
dk said...

Hello.

I got that to work from the command line. The code I have a large amount of (and can not show you here) lacks the six spaces in the beginning of the lines. I think it is some kind of HP/Compaq-COBOL for VMS.

As said, it does work when I run the cli-version (java -cp koopa.jar koopa.app.cli.ToXML --free-format hello_world.sco hw.xml), but not from the GUI. The cli version does not work on real code, alas. It usually dies on the last point in some early division declaration, eg a line like "procedure division using FOO BAR." or "program-id. FOOBAR.".

KrisDS said...
This comment has been removed by the author.
KrisDS said...

Note: Moved this discussion off-line.