— The Name in Software
Engineering Automation
The following example used an XTRAN rules file comprising 166 non-comment lines of "meta-code" (XTRAN's rules language) to highlight PL/I code involved with either file or terminal I/O, rendering the code as HTML for coloring. The rules took about four hours to create and debug. They are not particularly specific to PL/I; they can easily be adapted to do the same for any 3GL language.
Note that the rules infer file or terminal I/O usage of a variable to which a value is assigned that contains any variables of either type.
The following is an English paraphrase of the XTRAN rules used for this example:
Specify HTML as module rendering "decoration" prefix and suffix
Specify HTML as statement rendering "decoration" prefix and suffix,
according to statement's I/O involvement if any
Specify HTML as expression rendering "decoration" prefix and suffix,
according to expression's I/O involvement if any
For each PL/I statement
If DISPLAY or ACCEPT statement
Mark statement as "terminal I/O"
Mark all variables in statement as "terminal I/O"
Else if CLOSE, OPEN, READ, or WRITE statement
Mark statement as "file I/O"
Mark all variables in statement as "file I/O"
While variables to mark
For each PL/I statement
If assignment statement
If right side has "file I/O" and/or "terminal I/O" variables
If left side not already marked
Mark left side as such
Render code; XTRAN will decorate it as specified
The input to and output from XTRAN are untouched.
prc: PROC (dspio1, filio1);
DCL (dspio1, dspio2) FIXED BIN (31);
DCL (filio1, filio2, filio3) FIXED BIN (31);
DCL (bthio1, bthio2) FIXED BIN (31);
DCL (neither1, neither2) FIXED BIN (31);
DCL file1 FILE;
DISPLAY ('First argument is ' || dspio1);
dspio2 = dspio1;
OPEN FILE(file1) INPUT TITLE('foo');
READ FILE(file1) INTO(filio1);
filio2 = filio1 + 1;
bthio1 = bthio1 + filio1;
neither1 = 1;
neither2 = neither1 + 1;
IF (filio2 > filio3) THEN
filio3 = filio2;
bthio1 = dspio1;
bthio2 = filio1 + bthio1;
dspio1 = neither2;
CLOSE FILE(file1);
RETURN;
END prc;
prc: PROCEDURE (dspio1, filio1);
DCL (dspio1, dspio2) FIXED BIN (31);
DCL (filio1, filio2, filio3) FIXED BIN (31);
DCL (bthio1, bthio2) FIXED BIN (31);
DCL (neither1, neither2) FIXED BIN (31);
DCL file1 FILE;
DISPLAY ('First argument is ' || dspio1);
dspio2 = dspio1;
OPEN FILE(file1) INPUT TITLE('foo');
READ FILE(file1) INTO(filio1);
filio2 = filio1 + 1;
bthio1 = bthio1 + filio1;
neither1 = 1;
neither2 = neither1 + 1;
IF filio2 > filio3
THEN
filio3 = filio2;
bthio1 = dspio1;
bthio2 = filio1 +
bthio1;
dspio1 = neither2;
CLOSE FILE(file1);
RETURN;
END prc;
COPYRIGHT 2012; reproduction prohibited without permission. Revised 2009-09-11
XTRAN is a trademark of Pennington Systems Incorporated.
|
Pennington Systems Incorporated 2820 N. Pinal Avenue, Suite 12 Casa Grande, Arizona 85122-7927 USA |
Phone: +1(480)626-5503 Fax: +1(480)626-7618 Email: Info@Pennington.com Web: http://WWW.Pennington.com |