Apparatus and program

This apparatus is provided with a storage device and a CPU. The storage device has two or more modules stored therein. The CPU acquires, from the storage device, a first module and a second module from among the modules stored in the storage device. Furthermore, the CPU creates a message that indicates whether a hierarchical structure of the first module matches a hierarchical structure of the second module.

TECHNICAL FIELD

This invention relates to an apparatus which compares two modules (source programs) each including one or more sentences written in a programming language.

BACKGROUND ART

In general, a program tends to be used for a long time while being repeatedly maintained. In many cases, program maintenance is performed to change function of a program. In addition, a program is sometimes maintained so as to be adapted to replacement of an environment in which the program is used, wherein the environment is, for example, a hardware that is a platform of the program, an operating system (OS) or a middleware. Moreover, a program is sometimes maintained so as to be adapted to replacement of a programming language describing the program. Thus, such maintenance that is not intended to change function of a program (hereafter, such maintenance is referred to as “conversion”) is sometimes carried out.

When such conversion of a program is required, every sentence of the program needs to be examined whether some change is necessary or not, and subsequently, modification should be applied only to the sentences necessary to be changed. However, there are many systems each of which includes programs whose total sum of sentences is over one million. It is not easy in such a system to correctly carry out the conversion. Moreover, it is not easy to verify whether the conversion is correctly carried out or not. Moreover, not limited to the conversion, and regardless of the size of a system, it is not easy to verify whether a program maintenance is correctly carried out or not.

In order to verify whether a program maintenance is correctly carried out or not, there is a general technique of comparing programs before and after maintenance to find out parts different from each other. For example, Patent Document 1 discloses a program difference detecting apparatus which compares token arrangements generated from respective programs before and after maintenance to find out different parts of the respective programs before and after maintenance. The tokens of Patent Document 1 include reserved words, character constants, etc. According to Patent Document 1, since the program difference detecting apparatus finds out different parts of respective programs with use of the arrangement of such tokens, the program difference detecting apparatus can find out the different parts not based on syntactic difference such as difference in starting column of a sentence but based on semantic difference.

PRIOR ART DOCUMENTS

Patent Document 1: JP A 2009-176108

SUMMARY OF INVENTION

Technical Problem

However, for example, in a case where a programming language is replaced, the reserved words (i.e. tokens) of the programming language are usually changed. Moreover, in a case where a program is changed in order to be adapted to replacement of an OS or a middleware, function names (i.e. tokens) written in the program are sometimes changed. When the technique disclosed in Patent Document 1 is used in such cases, semantically same parts are found out to be different parts. Thus, the technique disclosed in Patent Document 1 is hard to be used in a conversion.

It is therefore an object of the present invention to provide an apparatus which compares two modules each including one or more sentences written in a programming language and which compares the two modules by using a new method applicable even in a conversion.

Solution to Problem

An aspect of the present invention provides an apparatus which compares two modules each including one or more sentences written in a programming language. The module is capable of including conditional statements written therein, wherein each of the conditional statements is one of the sentences. The conditional statement includes an executable-on-satisfaction statement and/or an executable-on-failure statement. The executable-on-satisfaction statement is the sentence that is executed when a conditional expression of the conditional statement is satisfied. The executable-on-failure statement is the sentence that is executed when the conditional expression is not satisfied. At least one of the conditional statements is capable of including the other conditional statement therein as the executable-on-satisfaction statement and/or as the executable-on-failure statement so that the conditional statements enable a hierarchization of the sentences. Moreover, the hierarchization of the sentences forms a specifiable hierarchical structure of the module. The apparatus comprises a storage means and a comparing means. The storage means stores two or more of the modules. The comparing means obtains a first module and a second module, from the storage means, among the modules stored in the storage means. The comparing means creates a message which shows whether the hierarchical structure of the first module is identical to the hierarchical structure of the second module or not.

Another aspect of the present invention provides a program which makes a computer function as the apparatus.

Advantageous Effects of Invention

According to the present invention, the created message shows whether the hierarchical structures of the two modules are identical to each other or not. When the hierarchical structures of the two modules are not identical to each other, the two modules are very likely to include the respective parts semantically different from each other. The message can therefore notify whether the two modules include the respective parts semantically different from each other.

DESCRIPTION OF EMBODIMENTS

First Embodiment

As shown inFIG. 1, a comparing apparatus (apparatus)10according to a first embodiment of the present invention comprises a device body20, a storage device (storage means)30, an input device40and an output device50. The comparing apparatus10is to compare two modules (source programs) each including one or more sentences written in a programming language.

The program language according to the present embodiment is COBOL. However, the present invention is also applicable for a program language other than COBOL.

The module according to the present embodiment can be identified by a module name which is formed of combined letters, digits, symbols, etc.

The module is capable of including one or more of processing sections written therein, wherein each of the processing sections includes one or more of the sentences. The processing section according to the present embodiment is a section in COBOL. Each of the sections can be identified by a section name (processing section name). However, the processing section does not need to be the section. For example, when the program language is JAVA (trademark), the processing section may be a function which can be identified by a function name (processing section name).

The module can call the other modules or the module itself. Moreover, the section of the module can perform the other sections or the section itself. More specifically, the module is capable of including each of a processing-section perform statement (the sentence) and a module call statement (the other sentence) written therein, wherein the processing-section perform statement is to perform the section identified by the section name, and the module call statement is to perform one of the modules identified by the module name. According to the present embodiment, the processing-section perform statement is PERFORM-statement, and the module call statement is CALL-statement. In another program language, each of the processing-section perform statement and the module call statement is, for example, a statement which specifies the function name. In a case where the module call statement is the statement specifying the function name, the specified function of the module (i.e. a part of the module) is executed by the module call statement. In this case, the module name may not be explicitly written in the module call statement. In other words, the module name may be indirectly specified by the function name.

