Re:Creating a tool for Cobol standards



IBM's Command List programming language & Restructured Extended Executor

Re:Creating a tool for Cobol standards

Postby balacsv1 » Mon May 09, 2016 9:12 pm

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.
balacsv1
 
Posts: 6
Joined: Mon May 09, 2016 9:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re:Creating a tool for Cobol standards

Postby enrico-sorichetti » Mon May 09, 2016 9:16 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Re:Creating a tool for Cobol standards

Postby Pedro » Mon May 09, 2016 9:37 pm

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.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: Re:Creating a tool for Cobol standards

Postby Robert Sample » Mon May 09, 2016 10:14 pm

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?
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Re:Creating a tool for Cobol standards

Postby balacsv1 » Mon May 09, 2016 10:23 pm

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
balacsv1
 
Posts: 6
Joined: Mon May 09, 2016 9:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re:Creating a tool for Cobol standards

Postby balacsv1 » Mon May 09, 2016 10:24 pm

Hi Pedro,
Thanks a lot for your inputs. will try implementing it and let u know
balacsv1
 
Posts: 6
Joined: Mon May 09, 2016 9:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re:Creating a tool for Cobol standards

Postby prino » Tue May 10, 2016 12:31 am

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...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: Re:Creating a tool for Cobol standards

Postby BillyBoyo » Tue May 10, 2016 3:42 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Re:Creating a tool for Cobol standards

Postby balacsv1 » Tue May 10, 2016 5:00 pm

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 :-)
balacsv1
 
Posts: 6
Joined: Mon May 09, 2016 9:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re:Creating a tool for Cobol standards

Postby balacsv1 » Tue May 10, 2016 5:09 pm

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
balacsv1
 
Posts: 6
Joined: Mon May 09, 2016 9:00 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post