Page 1 of 2

Re:Creating a tool for Cobol standards

PostPosted: Mon May 09, 2016 9:12 pm
by balacsv1
Hello everyone,

I am quite new to REXX and I am assigned to develop a rexx tool which should check if the programmer has followed cobol standards. In the process I need to check the following for which I need some help and your valuable inputs
a)A Para must have a period only at the end of it, I need to find a way to identify if it's not followed
b)All the paragraphs must have an exit Para with an exit statement
C)usage of negative conditional statements need to be identified.

Looking forward to your inputs or ideas.

Re: Re:Creating a tool for Cobol standards

PostPosted: Mon May 09, 2016 9:16 pm
by enrico-sorichetti
Looking forward to your inputs or ideas.


good luck !

if You are new to rexx You have been assigned a task above Your skill level

anyway ...
first the logic,
after that the coding

Re: Re:Creating a tool for Cobol standards

PostPosted: Mon May 09, 2016 9:37 pm
by Pedro
1. read the program using EXECIO and save to a stem variable.

2. make multiple passes through all of the program statements. The first pass is to remove any comments. That is, replace with blanks. I have had problems with language keywords being in comments. Possibly also translate other statements to uppercase.

3. Use a 'Do' loop to scan all program statements.

4 Examine each program statement. Use the POS() built-in function to see if a particular keyword is in the current statement. Then use PARSE to look for proper syntax.

Re: Re:Creating a tool for Cobol standards

PostPosted: Mon May 09, 2016 10:14 pm
by Robert Sample
I am quite new to REXX and I am assigned to develop a rexx tool
Sigh. The rule of thumb I was taught in college classes is that writing a tool is 3 times as hard as writing an application program, and writing a compiler is 3 times as hard as writing a tool. This is assuming, of course, that the tool will be generic and usable by everyone in the applications development group at your site. How much experience do you have in writing COBOL programs?

And are you going to be checking for NEXT SENTENCE as well in your tool?

Re: Re:Creating a tool for Cobol standards

PostPosted: Mon May 09, 2016 10:23 pm
by balacsv1
Hi Robert,
I have an experience of around 5+ years in writing cobol programs,just that I am new to REXX. Nope I am not going to check NEXT SENTENCE in my tool

Re: Re:Creating a tool for Cobol standards

PostPosted: Mon May 09, 2016 10:24 pm
by balacsv1
Hi Pedro,
Thanks a lot for your inputs. will try implementing it and let u know

Re: Re:Creating a tool for Cobol standards

PostPosted: Tue May 10, 2016 12:31 am
by prino
Parsing COBOL is actually pretty easy.You could do worse than start with File # 769 R. Prins' edit macros to convert code/text into HTML...

Re: Re:Creating a tool for Cobol standards

PostPosted: Tue May 10, 2016 3:42 am
by BillyBoyo
I always point out it is easier to use the listing - or even request the ADATA output from the compiler, although for your three tasks that is perhaps overkill.

The negation is easy. After proceeding with the listing following Pedro's scheme, the only negation possible is NOT and FALSE (for EVALUATE).

For the exit-paragraph being present (assuming the programs don't also have multiple other paragraphs) you just match pairs of paragraph-names on the cross-reference. The cross-reference will note those that are used in a PERFORM so you can even check that the THRU exists from that.

The easiest part is the full-stops/periods. Count them all, starting from the PROCEDURE DIVISION header. That has one. Each paragraph-name has one. Then you should have one for each paragraph (so you know how many to expect). Any deviation from the expected total means more than one in a paragraph. You don't have to worry about a paragraph not having one, because that gives a compiler diagnostic anyway.

Have to point out that not using negation and using THRU are both... unnecessary. But fairly common.

Robert's point about the NEXT SENTENCE is worth following up on. If you only allow one full-stop/period per paragraph you definitely need to check no-one is using NEXT SENTENCE.

Re: Re:Creating a tool for Cobol standards

PostPosted: Tue May 10, 2016 5:00 pm
by balacsv1
Hi Pedro,

I followed your inputs and I am able to create the basic structure of the program,My tool is able to identify missing end-if's and end-exec's right now :-) Will work on further,thank you :-)

Re: Re:Creating a tool for Cobol standards

PostPosted: Tue May 10, 2016 5:09 pm
by balacsv1
Hi Billy,
Thanks for taking the time out.

"The easiest part is the full-stops/periods. Count them all, starting from the PROCEDURE DIVISION header. That has one. Each paragraph-name has one. Then you should have one for each paragraph (so you know how many to expect). Any deviation from the expected total means more than one in a paragraph. You don't have to worry about a paragraph not having one, because that gives a compiler diagnostic anyway."
I need to identify the paragraph having multiple periods as well,Coz I am writing the discrepancies in a report and it would be better for me to write the para name there.

Your's and Robert's point about NEXT SENTENCE is very valid,I will probably add it