Moreover, the module is capable of including conditional statements written therein, wherein each of the conditional statements is one of the sentences. The conditional statement includes a conditional expression, and an executable-on-satisfaction statement and/or an executable-on-failure statement can be written in the conditional statement. In other words, the conditional statement is capable of including the executable-on-satisfaction statement and/or the executable-on-failure statement. The executable-on-satisfaction statement is the sentence that is executed when the conditional expression of the conditional statement is satisfied. The executable-on-failure statement is the sentence that is executed when the conditional expression is not satisfied. The conditional statement according to the present embodiment is IF-statement or EVALUATE-statement. In IF-statement, the executable-on-satisfaction statement is the sentence written subordinate to THEN-phrase, and the executable-on-failure statement is the sentence written subordinate to ELSE-phrase. Similarly, in EVALUATE-statement, the executable-on-satisfaction statement is the sentence written subordinate to WHEN-phrase.

At least one of the conditional statements according to the present embodiment is capable of including the other conditional statement therein as the executable-on-satisfaction statement and/or as the executable-on-failure statement so that the conditional statements enable a hierarchization of the sentences. For example, IF-statement can be written as the executable-on-satisfaction statement of the other IF-statement. In other words, the module is composed of one or more of the sentences which can be nested with the conditional statements, so that the module has a predetermined hierarchical structure (i.e. the hierarchical structure formed by the conditional statements). As can be seen easily, the hierarchical structure of the module formed by the hierarchization can be specified by analyzing the sentences of the module.

As shown inFIG. 1, the storage device30is a magnetic disk unit, for example. The storage device30can store various files which are hierarchized, for example, with folders (not shown). The storage device30is communicatively coupled to the device body20, and can read (obtain) and write (store) the file in accordance with an instruction from the device body20. The storage device30according to the present embodiment stores two or more of modules31. In addition, the storage device30can store hierarchical structures36.

The module31is created by using a programming tool (not shown), for example. Each of the modules31may be a single file. Alternatively, a plurality of the modules31may be stored as a single file. The hierarchical structure36is to store the hierarchical structure of the module31. According to the present embodiment, the hierarchical structures36are created for the respective modules31.

The input device40is a keyboard or a mouse, for example. The input device40is communicatively coupled to the device body20, and can send a character input from the keyboard or a position indicated by the mouse to the device body20.

The output device50is a display or a printer, for example. The output device50is communicatively coupled to the device body20, and can display or print data (for example, a character or a figure) transmitted from the device body20.

The device body20is a main body of a personal computer (PC), for example. The device body20has a central processing unit (CPU), a primary storage device, etc. (not shown). The storage device30stores executable files of various programs (not shown). The CPU loads the executable files into the primary storage device to perform various functions by executing instructions in each of the executable files. During a process in which the CPU executes the instructions, a predetermined file stored in the storage device30is read into a variable region of the program via a buffer area in the primary storage device. The content of the file read into the variable region of the program is written into the storage device30via the buffer area of the primary storage device as necessary. As can be seen from the above explanation, each of the storage device30and the primary storage device functions as a readable and writable storage means in the present embodiment. In other words, the storage means according to the present embodiment may be one of the storage device30and the primary storage device, or may be both of them. In the following explanation, the storage device30is used as the storage means.

The storage device30according to the present embodiment stores various programs such as a comparing program (not shown). The aforementioned programs are loaded into the primary storage device and executed by the CPU so that the computer functions as various means (i.e. as apparatus). For example, the comparing program makes the computer function as a comparing means23(comparing apparatus10) that compares a first module31and a second module31among the modules31stored in the storage device30. In other words, the device body20of the apparatus10according to the present embodiment comprises the comparing means23.

As shown inFIG. 2, the module31according to the present embodiment is composed of n (n≧1) lines310. The module31according to the present embodiment is a text file. However, the module31may be a worksheet of MICROSOFT EXCEL (trademark), for example. In a case where the module31is the worksheet, the comparing means23can be implemented in an EXCEL macro, for example. The line310according to the present embodiment is formed of a sequence number (line ID)311and a sentence312. The sequence number311is to identify the line310and to judge the order of the lines310. The sequence number311may include characters or symbols as well as digits. The sentence312includes the statement (for example, a data definition statement, an executable statement or a comment statement) written therein. The sentence312may include a complete single statement wholly written therein. Alternatively, the sentence312may include a part of the single statement. For example, MOVE-statement may be separately written in the sentences312of the two lines310.

As shown inFIG. 3, the hierarchical structure36according to the present embodiment is composed of m (m≧1) lines360. The hierarchical structure36according to the present embodiment is a worksheet of MICROSOFT EXCEL (trademark). However, the hierarchical structure36may be a text file, for example. The hierarchical structure36is created via an analysis of the hierarchical structure of the module31made by the comparing means23and is stored in association with the module31. Specifically, for example, the hierarchical structure36has a file name same as a file name of the corresponding module31. Alternatively, the module31and the hierarchical structure36corresponding to each other may be respective worksheets of a common workbook.

The line360according to the present embodiment is formed of a sequence number (line ID)361and a hierarchy depth362. The sequence number361is set to the sequence number311of the corresponding line310of the corresponding module31. The hierarchy depth362is set to a hierarchy depth of the sentence312which corresponds to the sequence number361(i.e. sequence number311). In other words, the hierarchical structure36includes the hierarchy depth362which is specified in the hierarchization of the sentences312.

For example, referring to an example module31shown inFIG. 6, each of the sentences312between ACCEPT-statement with the sequence number311of “0001” and ACCEPT-statement with the sequence number311of “0004” has the hierarchy depth of 1. In addition, IF-statement with the sequence number311of “0005” has the hierarchy depth of 1. THEN with the sequence number311of “0006” has the hierarchy depth of 2. As can be seen from the above explanation, the top sentence312of the module31has the hierarchy depth of 1. As the sentences312are sequentially picked up, the hierarchy depth362is incremented by 1 each time when THEN is found. Moreover, as can be seen from the hierarchy depth362of each of the sentences312with the sequence numbers311of “0014”, “0017” and “0020”, the hierarchy depth362is decremented by 1 each time when END-IF is found.

