Abstract:
Automatic program generation method and apparatus in a computer program development support system having an input unit for inputting input information relating to data declaration and manner of use of data, a memory unit for storing a plurality of program part phototypes each including modifyable information and a processing unit for generating a program part from a program part prototype, wherein the input information is analyzed, one of the program part prototypes stored in the memory unit is selected in accordance with the analysis of the input information, and the selected program part prototype is substituted in accordance with the analysis of the input information to generate a program.

Description:
BACKGROUND OF THE INVENTION 
     The present invention relates to method and apparatus for automatically generating program, and more particularly to method and apparatus for supporting development of a computer program by using a processing system. 
     An apparatus for supporting development of a computer program by using a processing system is disclosed in &#34;System Development Support Software EAGLE&#34;, Hitach Hyoron, Vol. 66, No. 3, pages 19-24. In this apparatus, a plurality of program parts are stored as a library and selectively used in accordance with type and manner of use of data (EAGLE part library management function). In this function, a plurality of program parts are prepared as standard parts, and some of them are manually selected in accordance with the type of data to assemble a program. However, it has no function to modify the selected program parts to optimum ones in accordance with the manner of use of the data. Accordingly, it is necessary to manually add or modify the program parts of the generated program in accordance with the manner of use of the data. As a result, even if the quality and reliability of the program parts for generating the program are high, the resulting program may be of low quality and additional test and debugging are required. This renders the system development time long. 
     Further, since the program parts are manually selected in accordance with the manner of use and the type of the data, a man-power is required and the system development time is long because of selection time. If the number of program parts is set to be low in order to shorten the selection time, the application and utility of the program are restricted. 
     SUMMARY OF THE INVENTION 
     It is an object of the present invention to provide method and apparatus for automatically generating a program which can be used without manual addition or modification. 
     In order to achieve the above object, in accordance with the present invention, there is provided an automatic program generation apparatus in a computer program development support system which comprises an input unit for inputting data declaration and input information relating to manner of use of data, a memory unit for storing a plurality of program part prototypes each including modifyable information, and a processing unit for generating program parts from the program part prototypes, the input information is analyzed, one of the program part prototypes stored in the memory unit is selected in accordance with the analysis, and the selected program part prototype is modified in accordance with the analysis to generate a program. 
     In accordance with the present invention, 
     (1) Not the function of the program but the data to be processed by the program and the manner of use of the data are designated to select the program part prototype, and the program is generated based on the selected program part prototype. 
     (2) The allowable operation is limited by the nature of data. Thus, the program part prototype for the required operation is prepared and the program part prototype is modified in accordance with the variable name, type and size of the data to generate the program. As a result, only the operation method which conforms to the nature of data is generated. Accordingly, so long as the generated program is used as it is, the data integrity is assured and the implementation is hidden externally of the program module. 
     (3) When the program part prototype is modified (macro substitution), not only simple substitution of macros but also conditional substitution and repetitive substitution can be performed. As a result, one program part prototype can be flexibly applied to various data and addition or modification of the program part prototype is hot required. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 shows a block diagram of a typical embodiment of an automatic program generation apparatus of the present invention, 
     FIG. 2 is a flow chart for explaining a typical embodiment of an automatic program generation method and apparatus of the present invention, 
     FIG. 3 shows a typical example of information for designating a program to be generated, 
     FIG. 4 shows a list prepared by the designation of information shown in FIG. 3, 
     FIG. 5 shows a data attribute list prepared by analyzing the information of FIG. 3, 
     FIG. 6 shows a selection rule and a selected program part prototype, and 
     FIG. 7 shows an example of a generated program. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     FIG. 1 shows a block diagram of a typical embodiment of the automatic program generation apparatus of the present invention. 
     In FIG. 1, numeral 21 denotes an input/output unit which inputs data declaration and information relating to the manner of use of the data, outputs the input data and displays it, numeral 23 denotes a memory unit for storing a plurality of program part prototypes as a program part prototype library, numeral 22 denotes a processing unit for generating a program part by analyzing the input information to the input/output unit 21, selecting one of the program part prototypes from the memory unit 23 in accordance with the analysis and modifying the selected program part prototype, and numeral 24 denotes a memory unit for storing the program part generated by the processing unit 22. 
     The program part to be generated is designated by the processing unit 22 which receives the data to be processed by the program and the information relating to the manner of use of the data from the input/output unit 21 through a general purpose text editor and analyzes it. The processor 22 selects an appropriate program part prototype from the program part prototype library stored in the memory unit 23 in accordance with the designation, modifies it and supplies it to the memory unit 24. The input/output unit 21 can display error information of the error in the input data. 
     FIG. 3 shows a typical example of information for designating the program to be generated. In the present example, a list which registers names and values of macros as shown in FIG. 4 are processed. While the C language program is used in the present example for example, the present invention is applicable to other languages without regard to the program language. 
     In FIG. 3, information comprises data declaration statement, the manner of use of data (class), and key. In the data declaration statement exemplary shown in FIG. 3, a variable type is a structure, type of first and second elements (elements 1 and 2) are characters, name of the element 1 is macro name having a 16-byte length, name of the element 2 is macro value having a 32-byte length, a variable name is macrotbl having a variable length of 100, the manner of use or class of the data declaration statement is retrieval table and the key therefor is macroname or element 1. Thus, the information of FIG. 3 designates the preparation of a table having 100 data relating to the macro names and the macro values as shown in FIG. 4. The processing unit 22 analyzes the input information of FIG. 3 to prepare a data attribute analysis table shown in FIG. 5. 
     FIG. 2 shows a flow chart for illustrating an embodiment of the automatic program generation method and apparatus of the present invention. 
     The operation of the present embodiment is explained with reference to the flow chart of FIG. 2. In a step 101, the processing unit 22 receives the information such as data declaration statement from the general purpose text editor of the input/output unit 21. The input information designates the data declaration statement to be processed by the program, the manner of use of the data (class) and the key where the class designates the retrieval table. In a step 102, the processing unit 22 analyzes a structure of the data declaration sentence in accordance with the designation of the program. After the analysis, the processing unit 22 prepares the data attribute analysis table shown in FIG. 5. In a step 104, the processing unit 22 selects one of the program part prototypes from the program part prototype library by referring to the analysis table. The selection criterion is based on the selection rules by the class and the variable type prepared in the part prototype library. 
     FIG. 6 shows the selection rule and the program part prototype selected in accordance with the selection rule. The first line of FIG. 6 shows the selection rule. The selection rule in the present embodiment is class, variable type and variable size. The selection rule determined by the data declaration statement and the class shown in FIG. 3 belongs to a class &#34;retrieval table&#34;, in which the variable type is struct and the variable size is not zero. 
     The program part prototype shown in FIG. 6 matches to this selection rule. In a step 105, the processing unit 22 performs the macro substitution by using $(----) in the program part prototype as a macro name while referencing the structure analysis table shown in FIG. 5 and prepared in the step 103. 
     In FIG. 6, % for -- % end for indicates that each element is to be repeatedly substituted if the condition of line 8 in FIG. 6 is met. The condition of line 8 indicates that the element is not a key element or not &#34;1&#34;. From FIGS. 3 and 5, the element 2 is not a key element but the element 1 is a key element. Accordingly, only the element 2 meets the condition and only the element 2 repeatedly develops the line 9 et seq. % if -- % endif indicates that the development of the line 9 et seq is to be performed when a condition, that is, the condition of the line 9 is met. The condition of the line 9 indicates that the element size is not zero and the element size of the first element is also not zero. In this case, the element 1 is not required to be considered. Thus, from FIGS. 3 and 5, the element size of the element 2 is 16 bytes and hence the above condition is met. Accordingly, the substitution is made only for the element 2 in the line 10 et seq. 
     As a result of the macro substitution or program generation in the step 105, the program part shown in FIG. 7 is generated. This program part is stored in the memory unit 24. 
     In FIG. 7, lines 1-4 represent the data declaration statement. The processing in {} in lines 13-22 is repeated by the variable size, that is, 100 times so that the table of FIG. 4 is prepared. Thus, the retrieval table having keys as the macro names is prepared. 
     As described above, since the program part of FIG. 5 has a control statement % for or information which allows modification of the program, any number of elements may be included. Further, since it has a control statement % if, any element type may be used. Furthermore, it has a control statement $(), so that any macro name may be used. 
     When the program prototype is modified (macro substitution), not only the simple substitution of the macros but also conditional substitution (% if) or repetitive substitution (% for) can be carried out. Through the function, one program prototype can be flexibly applied to various data without addition or modification. 
     In the retrieval table used in the present embodiment, operation methods for initialization, setting and reference are generated. Whatever the number and the type of elements, the steps are similar and an appropriate program part for the data can be generated from one program part prototype. Since no manual modification or addition is required, the test of the developed program may be omitted and the productivity and reliability are improved. 
     While the present embodiment describes the program part when the class is the retrieval table, the present invention is not limited thereto but it can be applied to the program parts of other class. 
     In accordance with the present invention, a highly reliable program can be automatically generated without manual addition or modification. Further, since the program part prototype can be automatically selected in accordance with the selection rule, the productivity of the software can be significantly improved.