Dan:

You do not need the full "parser" for ILE RPG IV in order to strip out comments.

Just create a "filter" -- a program that makes one pass over the source code, writing the code without any comments to a temporary source file member (e.g. in QTEMP), and then scan that for what you are looking for.

The rules for RPG IV comments are pretty simple:

First, strip anything beyond column 80, that is, overlay that with blanks, as those are always comments for "fixed form" RPG.

Start scanning in column 6.

If column 6 contains a " " (blank space) then the line is in "free form" ...

If column 6 contains an "*" then the entire line is a comment line -- either suppress the line entirely or just print a blank line.

If column 6 contains a non-blank (F, I, D, C, etc.) then if column 7 contains an "*" the entire line is a comment line -- either suppress the line entirely or just print the line up through column 7.

Scan from left to right, starting at column 7, for "//" and if you find it, blank out the "// and everything to the end of the line, then write out that line.

Repeat the above for each source line in the input member, creating a temporary member to be scanned "without comments" ...

Now, scan that using whatever tool(s) you want.

"And, Bob's your Uncle!"

HTH,

Mark S. Waterbury

> On 5/19/2015 11:08 AM, Dan wrote:
Paul: It does not appear that we have TAATOOLS here. At least anything
newer than the V3R0M5 version. (Probably IBM's QUSRTOOL version?)

John: My motivation to do this is that I have to scan about 200 source
members, and there is the likelihood that this will turn into a system-wide
endeavor. (I.e. thousands of source members.)

Kurt mentioned JCRSMLT from JCRCMDS. Getting stuff loaded on our dev box
is such a PITA here, so I reviewed the source code online. It appears that
the option to omit comment lines is limited to RPG, and then only for an
asterisk in column 7 or a '//' in columns 7-8. If anyone knows that I am
wrong about that, please let me know, and I'll review it again.

Roger, Evan: I cross-posted this to WDSC-L, thinking that the iSphere
plug-in for RDi might support something like this. Buck Calabro offered up
a search function using egrep and grep. It all looks Greek to me, although
Buck seems to do a nice job breaking it down for understanding what's going
on.

I wonder if IBM could be persuaded to share the code it uses to validate
code syntax, specifically how it distinguishes between comments and live
code. I would be happy to be able to read an original source member and
have something that dumps only the live code into a new (temporary) member
for further analysis.

If this is a wheel that needs to be invented, I'd be happy to be involved
in an open source project to do it, but from the looks of the regular
expressions using grep / egrep, I'd be more of a cheerleader than a main
contributor.

- Dan


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.