As described above, according to the present embodiment, the hierarchy depth362is set to a numerical value. However, the hierarchy depth362is not required to be set to a numerical value, provided that the hierarchy depths in the hierarchical structure can be compared with one another. Moreover, it is sufficient if the hierarchy depth362is designed to be changed in value upon the detection of THEN and to recover the value before the change upon the detection of corresponding END-IF. The hierarchy depth may be applied only to the lines each including the executable statement written therein. Moreover, the hierarchy depth may be applied only to the top line and the end line of IF-statement as well as the lines each including THEN or ELSE written therein.

Hereafter, by usingFIG. 5while referring to examples shown inFIGS. 6 to 8, explanation is made in detail about the function and the process of the apparatus10according to the present embodiment. First, explanation is made about an example in which the module31includes only IF-statement as the conditional statement (seeFIGS. 6 and 7). Then, explanation is made about another example in which the module31includes the conditional statement other than IF-statement (seeFIG. 8).

As shown inFIG. 5, the comparing means23according to the present embodiment is activated, for example, by a start instruction input from the input device40, and subsequently, gets a first module name to identify the first module31and a second module name to identify the second module31(S500). For example, the second module31is the maintained first module31. Each of the first module name and the second module name may be input, for example, as a part of the start instruction.

Then, the comparing means23reads the first module31, which is identified by the obtained first module name, from the storage device30(S502). At that time, for example, only one of the modules31stored in a predetermined folder may be the target to be read. If the first module31is not stored in the storage device30, the comparing means23ends its process (not shown).

Then, the comparing means23generates the hierarchy depth for each sentence312of the first module31and creates a first hierarchical structure36(S504). Specifically, the comparing means23sequentially retrieves the lines310of the first module31from the first line to the last line while applying the hierarchy depth to each of the lines310. At that time, the comparing means23adjusts the hierarchy depth of the first line to 1 and increments the hierarchy depth each time when THEN of IF-statement is found. Moreover, the comparing means23decrements the hierarchy depth each time when END-IF of IF-statement (i.e. the end of IF-statement) is found. In a case where the description of THEN or END-IF can be omitted, the hierarchy depth can be set by analyzing, for example, the order of the statements in IF-statement. The comparing means23combines the sequence numbers311of the lines310with the hierarchy depths generated as described above to create the hierarchical structure36.

Referring to the example shown inFIG. 6, the comparing means23applies the hierarchy depth362for each of the sentences312between the top executable statement of the first module31(i.e. the sentence312with the sequence number311of “0001”) and the last executable statement (i.e. the sentence312with the sequence number311of “0020”). The comparing means23combines the sequence numbers311with the hierarchy depths362to create the first hierarchical structure36.

Then, as shown inFIG. 5, the comparing means23reads the second module31that is identified by the obtained second module name from the storage device30similar to the first module31(S506).

Then, the comparing means23generates the hierarchy depth for each sentence312of the second module31and creates a second hierarchical structure36similar to the first module31(S508).

Referring to the example shown inFIG. 7, the comparing means23applies the hierarchy depth362for each of the sentences312between the top executable statement of the second module31(i.e. the sentence312with the sequence number311of “0001”) and the last executable statement (i.e. the sentence312with the sequence number311of “0014”). The comparing means23combines the sequence numbers311with the hierarchy depths362to create the second hierarchical structure36.

As shown inFIG. 5, the comparing means23according to the present embodiment writes the first hierarchical structure36and the second hierarchical structure36, which are thus-created, into the storage device30(S510). However, the first hierarchical structure36and the second hierarchical structure36may be stored only into the primary storage device (not shown) of the device body20. In other words, the hierarchical structures36may be stored not in the storage device30but in the primary storage device (not shown).

Then, the comparing means23compares between the first hierarchical structure36and the second hierarchical structure36(S512). For example, the comparing means23sequentially compares the hierarchy depths362of the first hierarchical structure36with the hierarchy depths362of the second hierarchical structure36from the first line and determines whether the fluctuations of the hierarchy depths362are identical to each other or not.

Referring to the examples, namely, the first hierarchical structure36and the second hierarchical structure36, shown inFIGS. 6 and 7, the hierarchy depths362in the first hierarchical structure36(seeFIG. 6) fluctuates in the order of 1, 2, 3, 4, 3, 2, 1 except the parts with no fluctuation. On the other hand, the hierarchy depths362in the second hierarchical structure36(seeFIG. 7) fluctuates in the order of 1, 2, 3, 2, 1 except the parts with no fluctuation. Thus, the fluctuation of the hierarchy depths362of the first hierarchical structure36is not identical to the fluctuation of the hierarchy depths362of the second hierarchical structure36. In this case, the comparing means23creates a message which shows that the first hierarchical structure36of the first module31is not identical to the second hierarchical structure36of the second module31. In contrast, in a supposed case where the hierarchy depths362in the second hierarchical structure36fluctuates in the order of 1, 2, 3, 4, 3, 2, 1, the fluctuation of the hierarchy depths362of the first hierarchical structure36is identical to the fluctuation of the hierarchy depths362of the second hierarchical structure36. In this case, the comparing means23creates another message which shows that the first hierarchical structure36of the first module31is identical to the second hierarchical structure36of the second module31.

As described above, the comparing means23creates the message, or the result of the comparison between the first hierarchical structure36and the second hierarchical structure36(S512ofFIG. 5). The comparing means23according to the present embodiment outputs the created message to the output device50(S512).

The first hierarchical structure36and the second hierarchical structure36may be compared with each other by a method other than that of the present embodiment. For example, as can be seen fromFIGS. 6 and 7, the sequence numbers361and the hierarchy depths362may be created only from IF-statement, THEN, ELSE and END-IF (see the parts whose hierarchy depths362are encircled inFIGS. 6 and 7). In this case, the first hierarchical structure36and the second hierarchical structure36can be compared with each other by sequentially comparing the hierarchy depths362of the first hierarchical structure36with the hierarchy depths362of the second hierarchical structure36from the first line.

