krisds/koopa

Procedure Division using "copybook"?

Closed this issue · 3 comments

Hi Kris (again)

Our code makes considerable use of this construct.

019600* ================================================================
019700 PROCEDURE DIVISION USING
019800 COPY AFU001.
019900* ================================================================

Which causes the parser to barf like this:

Processing D:\data\protect\gp_project_9\REF\cobol\AFF001.CBL
Writing XML to D:\work\source-xref\file-out\AFF001.xml
Error: [AFF001.CBL:186:49|COPY|AFF001.CBL:186:52] @fixed @word @PROGRAM_TEXT_AREA Incomplete parse. Last successful match: byReference < using < header < procedureDivision < programDefinition < sourceUnit < compilationGroup.
Could not parse D:\data\protect\gp_project_9\REF\cobol\AFF001.CBL

Are there any options that I can tweak to have it recognize the construct?

I could pre-resolve the copybooks (which I may have to do in the end anyway so I get a complete parse) but would like to avoid this for as long as possible.

There is no option or toggle you can tweak to fix this, other than enabling preprocessing.

To do it without preprocessing you will have to update the grammar and rebuild Koopa. Adding copyStatement as an extra option in where def using (after line 2150) might do it, depending on where the "dot" for the end of the header appears in your inputs.

If you want to do the grammar tweak and need help, just let me know.

Hi Kris

The grammar looks very Pythonesque which leaves me very curious about the underlying technology (I got the impression it was all Java-based) ultimately we'd want to bolt this on to a Python post-processor so I'm interested to know whether Koopa will run as a native Python App so we don't need to mix technologies.

I'd probably need some guidance on adjusting the grammar as it isn't that intuitive at first glance.

I have also come up with a couple more strange parser failures at least one of them is probably a fault introduced by my pre-processor. So I may well have to come to grips with the grammar expressions so I don't become an inordinate drag on your time.

Would it be more suitable to take this thread outside of the forum? It could become quite protracted should it run it's full course (we have 6.5K COBOL programs to parse).

Cheers
Guy

Hey,

It's all Java. Koopa is a parser generator which bootstraps itself to the point where it can "easily" express a COBOL grammar.

Are you on Sourceforge by any chance ? The Koopa project still has a forum there which might make more sense for discussion. I haven't figured out how to do something similar on github. You should also be able to contact me directly through SF (another option I can't find on GH).