Go to Home page Contact us Send email to us We respect your privacy
Our Consulting services Our Java software Our AS/400 software Current page is Windows software


Introduction
Construct Files
Transform Files
Small Example
Larger Example
Command Line
Typical Uses
Downloads
History

PSPZap Larger Example

In this example, old-style comments in C++ code are converted to a consistent style. The same file is used for source construct and target construct in this case.

Input Data: (C++ source with comments only)

// Comment 1 - single line
/* Comment 2 - single line */
/* Comment 3
- multi-line */

Output Data: (C++ source with revised comments)

// Comment 1 - single line
// Comment 2 - single line
/*
 Comment 3
- multi-line
*/

As you can see, the single line comments in the old style /* */ have been converted to the new style //. Multi-line comments are preserved intact, but the /* */ delimiters are on separate lines. This change is achieved using the construct and transform records below.

Source Construct and Target Construct (same file used for both):

OldStart

1

0 0 0

{D(047042)}
OldEnd

1

0 0 0

{D(042047)}
NewStart

1

0 0 0

{D(047047)}
Other

1

0 0 0

{D(001/255)(1,n)}

OldSingle

1

0 0 0

{(OldStart)}{(Other)(0,n)}{(OldEnd)}

OldMulti

9999

0 0 0

{(OldStart)}{(Other)(0,n)}{(OldEnd)}
NewSingle

1

0 0 0

{(NewStart)}{(Other)(0,n)}

The first three records above identify the critical characters denoting the start/end of C++ comments. The fourth record picks up every remaining character i.e. any character with an ASCII code in the range 001 to 255. The final three records identify entire comments of the three types (old style single line, old style multi-line, new style single line).

Transform:

Z OldStart OldStart {T1}
Z OldEnd OldEnd {T1}
Z NewStart NewStart {T1}
Z Other Other {S1}
Mult Other Other {S1}[L1]
Z OldSingle NewSingle {T1}{S2}[L1]
Z NewSingle NewSingle {T1}{S2}[L1]
Z OldMulti OldMulti {T1}[L1]{S2(Mult)}{T3}

The same construct descriptions appear in each of the records above except the sixth record, which specifies that the OldSingle construct in the input file is to be converted to a NewSingle construct in the output file.

Of course any source code (C++, Java etc.) is more complicated than this. But the above example shows how a relatively small set of PSPZap construct/transform records can still do a fairly significant data conversion. As always, the PSPZap User Guide provides much more detail on how you define construct/transform records and their components.