Moreover, as can be seen fromFIG. 8, at least one of the first module31and the second module31may include the conditional statement other than IF-statement. For example, in a case where EVALUATE-statement is included, the comparing means23may update the hierarchy depth when first WHEN of EVALUATE-statement is found and may set back the hierarchy depth prior to the updating when END-EVALUATE corresponding to EVALUATE-statement is found. The conditional statement other than IF-statement and EVALUATE-statement can be similarly processed. As can be seen easily, after the hierarchical structures36(the first hierarchical structure36and the second hierarchical structure36) are created, the function and the process of the comparing means23are same as those in the case where the module31includes only IF-statement as the conditional statement.

As previously described, the comparing means23according to the present embodiment creates the message not only when the first hierarchical structure36is not identical to the second hierarchical structure36but also when the first hierarchical structure36is identical to the second hierarchical structure36. However, the comparing means23may create the message in only one of two cases, namely, a case where the first hierarchical structure36is not identical to the second hierarchical structure36and another case where the first hierarchical structure36is identical to the second hierarchical structure36. Moreover, the message created by the comparing means23may shows not only whether the first hierarchical structure36of the first module31is identical to the second hierarchical structure36of the second module31or not, but also the different parts between the first hierarchical structure36and the second hierarchical structure36. As explained below, in this case, the comparing means23may create a hierarchical structure36a(seeFIG. 4) instead of the hierarchical structure36.

As shown inFIG. 4, the hierarchical structure36ais composed of ma (ma≧1) lines360a. Similar to the hierarchical structure36, the hierarchical structure36ais created via an analysis of the hierarchical structure of the module31made by the comparing means23and is stored in association with the module31.

The lines360aof the hierarchical structure36aare created so as to correspond to the respective conditional statements of the corresponding module31. For example, referring to the example ofFIG. 6, the conditional statements (IF-statements) of the first module31are written in the three lines310with the sequence numbers311of “0005”, “0007” and “0009”. Accordingly, as shown in the upper part ofFIG. 9, the hierarchical structure36aof the first module31includes the three lines360a. On the other hand, referring to the example ofFIG. 7, the conditional statements (IF-statements) of the second module31are written in the two lines310with the sequence numbers311of “0004” and “0006”. Accordingly, as shown in the lower part ofFIG. 9, the hierarchical structure36aof the second module31includes the two lines360a.

As shown inFIG. 4, the line360ais formed of the sequence number (line ID)361, a hierarchy pattern363and an end line (sequence number)364. The sequence number361is set to the sequence number311of the corresponding module31. The end line364is set to the sequence number311of the end line of the conditional statement written in the line310of the sequence number361(sequence number311), for example, the sequence number311of the line310in which END-IF corresponding to IF-statement is written. As explained below, the hierarchy pattern363is set to data which can identify the hierarchical structure of the range between the sequence number361and the end line364.

For example, referring to the example inFIG. 6and the example in the upper part ofFIG. 9, first IF-statement, which is written in the line310with the sequence number311of “0005”, ends at the line310with the sequence number311of “0020”. Accordingly, the sequence number361and the end line364of the first line of a first hierarchical structure36aare set to “0005” and “0020”, respectively. At that time, the comparing means23creates a hierarchy pattern before compression (“1 2 2 3 3 4 4 3 3 2 2 1”) by combining the hierarchy depths of IF-statements, THENs, ELSEs and END-IFs written between the line310with the sequence number311of “0005” and the line310with the sequence number311of “0020”. Then, the comparing means23creates the hierarchy pattern363after compression (“1 2 3 4 3 2 1”) by compressing the successive same hierarchy depths in the hierarchy pattern before compression into a single hierarchy depth. The comparing means23similarly creates the hierarchy pattern363after compression for each of If-statement written in the line310with the sequence number311of “0007” and If-statement written in the line310with the sequence number311of “0009”. As can be seen from the above explanation, the comparing means23generates the sequence number361, the end line364and the hierarchy pattern363for each of the conditional statements of the first module31, and creates the first hierarchical structure36a(see S504ofFIG. 5).

Similarly, as can be seen from the example inFIG. 7and the example in the lower part ofFIG. 9, the comparing means23generates the sequence number361, the end line364and the hierarchy pattern363for each of the conditional statements of the second module31, and creates a second hierarchical structure36a(see S508ofFIG. 5).

The comparing means23according to the present modification compares between the first hierarchical structure36aand the second hierarchical structure36awhich are created as described above, and outputs the result of the comparison (S512ofFIG. 5). For example, the comparing means23sequentially compares the hierarchy patterns363of the first hierarchical structure36awith the hierarchy patterns363of the second hierarchical structure36a. At that time, the comparing means23may compare only the hierarchy patterns363, each of which has the starting hierarchy depth of 1, with each other. For example, referring to the examples inFIG. 9, the hierarchy pattern363with the sequence number361of “0005” in the first hierarchical structure36amay be compared with the hierarchy pattern363with the sequence number361of “0004” in the second hierarchical structure36a.

According to the modification described above, when the hierarchy patterns363of the first hierarchical structure36a(i.e. the first module31) are not identical to the hierarchy patterns363of the second hierarchical structure36a(i.e. the second module31), it is possible to output the inequal parts to the output device50together with the message which shows the inequality. Specifically, for example, the sequence number311and the end line364for each of the hierarchy patterns363, which are not identical to each other, may be output to the output device50.

The comparing means23may compares not only the hierarchy patterns363each of which has the starting hierarchy depth of 1 but also all of the hierarchy patterns363. In this case, the inequal parts between the first module31and the second module31can be limited to a narrower range.

As described above, the comparing means23according to the present embodiment (including the modifications) outputs the message to the output device50. However, the comparing means23may store the message into the storage means30as well as output it to the output device50. Moreover, the comparing means23may store the message into the storage means30without outputting it to the output device50. Moreover, the comparing means23may send the message to the other devices or means.

The comparing means23according to the present embodiment can be variously modified as described below in addition to the aforementioned modifications.

