Menu

REPLACE COPY

Help
2014-07-29
2014-07-29
  • Stefan Reisner

    Stefan Reisner - 2014-07-29

    Hi Kris,

    thanks for your great project and your continued support. Now to my question.

    Koopa (r161) gets confused by statements like the following that occur in many of the source files I am trying to process:

    100000 REPLACE COPY cccccccc. .

    Not being very well versed with COBOL, I roughly understand that this is due to the fact that Koopa does not actually substitute the copybook before parsing the REPLACE statement. However, I saw you mentioning a preprocessor in some older forum post.

    Should I try to modify the grammar to accommodate the REPLACE COPY syntax, should I substitute the copybook before passing the source to Koopa, or is a solution on your part coming up already? I should mention that I don't own the COBOL sources, so I cannot modify them (moving the REPLACE into the copybook was recommended for a similar issue with some other COBOL parser).

    Maybe I should explain a little bit what I'm trying to achieve here. I would like to convert the ASTs into an ontology in order to be able to apply automated reasoning about aspects like module dependencies, data flows, and maintainability issues.

    BTW: do you have any plans of turning Koopa into a Maven project? That would make it so much easier to integrate it into other projects.

    Best regards
    Stefan

     
  • KrisDS

    KrisDS - 2014-07-29

    Hi Stefan!

    Thanks for the kind words. Your use case is pretty much what I orginally started Koopa for. Your constraints sound pretty familiar. :-)

    Yes, there is an experimental preprocessor in Koopa. If you look for the Cobol85PreprocessingTest class, you'll see an example of how to set this up. Beware though that this does not do any replacing of tokens yet; so far it's a verbatim include.

    You could also try modifying the grammar. If you go that road I would suggest adding an catch-all alternative to data descriptors. Something like

    levelNumber (--> .) .
    

    (I prefer that over trying to place "copyStatement" all over the grammar.)

    Alternatively (depending on the source code you're working with) you could also do a simple grep/replace before throwing it at Koopa.

    As for Maven, I have considered it several times. Problem is I need a lot of what ANT offers and Maven does not have. So I would be doing a lot of ANT in Maven itself, which kind of defeats the purpose.

    Cheers,

    Kris

     

Log in to post a comment.

MongoDB Logo MongoDB