Reputation: 347
I am working on a project to automate COBOL to generate a class diagram. I am developing using a .NET console application. I need help tracking down the procedure name where the perform statement in used in the below example.
**Z-POST-COPYRIGHT.
move 0 to RETURN-CODE
perform Z-WRITE-FILE**
How do I track the procedure name 'Z-Post-COPYRIGHT' where the procedure 'Z-write-file' is called? The only idea I could think of in terms of COBOL is through indentation as the procedure names are always indented. Ideally in the database, the code should track the procedure name after the word 'perform' and procedure under which it is called (in this case it is Z-POST-COPYRIGHT).
Upvotes: 0
Views: 525
Reputation: 7297
I assume you want to do this "on your own" without external tools (a faster approach can be found at the end).
You first have to "know" your source:
Then you have to preparse the source:
REPLACING
rules if any)-
in column 7REPLACE
and change the result accordingly*
and \
in column 7 in fixed-form reference format or similar (extensions like "variable" format / "terminal" format", ... exist, maybe only inline comments - when in free-form reference-format, otherwise maybe inline comments *>
or compiler specific extensions like |
) - depending on the further re-engineering you want to do it could be a good idea to extract them and store them at least with a line number referenceThe you finally can track the procedure name with the following rule:
Start from here and check the output, then fine grade the rule with actual false positives or missing entries.
If you want to do more than only extract the procedure-names for PERFORM
and GO TO
(you should at least check the sources for PERFROM ... THRU
) then this can get to a lot of work...
Faster approach with external tools:
Just a note: You may want to check GnuCOBOL (formerly OpenCOBOL) for the preparsing and/or generation of symbol tables/cross-reference and/or printcbl for a completely external tool doing preparsing and/or cobxref for a complete cross reference generation.
Upvotes: 1