For example, at least one of the first module31and the second module31may be a combination of a plurality of the modules31. For example, a plurality of the modules31may be simply and sequentially combined from each start line to its end line to form the first module31or the second module31. Thereby, the whole of a single program formed of a plurality of the modules31can be compared at one time. It is also possible to combine a plurality of the modules31according to a second embodiment as described below.

Second Embodiment

As shown inFIG. 10, a comparing apparatus (apparatus)10′ according to a second embodiment of the present invention comprises a device body20′, a storage device (storage means)30′, the input device40and the output device50. Similar to the apparatus10according to the first embodiment, the apparatus10′ is to compare two modules (source programs) each including one or more sentences written in a programming language. The program language, the module, the input device40and the output device50according to the second embodiment are configured similar to those of the first embodiment.

As shown inFIG. 10, the storage device30′ is a magnetic disk unit similar to the storage device30. The storage device30′ stores two or more of the modules31similar to the first embodiment. In addition, the storage device30′ stores two or more of secondary modules (modules)32. The secondary module32according to the present embodiment is created by converting one of the modules31or created by combining and converting two or more of the modules31.

The device body20′ is, for example, a main body of a PC similar to the device body20. The device body20′ has a CPU, a primary storage device, etc. (not shown). Similar to the first embodiment, each of the storage device30′ and the primary storage device functions as a readable and writable storage means in the present embodiment. In the following explanation, the storage device30′ is used as an example of the storage means.

The storage device30′ according to the present embodiment stores a conversion program, a processing program and a comparing program (not shown). The aforementioned programs are loaded into the primary storage device and executed by the CPU so that the computer functions as each of a conversion means21, a processing means22and a comparing means23′. Thus, the aforementioned programs are to make the computer function as the apparatus10′ that compares two modules each including one or more sentences written in a programming language. In other words, the device body20′ of the apparatus10′ according to the present embodiment comprises the conversion means21, the processing means22and the comparing means23′.

