— The Name in Software
Engineering Automation
The following example uses a rule set written in XTRAN's rules language ("meta-code") that finds and suppresses every statement that is "dead" (cannot execute). The rules comprise 147 non-comment lines of meta-code.
NOTE that these rules are language-independent; they are exactly the same rules used for similar examples for other languages.
Strategy:
prc: PROCEDURE;
DCL i FIXED BIN (31);
IF i = 0 | i = 1 THEN
GOTO lbl2;
i = 1;
GOTO lbl3;
/*
* The following code is dead and should therefore be eliminated:
*/
IF i > 1 THEN
GOTO lbl1;
i = 2;
lbl1: i = 3;
GOTO lbl3;
/*
* The following statement is dead and should therefore be eliminated:
*/
i = 4;
lbl2: i = 4;
lbl3: i = 5;
END PRC;
prc: PROCEDURE;
DECLARE i FIXED BINARY (31);
IF i = 0 | i = 1 THEN
GOTO lbl2;
i = 1;
GOTO lbl3;
lbl2: i = 4;
lbl3: i = 5;
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 |