The conversion means21according to the present embodiment is to convert a predetermined module31among the modules31stored in the storage device30′ into the secondary module32to store it into the storage device30′. The processing means22is to process the secondary module32(a first module32and/or a second module32) stored in the storage device30′. The comparing means23′ is to compare the first module32and the second module32stored in the storage device30′ similar to the comparing means23of the first embodiment. However, the comparing means23′ according to the present embodiment does not compare the two module31but compares the two secondary modules32(the first module32and the second module32which are created from the two respective modules31.

As shown inFIG. 11, the storage device30′ stores, for example, a module31(XXX module) having a module name of XXX, another module31(AAA module) having another module name of AAA, another module31(BBB Module) having another module name of BBB and another module31(CCC module) having another module name of CCC. Each of the modules31is composed of a plurality of the lines310each of which is formed of the sequence number311and the sentence312. Hereafter, more specific explanation about the structure of the module31is made as referring to these examples.

XXX module is a main module (i.e. a module where a process starts). XXX module has the lines310in which respective CALL-statements for identifying and calling AAA module and BBB module by using their module names are written. AAA module has the line310in which CALL-statement for calling CCC module is written.

Each of the example modules31illustrated inFIG. 11includes one or more of the sections. For example, XXX module has a main section (i.e. a main processing section where a process of the module starts) and sub-sections (subordinate processing sections). The main section is composed of the lines310between the line310next to the line310in which “PROCEDURE DIVISION.” is written and the line310in which “STOP RUN.” is written. One of the subordinate processing sections (sub-sections) is composed of the lines310between the line310in which “AAA-SUB SECTION.” is written and the line310in which “EXIT.” is written. The aforementioned sub-section has the section name (processing section name) of AAA-SUB. The main section includes the line310which identifies and performs AAA-SUB section by using its section name. More specifically, the main section includes the line310in which “PERFORM AAA-SUB.” is written.

Some of example sections illustrated inFIG. 11include the lines310in each of which the conditional statement is written. For example, the main section of XXX module includes the lines310in which EVALUATE-statement having five WHEN phrases are written and the lines310in which IF-statement having THEN and ELSE are written. The main section of CCC module includes the lines310in which IF-statement having ELSE including the other IF-statement is written so that the conditional statements form hierarchies of the sentences312.

As shown inFIG. 12, the secondary module32according to the present embodiment is composed of a plurality of secondary lines (lines)320. The secondary module32according to the present embodiment is a worksheet of MICROSOFT EXCEL (trademark). However, the secondary module32may be a text file, for example. The line320according to the present embodiment is formed of a module ID321, a line number322, a hierarchical structure323, a sequence number (line ID)326and a secondary sentence327.

Each of the secondary modules32is generated by collecting the lines310from one or more of the modules31and processing the collected lines310in which the executable statements, etc. are written. The secondary module32according to the present embodiment is generated by the conversion means21and processed by the processing means22. The processed secondary modules32are compared with each other by the comparing means23′.

As shown inFIG. 12, an example of the secondary module32according to the present embodiment is generated by collecting and processing the lines310in PROCEDURE DIVISIONs of XXX module, AAA module, BBB module and CCC module.

As can be seen fromFIGS. 11 and 12, each PERFORM-statement written in the sentence312of the line310(for example, “PERFORM PGMAAAP-PROC” inFIG. 11) is commented out in the secondary sentence327of the line320. In contrast, the sentences312in PGMAAAP-PROC section, which is to be performed by this PERFORM-statement, are expanded into the secondary sentences327of the lines320. Moreover, each CALL-statement written in the sentence312of the line310is commented out, or changed into a comment statement, in the secondary sentence327of the line320. In contrast, the sentences312in PROCEDURE DIVISION of AAA module, which is to be called by CALL-statement, are expanded into the secondary sentences327of the lines320, or expanded so that the secondary sentences327of the lines320are generated. In addition, the sentences312in PROCEDURE DIVISION of CCC module, which is to be called by CALL-statement of AAA module, are expanded into the secondary sentences327of lines320.

Regarding the conditional statements written in the sentences312, the conditional statement other than IF-statement, or EVALUATE-statement in the present embodiment, is converted into IF-statements in the secondary sentences327. For example, the three sentences312in which “EVALUATE WK-A-O”, “WHEN CS-1” and “MOVE CS-1 TO WK-B-I” are written, respectively, are converted into the five secondary sentences327in which “*# E EVALUATE WK-A-O” (comment statement), “*# E WHEN CS-1” (comment statement), “IF (WK-A-O=CS-1)”, “THEN” and “MOVE CS-1 TO WK-B-I” are written, respectively (see the part enclosed by dashed line A inFIG. 12). According to the present embodiment, in addition to the aforementioned conversion, the secondary sentences327are generated to supplement the lack of THEN, ELSE and END-IF in IF-statement. Moreover, a negative conditional expression is converted into an affirmative conditional expression. Moreover, IF-statement having conditional expressions coupled with each other by AND or OR is broken down into a plurality of IF-statements, or converted into IF-statements each having a simple secondary conditional expression which evaluates the relation of two operands only by a single logical operator. However, some of the aforementioned conversions (for example, the breakdown of the conditional expressions coupled with each other by AND or OR) does not necessarily need to be done.

In addition, each executable statement, for example, MOVE-statement, which is separately written in a plurality of the sentences312is arranged into a single secondary sentence327. Thus, each of the lines320of the secondary module32is generated based on the line310of the module31. More specifically, the secondary sentence327is either a copy of the sentence312with no modification or a sentence generated by processing and/or expanding the sentence312.

The module ID321according to the present embodiment is to indicate the module31from which the corresponding line320is generated. More specifically, the module ID321is set to the module name, for example, XXX. However, a number, etc. which can uniquely identify the module31may be set instead of the module name.

In a case where the line320has the secondary sentence327copied from the sentence312, the sequence number326thereof is set to the sequence number311of the copied source line310. In other words, when the line320one-to-one corresponds to the line310, for example, when the line320includes the secondary sentence327generated by commenting out the sentence312, the sequence number326is set to the sequence number311of the corresponding line310. On the other hand, the sequence number326in the generated (added) line320is set to an identifier, for example, a combination of symbols, which can indicate that the line320is generated. By doing so, the line320and the line310can be easily associated with each other.

The line number322according to the present embodiment is set to a serial number which starts from 1 and is incremented along the order of the lines320. However, the line number322does not need to be a serial number, provided that the line numbers322can be compared with one another in magnitude relation. For example, the line number322may be a combination of characters and symbols.

The hierarchical structure323according to the present embodiment is formed of a branch hierarchy324and a hierarchy depth325. The branch hierarchy324is used to specify a hierarchy formed with the conditional statements. The branch hierarchy324according to the present embodiment is set in such a manner that 1 is used as the starting value of the first line320. In other words, the branch hierarchy324of the first line320is 1. The branch hierarchy324is changed into 1.1 at the line320in which THEN of IF-statement is written while being changed into 1.2 at the line320in which ELSE is written. The branch hierarchy324returns to 1 from the line next to the line320in which END-IF of IF-statement is written. When generalized: at the line320in which THEN is written, “0.1” is appended to the end of the branch hierarchy324of the immediately preceding line320; at the line320in which ELSE is written, “0.1” of the end of the branch hierarchy324of the immediately preceding line320is changed into “0.2”; and at the line320next to the line320in which END-IF is written, “0.2” of the end of the branch hierarchy324of the line320in which END-IF is written is removed. Except for the above cases, the branch hierarchy324is set to a value same as that of the immediately preceding line320.

Similar to the branch hierarchy324, the hierarchy depth325according to the present embodiment is set in such a manner that 1 is used as the starting value at the first line320. In other words, the hierarchy depth325of the first line320is 1. The hierarchy depth325is changed into 1.1 at the line320in which THEN of IF-statement is written while returning to 1 from the line320next to the line320in which END-IF is written. Thereafter, the hierarchy depth325is changed into 1.2 at the line320in which THEN of IF-statement is written while returning to 1 from the line320next to the line320in which END-IF is written. When generalized: the hierarchy depth325has the starting value of 1; at the line320in which THEN is written, a digit of “.q” (q is an integer equal to or more than1) is appended to its end; and at the line320next to the line320in which END-IF is written, its end digit of “.q” is removed. The value of q in “.q” starts from 1 for each digit. In detail, the value of q in “.q” of the first digit (for example, “0.2” of 1.2) starts from 1 and is incremented each time when being appended. The value of q in “.q” of the second digit or the digit after the second digit (for example, “0.1” of 1.2.1) starts from 1 in a continuous range and is incremented each time when being appended in this continuous range, wherein the continuous range is composed of successive lines320having the same hierarchy depth325as one another except this digit.

The line320may include various items in addition to the items described above. For example, when the line320includes the section name of the corresponding line310, correspondence between the line320and the line310can be understood more easily.

Hereafter, explanation is made in detail about the function and the process of the apparatus10′ according to the present embodiment.

As can be seen fromFIG. 13, the conversion means21according to the present embodiment has a control information getting function (S1300), a read function (S1302and S1304), a conversion function (S1306to S1312) and a write function (S1314). The control information getting function is a function to get an expansion control information. The read function is a function to read a target module31to be processed among the modules31from the storage device30′. The conversion function is a function to convert the target module31into the secondary module32. The write function is a function to store the secondary module32into the storage device30′.

More specifically, as shown inFIG. 13, when the conversion means21is activated, for example, by a start instruction input from the input device40, the conversion means21gets the expansion control information which is, for example, input as a part of the start instruction (S1300). The expansion control information according to the present embodiment can optionally include an expansion limit indicator. The expansion limit indicator indicates that an expansion of the statements written in the sentences312of each of the processing section to be performed and the module31to be called is limited only once at first time.

Then, the conversion means21gets the sentence312at a process start location of the target module31(S1306). The process start location according to the present embodiment is the top of the main section. The conversion means21performs a secondary sentence output process for the obtained sentence312(S1308). Then, the conversion means21determines whether the sentence312at a process end location is already processed (S1310). The process end location according to the present embodiment is the end of the main section. If already processed (YES at S1310), the conversion means21writes the generated secondary module32into the storage device30′ (S1314) and ends its process. On the other hand, if not yet processed (NO at S1310), the conversion means21gets the sentence312to be processed next, or the sentence312of the next line310(S1312), and performs the secondary sentence output process for the obtained sentence312(S1308).

FIG. 14is a flowchart showing in more detail the secondary sentence output process (S1308) among the processes (functions) of the conversion means21shown inFIG. 13. As shown inFIG. 14, in the secondary sentence output process, the conversion means21outputs the sentence312as the secondary sentence327(S1400). More specifically, according to the present embodiment, the executable statement, etc. written in the sentence312is copied into a predetermined row and column of a worksheet. At that time, as previously described, the processing such as the commenting out of PERFORM-statement is done. In addition, the conversion means21sets the module ID321, the line number322and the sequence number326to the previously described values.

Then, the conversion means21determines whether the conditional statement is written in the sentence312(S1402). If the executable statement written in the sentence312is the conditional statement (YES at S1402), the conversion means21performs the previously described process so that, for example, the conditional statement other than IF-statement is converted into IF-statement. More specifically, the conversion means21generates, based on the conditional expression of the conditional statement, the secondary sentences327including the secondary conditional statement (IF-statement) which is one of the secondary statements while hierarchizing the secondary sentences327with the secondary conditional statement, outputs the secondary sentences327into the secondary module (S1404) and ends its secondary sentence output process.

If the executable statement written in the sentence312(target statement) is not the conditional statement (NO at S1402), the conversion means21determines whether the target statement is the processing-section perform statement (PERFORM-statement) or not (S1406). If the target statement is the processing-section perform statement (YES at S1406), the conversion means21gets the sentence312at a process start location of the processing section to be performed. In the present embodiment, the process start location of the processing section is the top of the section.

If the target statement is not the processing-section perform statement (NO at S1406), the conversion means21determines whether the target statement is the module call statement (according to the present embodiment, CALL-statement) or not (S1410). If the target statement is the module call statement (YES at S1410), the conversion means21reads the called target module31that is identified by CALL-statement from the storage device30′ (S1412) and gets the sentence312at a process start location of the called target module31(S1414). According to the present embodiment, the process start location of the called target module31is the top of the main section of this module31. If the target statement is not the module call statement (NO at S1410), the conversion means21ends its secondary sentence output process.

The conversion means21recursively performs the secondary sentence output process for the sentence312of the section to be performed or for the sentence312of the called target module31(S1416). Then, the conversion means21determines whether the sentence312at a process end location is already processed (S1418). The process end location according to the present embodiment is either the end of the section to be performed or the end of the main section of the called target module31. If already processed (YES at S1418), the conversion means21ends its secondary sentence output process. On the other hand, if not yet processed (NO at S1418), the conversion means21gets the next sentence312to be processed, or the sentence312of the next line310(S1420) and recursively performs the secondary sentence output process for the obtained sentence312(S1416).

The conversion means21does not perform the expansion of the sentences312of the section which is recursively performed by PERFORM-statement (which performs itself). Similarly, the conversion means21does not perform the expansion of the sentences312of the module which is recursively called by CALL-statement (which calls itself). Moreover, in a case where the expansion limit indicator is included in the expansion control information, the conversion means21does not perform the secondary sentence output process when the conversion means21gets PERFORM-statement that performs the section of the section name same as that of the section for which the secondary sentence output process is already done (S1406). Similarly, in the case where the expansion limit indicator is included in the expansion control information, the conversion means21does not perform the secondary sentence output process when the conversion means21gets CALL-statement that calls the module31of the module name same as that of the module31for which the secondary sentence output process is already done (S1410).

As can be seen from the above explanation, the conversion function of the conversion means21sequentially outputs each of the sentences312written between the predetermined process start location and the predetermined process end location of the target module31into the secondary module as the secondary sentence327. Moreover, when the sentence312is the processing-section perform statement or the module call statement, the conversion function of the conversion means21generates the secondary sentences327to output them into the secondary module32, wherein the secondary sentences327are generated from the sentences312which are written in the processing section to be performed or in the called target module31. Moreover, the conversion function of the conversion means21further expands (i.e. recursively expands) the processing-section perform statement and the module call statement in the expansion of the sentences312. Accordingly, a function distributed in many processing sections and modules31can be collected in such a manner that the distributed function is hauled into the main section of the target module31. In other words, functions of a program can be collected into a single secondary module32.

As can be seen from the above explanation, when the expansion limit indicator is included in the expansion control information, the conversion function of the conversion means21according to the present embodiment generates the expansion of the sentences312written in the processing section to be performed only once at first time for the same processing section (i.e. expands the same processing section only once), and generates the expansion of the sentences312written in the called target module31only once at first time for the same module (i.e. expands the same module31only once). However, the conversion function of the conversion means21may expand the same processing section or the same module31only once when the expansion limit indicator is not included. Moreover, the conversion function of the conversion means21may expand the same processing section or the same module31only once regardless of whether the expansion limit indicator is included or not. Moreover, the conversion function of the conversion means21may repeatedly expand the same processing section or the same module31regardless of whether the expansion limit indicator is included or not.

As explained above, the secondary module32composed of the secondary sentences327is stored into the storage device30′ by the conversion means21.

As can be seen fromFIG. 15, the processing means22according to the present embodiment has a read function (S1500and S1502), a hierarchical structure adding function (S1506) and a write function (S1510). The read function is a function to read a target secondary module32from the storage device30′. The hierarchical structure adding function is a function to add the hierarchical structure323for at least one of the secondary sentences327of the secondary module32. The write function is a function to store the secondary module32into the storage device30′, wherein the secondary module32includes the secondary sentence327to which the hierarchical structure323is added.

More specifically, as shown inFIG. 15, when the processing means22is activated, for example, similar to the conversion means21, the processing means22gets a secondary module name which identifies the target secondary module32(S1500). The processing means22reads the secondary module32that is identified by the obtained target secondary module name from the storage device30′ (S1502). If the target secondary module32is not stored in the storage device30′, the processing means22ends its process (not shown).

Then, the processing means22gets the secondary sentence327at a process start location of the target secondary module32(S1504). The process start location according to the present embodiment is the top of the secondary module32.

The processing means22adds the hierarchical structure323for the obtained secondary sentence327(S1506). More specifically, the processing means22according to the present embodiment outputs each of the branch hierarchy324and the hierarchy depth325, which are previously described, into a row and column that corresponds to the hierarchical structure323of the line320in the worksheet (i.e. target worksheet) in which the target secondary module32is recorded.

Then, the processing means22determines whether the secondary sentence327at a process end location is already processed (S1508). The process end location according to the present embodiment is the end of the secondary module32. If already processed (YES at S1508), the processing means22writes the processed secondary module32into the storage device30′ (S1510) and ends its process. On the other hand, if not yet processed (NO at S1508), the processing means22gets the secondary sentence327to be processed next, or the secondary sentence327of the next line320(S1512), and adds the hierarchical structure323for the obtained secondary sentence327(S1506).

As explained above, the processing means22stores the secondary module32into the storage device30′, wherein the secondary module32includes the secondary sentence327to which the hierarchical structure323is added. As can be seen from the above explanation, the function of the processing means22can be included in the conversion means21. In this case, the apparatus10′ does not need to comprise the processing means22.

The comparing means23′ according to the present embodiment has functions similar to those of the comparing means23according to the first embodiment. Hereafter, explanation is made mainly about the function different from that of the comparing means23by usingFIG. 16while referring to examples shown inFIG. 17.

When the comparing means23′ is activated similar to the comparing means23, the comparing means23′ gets a first module name to identify a first module32of the secondary modules32and a second module name to identify a second module32of the secondary modules32(S1600). For example, the first module32is the secondary module32into which the modules31of a predetermined program before maintenance are combined, and the second module32is the secondary module32into which the modules31of the predetermined program after maintenance are combined.

Then, the comparing means23′ reads the first module32and the second module32that are identified by the obtained first module name and the second module name, respectively, from the storage device30(S1602and S1604).

As shown in the example inFIG. 12(see the part enclosed by dashed line A) and the example of the upper part inFIG. 17, EVALUATE-statement having five WHEN-phrases are written in XXX-module before maintenance. As a result, the first module32before maintenance includes four If-statements generated from this EVALUATE-statement (see the upper part inFIG. 17).

As can be seen fromFIG. 17, fifth WHEN-phrase of five WHEN-phrases of XXX-module before maintenance is deleted by the maintenance. As a result, the second module32after maintenance includes three If-statements generated from this EVALUATE-statement (see the lower part inFIG. 17).

As shown inFIG. 16, the comparing means23′ compares between the hierarchical structure323of the first module32and the second hierarchical structure323of the second module32(S1606) after reading the first module32and the second module32. According to the present embodiment, the comparing means23′ sequentially compares the hierarchy depths325of the first module32with the hierarchy depths325of the second module32from the first line and determines whether the fluctuations of the hierarchy depths325are identical to each other or not.

Referring to the examples of the first module32and the second module32shown inFIG. 17, the hierarchy depths325of the second module32are identical to the hierarchy depths325of the first module32, respectively, until the line320with the line number322of “60”. However, the hierarchy depth325(“1.2.1.1”) of the line320with the line number322of “61” of the second module32is different from the hierarchy depth325(“1.2.1.1.1”) of the line320with the line number322of “61” of the first module32. Accordingly, the comparing means23′ creates a message which shows that the hierarchical structure323of the first module32is not identical to the hierarchical structure323of the second module32. Thus, the comparing means23′ creates the message, or the result of the comparison between the hierarchical structure323of the first module32and the hierarchical structure323of the second module32, similar to the comparing means23. The comparing means23′ according to the present embodiment outputs the created message to the output device50.

As can be seen from the above explanation, the comparing means23′ according to the present embodiment can compare between the hierarchical structures of the two modules (the first module32and the second module32) similar to the comparing means23according to the first embodiment. Moreover, according to the present embodiment, in each of the first module32and the second module32, a plurality of the related modules31are combined in the processing order. Accordingly, the whole programs before and after maintenance can be compared at a time.

For example, in a case where a module is maintained in association with an update of a software such as runtime system, the hierarchical structure of the module is basically not changed. Moreover, in such conversion, a conversion tool is sometimes used to maintain the module. However, in general, a conversion tool cannot completely correctly maintain a module. Even in such a case, it is possible to know whether the maintenance is correctly carried out or not by comparing the hierarchical structures of the first module32and the second module32which are generated from the modules before and after the maintenance, respectively.

The comparing method of the hierarchical structures in the present embodiment can be variously modified similar to the first embodiment. For example, the output device50can output the parts at which the hierarchical structure323of the first module32and the hierarchical structure323of the second module32are not identical to each other, so that the incorrectly maintained parts can be easily recognized.

Third Embodiment

As shown inFIG. 18, a comparing apparatus (apparatus)10″ according to a third embodiment of the present invention comprises a device body20″, a storage device (storage means)30″, the input device40and the output device50. The storage device30″ according to the present embodiment is a primary storage device of the device body20″. Similar to the device body20′ according to the second embodiment, the device body20″ comprises the conversion means21, the processing means22and the comparing means23′.

The apparatus10″ is communicatively coupled to a file server60via a communication line80. The communication line80, for example, may be a local area network (LAN) or may be the Internet. The file server60may comprise at least one of the conversion means21, the processing means22and the comparing means23′. Moreover, the file server60comprises a storage device (storage means)70. The storage device70can store the modules31and the secondary modules32. The apparatus10″ therefore can read the module31, etc. from the storage device70and can write the module31, etc. into the storage device70.

As can be seen easily, according to the present embodiment, two modules (the first module32and the second module32) among the secondary modules32can be compared with each other similar to the first and the second embodiments. Moreover, the result of the comparison can be shared by a plurality of the apparatus10″.

REFERENCE SIGNS LIST

20,20′,20″ device body

23,23′ comparing means