JPH06100971B2 - Translation processing method - Google Patents

Translation processing method

Info

Publication number
JPH06100971B2
JPH06100971B2 JP24184788A JP24184788A JPH06100971B2 JP H06100971 B2 JPH06100971 B2 JP H06100971B2 JP 24184788 A JP24184788 A JP 24184788A JP 24184788 A JP24184788 A JP 24184788A JP H06100971 B2 JPH06100971 B2 JP H06100971B2
Authority
JP
Japan
Prior art keywords
information
translation
common information
definition
translation unit
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
JP24184788A
Other languages
Japanese (ja)
Other versions
JPH0290233A (en
Inventor
恭子 羽中田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP24184788A priority Critical patent/JPH06100971B2/en
Publication of JPH0290233A publication Critical patent/JPH0290233A/en
Publication of JPH06100971B2 publication Critical patent/JPH06100971B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Description

【発明の詳細な説明】 〔産業上の利用分野〕 本発明は翻訳処理方式に関し、特に翻訳単位間で共通な
情報である共通データや共通手続き(以下、共通情報と
称する)の定義と参照とを別々の翻訳単位に記述可能な
高級プログラミング言語で記述された原始プログラムを
翻訳して目的プログラムを生成するコンパイラにおける
翻訳処理方式に関する。
Description: TECHNICAL FIELD The present invention relates to a translation processing method, and particularly, to definition and reference of common data and common procedures (hereinafter referred to as common information) that are common information between translation units. The present invention relates to a translation processing method in a compiler that translates a source program written in a high-level programming language that can be written into different translation units to generate an object program.

〔従来の技術〕[Conventional technology]

従来、この種の翻訳処理方式では、翻訳単位間の共通情
報の定義と参照とを別々の翻訳単位に記述可能な高級プ
ログラミング言語で記述された原始プログラムを翻訳す
る場合に、共通情報の参照を含む翻訳単位は、参照すべ
き共通情報の定義を含む翻訳単位の翻訳が成功して目的
プログラムが生成された結果として生成される当該共通
情報の定義情報を参照して翻訳している。
Conventionally, in this type of translation processing method, when translating a source program written in a high-level programming language in which definitions and references of common information between translation units can be described in different translation units, the reference of common information is referred to. The included translation unit is translated by referring to the definition information of the common information generated as a result of successful translation of the translation unit including the definition of the common information to be referenced and the generation of the target program.

〔発明が解決しようとする課題〕[Problems to be Solved by the Invention]

上述した従来の翻訳処理方式では、共通情報の参照を含
む翻訳単位は、参照すべき共通情報の定義情報を参照し
なければならないので、コンパイラの利用者は、共通情
報の定義を含む翻訳単位が当該共通情報の参照を含む翻
訳単位よりも前に翻訳されるように意識して原始プログ
ラムを記述したり、共通情報の定義を含む翻訳単位を当
該共通情報の参照を含む翻訳単位よりも前に翻訳される
ように翻訳の指示を出さなければならないという欠点が
ある。
In the above-described conventional translation processing method, the translation unit including the reference of the common information must refer to the definition information of the common information to be referred to, so the compiler user can confirm that the translation unit including the definition of the common information is Write the source program with the intention that it will be translated before the translation unit that contains the reference to the common information, or put the translation unit that contains the definition of the common information before the translation unit that contains the reference to the common information. It has the drawback of having to give instructions for translation to be translated.

本発明の目的は、上述の点に鑑み、コンパイラの利用者
が共通情報の定義を含む翻訳単位が当該共通情報の参照
を含む翻訳単位よりも前に翻訳されるように意識して原
始プログラムを記述したり、翻訳の指示を出したりしな
くても共通情報の定義と参照とが別々の翻訳単位に記述
された原始プログラムを翻訳することができる翻訳処理
方式を提供することにある。
In view of the above points, an object of the present invention is to allow a user of a compiler to consider that a translation unit including a definition of common information is translated before a translation unit including a reference to the common information. It is an object of the present invention to provide a translation processing method capable of translating a source program in which the definition and reference of common information are described in different translation units without writing or issuing a translation instruction.

〔課題を解決するための手段〕[Means for Solving the Problems]

本発明の翻訳処理方式は、翻訳単位間の共通情報の定義
と参照とを別々の翻訳単位に記述可能であり共通情報の
参照を含む翻訳単位が参照すべき共通情報の定義を含む
翻訳単位を翻訳して生成される共通情報の定義情報を参
照して翻訳される高級プログラミング言語で記述された
原始プログラムを入力して目的プログラムを生成するコ
ンパイラにおいて、前記原始プログラムの翻訳処理を翻
訳単位毎に行い翻訳処理中の翻訳単位が共通情報の参照
を含む場合には参照すべき共通情報の定義情報が共通情
報定義情報ファイルに存在するか否かと参照すべき共通
情報に関する情報とを翻訳処理中の翻訳単位の翻訳単位
名とともに共通情報格納領域に格納して参照すべき共通
情報の定義情報が前記共通情報定義情報ファイルに存在
すれば前記共通情報定義情報ファイルから参照すべき共
通情報の定義情報を入力して翻訳し翻訳処理中の翻訳単
位が共通情報の定義を含む場合には定義している共通情
報に関する情報を翻訳処理中の翻訳単位の翻訳単位名と
ともに共通情報格納領域に格納して当該翻訳単位の目的
プログラムが生成されたならばその結果生成される定義
している共通情報の定義情報を前記共通情報定義情報フ
ァイルに出力する翻訳処理手段と、この翻訳処理手段に
より1つの翻訳単位の翻訳処理が終了する毎に目的プロ
グラムが生成されたか否かと参照すべき共通情報の定義
情報が前記共通情報定義情報ファイルに存在しないため
に目的プログラムが生成されなかった翻訳単位であれば
再度翻訳処理をするのに必要な情報とを当該翻訳単位の
翻訳単位名とともに翻訳単位結果情報として翻訳単位結
果情報格納領域に格納する翻訳結果情報処理手段と、前
記原始プログラムの全ての翻訳単位についての前記翻訳
処理手段および前記翻訳結果情報処理手段による処理が
終了した後に前記翻訳単位結果情報格納領域に格納され
た翻訳単位結果情報を基に参照すべき共通情報の定義情
報が前記共通情報定義情報ファイルに存在しなかったた
めに目的プログラムが生成されなかった翻訳単位を抜き
出して当該翻訳単位の前記共通情報格納領域の参照すべ
き共通情報に関する情報を基に前記共通情報定義情報フ
ァイルおよび前記共通情報格納領域を参照することによ
り前記共通情報定義情報ファイルに参照すべき共通情報
の定義情報が存在しなかったために目的プログラムが生
成されなかった翻訳単位のうちから参照すべき共通情報
の定義情報が現在前記共通情報定義情報ファィルに存在
するために再翻訳可能な翻訳単位と参照すべき共通情報
の定義を含む翻訳単位との間の翻訳順序を入れ替えるこ
とで再翻訳可能な翻訳単位とを抽出して必要であれば再
翻訳処理の順序を入れ替えた後に再翻訳可能な翻訳単位
の前記翻訳単位結果情報格納領域の再翻訳処理をするの
に必要な情報を渡して前記翻訳処理手段に再翻訳可能な
翻訳単位の再翻訳処理を指示する再翻訳処理手段とを有
する。
According to the translation processing method of the present invention, a definition and reference of common information between translation units can be described in different translation units, and a translation unit including a definition of common information to be referred to by a translation unit including a reference of common information In a compiler for generating a target program by inputting a source program written in a high-level programming language that is translated by referring to definition information of common information generated by translation, a translation process of the source program is performed for each translation unit. If the translation unit being processed for translation includes a reference to common information, whether the definition information for the common information to be referenced exists in the common information definition information file and information on the common information to be referenced are If the definition information of the common information to be stored and referenced in the common information storage area together with the translation unit name of the translation unit exists in the common information definition information file, the common information If you enter the definition information of the common information to be referenced from the definition information file and translate it, and the translation unit being translated contains the definition of common information, the information about the defined common information is A translation that stores the definition information of the defined common information, which is generated as a result of storing the translation unit name in the common information storage area in the common information storage area and generating the target program of the translation unit, to the common information definition information file The processing means and whether or not a target program is generated each time the translation processing of one translation unit is completed by the translation processing means and definition information of common information to be referred to is not present in the common information definition information file. For a translation unit for which a program has not been generated, the information necessary to perform the translation process again together with the translation unit result information together with the translation unit name of the translation unit. Translation result information storage means for storing in the translation unit result information storage area, and the translation unit result information storage after processing by the translation processing means and the translation result information processing means for all translation units of the source program is completed. The definition information of the common information to be referenced based on the translation unit result information stored in the area does not exist in the common information definition information file, and thus the translation unit for which the target program is not generated is extracted and There is definition information of common information to be referred to in the common information definition information file by referring to the common information definition information file and the common information storage area based on information about common information to be referred to in the common information storage area. Common information to be referenced from the translation units for which the target program was not generated because Definition information currently exists in the common information definition information file, the translation unit can be retranslated by exchanging the translation order between the retranslatable translation unit and the translation unit containing the definition of the common information to be referenced. And the information necessary for performing the retranslation process of the translation unit result information storage area of the retranslatable translation unit is passed after exchanging the order of the retranslation process if necessary. And a retranslation processing unit for instructing the retranslation processing of the retranslatable translation unit.

〔作用〕[Action]

本発明の翻訳処理方式では、翻訳処理手段が原始プログ
ラムの翻訳処理を翻訳単位毎に行い翻訳処理中の翻訳単
位が共通情報の参照を含む場合には参照すべき共通情報
の定義情報が共通情報定義情報ファイルに存在するか否
かと参照すべき共通情報に関する情報とを翻訳処理中の
翻訳単位の翻訳単位名とともに共通情報格納領域に格納
して参照すべき共通情報の定義情報が共通情報定義情報
ファイルに存在すれば共通情報定義情報ファイルから参
照すべき共通情報の定義情報を入力して翻訳し翻訳処理
中の翻訳単位が共通情報の定義を含む場合には定義して
いる共通情報に関する情報を翻訳処理中の翻訳単位の翻
訳単位名とともに共通情報格納領域に格納して当該翻訳
単位の目的プログラムが生成されたならばその結果生成
される定義している共通情報の定義情報を共通情報定義
情報ファイルに出力し、翻訳結果情報処理手段が翻訳処
理手段により1つの翻訳単位の翻訳処理が終了する毎に
目的プログラムが生成されたか否かと参照すべき共通情
報の定義情報が共通情報定義情報ファイルに存在しない
ために目的プログラムが生成されなかった翻訳単位であ
れば再度翻訳処理をするのに必要な情報とを当該翻訳単
位の翻訳単位名とともに翻訳単位結果情報として翻訳単
位結果情報格納領域に格納し、再翻訳処理手段が原始プ
ログラムの全ての翻訳単位についての翻訳処理手段およ
び翻訳結果情報処理手段による処理が終了した後に翻訳
単位結果情報格納領域に格納された翻訳単位結果情報を
基に参照すべき共通情報の定義情報が共通情報定義情報
ファイルに存在しなかったために目的プログラムが生成
されなかった翻訳単位を抜き出して当該翻訳単位の共通
情報格納領域の参照すべき共通情報に関する情報を基に
共通情報定義情報ファイルおよび共通情報格納領域を参
照することにより共通情報定義情報ファイルに参照すべ
き共通情報の定義情報が存在しなかったために目的プロ
グラムが生成されなかった翻訳単位のうちから参照すべ
き共通情報の定義情報が現在共通情報定義情報ファィル
に存在するために再翻訳可能な翻訳単位と参照すべき共
通情報の定義を含む翻訳単位との間の翻訳順序を入れ替
えることで再翻訳可能な翻訳単位とを抽出して必要であ
れば再翻訳処理の順序を入れ替えた後に再翻訳可能な翻
訳単位の翻訳単位結果情報格納領域の再翻訳処理をする
のに必要な情報を渡して翻訳処理手段に再翻訳可能な翻
訳単位の再翻訳処理を指示する。
In the translation processing method of the present invention, when the translation processing unit performs the translation processing of the source program for each translation unit and the translation unit being translated includes a reference to the common information, the definition information of the common information to be referred to is the common information. The definition information of the common information that should be referred to by storing in the common information storage area together with the translation unit name of the translation unit being translated, whether the definition information file exists and the information related to the common information If it exists in the file, enter the definition information of the common information to be referenced from the common information definition information file and translate it. If the translation unit being translated contains the definition of the common information, information about the defined common information Is stored in the common information storage area together with the name of the translation unit being translated and the target program for that translation unit is created. The definition information of the common information is output to the common information definition information file, and the translation result information processing means refers to whether or not the object program is generated every time the translation processing means completes the translation processing of one translation unit, and the common information to be referred to. Definition information does not exist in the common information definition information file, the translation unit result information together with the translation unit name of the translation unit and the information necessary for reprocessing the translation unit for which the target program was not generated Stored in the translation unit result information storage area, and stored in the translation unit result information storage area after the retranslation processing means has finished processing by the translation processing means and the translation result information processing means for all the translation units of the source program. The definition information of common information to be referenced based on the translation unit result information does not exist in the common information definition information file. A common information definition information file by extracting a translation unit for which a program has not been generated and referring to the common information definition information file and the common information storage area based on the information related to the common information to be referenced in the common information storage area of the translation unit A target program was not created because there was no definition information of common information to be referenced in the translation unit. Retranslation is possible because the definition information of the common information to be referenced is currently present in the common information definition information file. Retranslatable translation units by exchanging the translation order between the translation unit and the translation unit containing the definition of the common information to be referenced, and if necessary, after reordering the retranslation process. The information necessary for retranslating the translation unit result information storage area of the translatable translation unit is passed to the translation processing means. Instruct retranslation processing of translation units.

〔実施例〕〔Example〕

次に、本発明について図面を参照して詳細に説明する。 Next, the present invention will be described in detail with reference to the drawings.

第1図は、本発明の一実施例の翻訳処理方式が適用され
たコンパイラ10の構成を示すブロック図である。このコ
ンパイラ10は、共通情報格納領域10aと、翻訳単位結果
情報格納領域10bと、翻訳処理手段11と、翻訳結果情報
処理手段12と、再翻訳処理手段13とを含んで構成されて
おり、原始プログラム2が格納されている入力原始プロ
グラムファイル1および共通情報定義情報4が格納され
る共通情報定義情報ファイル3に対してアクセス可能と
なっている。
FIG. 1 is a block diagram showing the configuration of a compiler 10 to which the translation processing method of one embodiment of the present invention is applied. The compiler 10 is configured to include a common information storage area 10a, a translation unit result information storage area 10b, a translation processing means 11, a translation result information processing means 12, and a retranslation processing means 13. The input source program file 1 in which the program 2 is stored and the common information definition information file 3 in which the common information definition information 4 is stored are accessible.

次に、このように構成された本実施例の翻訳処理方式の
動作について説明する。
Next, the operation of the translation processing system of this embodiment configured as described above will be described.

コンパイラ10が入力原始プログラムファイル1中の原始
プログラム2を入力すると、翻訳処理手段11は、入力さ
れた原始プログラム2の翻訳処理を翻訳単位毎に行う。
When the compiler 10 inputs the source program 2 in the input source program file 1, the translation processing means 11 performs the translation processing of the source program 2 input for each translation unit.

任意の翻訳単位の翻訳処理中に共通情報の参照が現れた
ならば、翻訳処理手段11は、共通情報定義情報ファイル
3を検索して参照すべき共通情報の定義情報が存在する
か否かを調べて、参照すべき共通情報の定義情報が共通
情報定義情報ファイル3に存在するか否かと参照すべき
共通情報に関する情報とを翻訳処理中の翻訳単位の翻訳
単位名とともに共通情報格納領域10aに格納し、参照す
べき共通情報の定義情報が共通情報定義情報ファイル3
に存在した場合には当該共通情報の定義情報を参照して
翻訳する。また、翻訳処理中の翻訳単位が共通情報の定
義を含むならば、翻訳処理手段11は、定義している共通
情報に関する情報を共通情報格納領域10aに格納して翻
訳する。
If a reference to the common information appears during the translation processing of an arbitrary translation unit, the translation processing means 11 searches the common information definition information file 3 to determine whether the definition information of the common information to be referred to exists. Whether the definition information of the common information to be referenced exists in the common information definition information file 3 and the information about the common information to be referenced are stored in the common information storage area 10a together with the translation unit name of the translation unit being translated. Definition information of common information to be stored and referred to is common information definition information file 3
If the common information is present, it is translated by referring to the definition information of the common information. If the translation unit being translated includes the definition of common information, the translation processing means 11 stores the information about the defined common information in the common information storage area 10a and translates it.

さらに、翻訳処理手段11は、共通情報の定義を含む翻訳
単位の翻訳に成功して目的プログラムが生成されたなら
ば、その結果として生成される定義している共通情報の
定義情報と翻訳処理を行った翻訳単位の翻訳単位名とを
共通情報定義情報4として共通情報定義情報ファイル3
に出力する。
Furthermore, when the translation unit including the definition of the common information is successfully translated and the target program is generated, the translation processing unit 11 executes the definition information and the translation processing of the defined common information generated as a result. The common information definition information file 3 is used as the common information definition information 4 together with the translation unit name of the translation unit that has been executed.
Output to.

翻訳結果情報処理手段12は、翻訳処理手段11において1
翻訳単位の翻訳処理が終了する毎に、翻訳処理が終了し
た翻訳単位の翻訳単位名,目的プログラムか生成された
か否か,参照すべき共通情報の定義情報が共通情報定義
情報ファイル3に存在しなかったために目的プログラム
が生成されなかった翻訳単位(以下、参照情報不足翻訳
単位と称する)ならば翻訳単位が格納されているファイ
ルのファイル名および当該ファイル内での位置情報等か
らなる再翻訳処理をするのに必要な情報等を翻訳単位結
果情報として翻訳単位結果情報格納領域10bに格納す
る。
The translation result information processing means 12 is 1 in the translation processing means 11.
Each time the translation process of the translation unit is completed, the translation unit name of the translation unit for which the translation process is completed, whether or not the target program is generated, definition information of common information to be referred to exists in the common information definition information file 3. If it is a translation unit for which the target program was not generated (hereinafter referred to as a reference information-deficient translation unit), a re-translation process consisting of the file name of the file in which the translation unit is stored and the position information within the file, etc. The information and the like necessary for executing is stored in the translation unit result information storage area 10b as the translation unit result information.

翻訳処理手段11および翻訳結果情報処理手段12は、原始
プログラム2内の全ての翻訳単位について上記の処理を
繰り返して行う。
The translation processing means 11 and the translation result information processing means 12 repeat the above processing for all the translation units in the source program 2.

コンパイラ10に入力された原始プログラム2の全ての翻
訳単位について翻訳処理手段11および翻訳結果情報処理
手段12による処理が終了したならば、再翻訳処理手段13
は、翻訳単位結果情報格納領域10bの再翻訳処理をする
のに必要な情報を基に参照情報不足翻訳単位を全て検出
する。次に、再翻訳処理手段13は、検出された参照情報
不足翻訳単位が参照すべき共通情報の定義情報名を共通
情報格納領域10aの参照情報不足翻訳単位の参照すべき
共通情報に関する情報から取り出して、参照すべき共通
情報の定義情報が現在共通情報定義情報ファイル3に存
在するか否かを調べる。その結果、参照情報不足翻訳単
位が参照すべき全ての共通情報の定義情報が共通情報定
義情報ファイル3に存在したならば、再翻訳処理手段13
は、この参照情報不足翻訳単位を再翻訳可能とする。参
照情報不足翻訳単位が参照すべき共通情報の定義情報が
共通情報定義情報ファイル3に存在しなければ、再翻訳
処理手段13は、当該共通情報の定義情報名を基に共通情
報格納領域10aからこの参照情報不足翻訳単位が参照す
べき共通情報を定義している翻訳単位を検索し、当該共
通情報を定義している翻訳単位が見つかったならば当該
翻訳単位の翻訳単位名を基に翻訳単位結果情報格納領域
10bを参照して当該翻訳単位が参照情報不足翻訳単位で
あるかどうかを調べる。当該翻訳単位が参照情報不足翻
訳単位であれば、再翻訳処理手段13は、この参照情報不
足翻訳単位(共通情報定義情報ファイル3には参照すべ
き共通情報の定義情報の全ては存在していないが、参照
すべき共通情報を定義している参照情報不足翻訳単位が
存在する翻訳単位)を順序制限付きで再翻訳可能とす
る。
When all the translation units of the source program 2 input to the compiler 10 have been processed by the translation processing means 11 and the translation result information processing means 12, the retranslation processing means 13
Detects all reference information-deficient translation units based on the information necessary for retranslating the translation unit result information storage area 10b. Next, the re-translation processing unit 13 extracts the definition information name of the common information to be referenced by the detected reference information-deficient translation unit from the information related to the common information to be referenced by the reference information-deficient translation unit in the common information storage area 10a. Then, it is checked whether or not the definition information of the common information to be referenced currently exists in the common information definition information file 3. As a result, if the definition information of all the common information to be referred to by the reference information-deficient translation unit exists in the common information definition information file 3, the retranslation processing means 13
Makes it possible to retranslate this translation unit lacking reference information. If the definition information of the common information to be referred to by the reference information-deficient translation unit does not exist in the common information definition information file 3, the re-translation processing unit 13 extracts the common information from the common information storage area 10a based on the definition information name of the common information. When a translation unit that defines common information that this translation information-deficient translation unit should refer to is found and a translation unit that defines the common information is found, the translation unit is translated based on the translation unit name of the translation unit. Result information storage area
Refer to 10b to check whether or not the translation unit is a reference information-deficient translation unit. If the translation unit is a reference information-deficient translation unit, the re-translation processing unit 13 does not include all of the definition information of the common information to be referred to in the reference information-deficient translation unit (common information definition information file 3). However, a translation unit in which a reference information-deficient translation unit that defines common information to be referenced exists) can be retranslated with an order restriction.

再翻訳処理手段13は、翻訳単位結果情報格納領域10bか
ら検出した全ての参照情報不足翻訳単位について上記の
処理を行って、再翻訳可能な翻訳単位および翻訳順序制
限付きで再翻訳可能な翻訳単位を全て選択する。次に、
再翻訳処理手段13は、選択した全ての再翻訳可能な翻訳
単位および順序制限付きで再翻訳可能な翻訳単位の間の
共通情報の定義と参照との依存関係を調べ、共通情報の
定義を含む翻訳単位を当該共通情報の参照を含む翻訳単
位よりも前に翻訳するように選択した翻訳単位の翻訳順
序を並びに替えた後に、選択した翻訳単位の再翻訳処理
を翻訳処理手段11に指示する。
The re-translation processing unit 13 performs the above-mentioned processing for all the reference information-deficient translation units detected from the translation-unit result information storage area 10b, and re-translatable translation units and re-translatable translation units with translation order restrictions. Select all. next,
The re-translation processing means 13 checks the definition of common information between all selected re-translatable translation units and re-translatable translation units with order restrictions and the dependency relation with the reference, and includes the definition of common information. After changing the translation order of the translation unit selected so that the translation unit is translated before the translation unit including the reference of the common information, the translation processing unit 11 is instructed to retranslate the selected translation unit.

次に、共通情報定義情報ファイル3が第2図(c)に示
すようになっているときに、第2図(a)および(b)
に示す原始プログラム2aおよび2bを翻訳する場合につい
て具体的に説明する。
Next, when the common information definition information file 3 is as shown in FIG. 2 (c), FIG. 2 (a) and (b)
The case of translating the source programs 2a and 2b shown in will be specifically described.

第2図(a)に示す原始プログラム2aは、翻訳単位名が
Aで共通情報B1および共通情報C1の参照を含む翻訳単位
21と、翻訳単位名がBで共通情報B1の定義を含む翻訳単
位22と、翻訳単位名がCで共通情報C1の定義および共通
情報E1の参照を含む翻訳単位23と、翻訳単位名がDで共
通情報H1の参照を含む翻訳単位24との4個の翻訳単位か
らなる原始プログラム2である。
The source program 2a shown in FIG. 2 (a) has a translation unit name of A and a translation unit including references to common information B1 and common information C1.
21, a translation unit 22 having a translation unit name of B and a definition of common information B1, a translation unit 23 having a translation unit name of C and a definition of common information C1 and a reference of common information E1, and a translation unit name of D The source program 2 is composed of four translation units including the translation unit 24 including the reference of the common information H1.

第2図(b)に示す原始プログラム2bは、翻訳単位名が
Eで共通情報E1の定義を含む翻訳単位25と、翻訳単位名
がFで共通情報B1の参照を含む翻訳単位26と、翻訳単位
名がGで共通情報I1の参照を含む翻訳単位27との3個の
翻訳単位からなる原始プログラム2である。
The source program 2b shown in FIG. 2 (b) includes a translation unit 25 having a translation unit name E and a definition of common information E1, a translation unit 26 having a translation unit name F and a reference to common information B1, and a translation The source program 2 is composed of three translation units, a unit name of which is G and a translation unit 27 which includes a reference to the common information I1.

第2図(c)に示す共通情報定義情報ファイル3には、
翻訳単位名がHで共通情報H1の定義情報h1および共通情
報H2の定義情報h2を含む共通情報定義情報4hが格納され
ている。
In the common information definition information file 3 shown in FIG. 2 (c),
The translation unit name is H, and common information definition information 4h including definition information h1 of common information H1 and definition information h2 of common information H2 is stored.

なお、原始プログラム2aおよび原始プログラム2bの各々
の翻訳単位は、翻訳処理中に参照すべき共通情報の定義
情報が共通情報定義情報ファイル3に存在すれば当該共
通情報の定義情報を参照することにより翻訳されて目的
プログラムが生成されるものとし、また、目的プログラ
ムが生成された翻訳単位において定義されている共通情
報の定義情報は共通情報定義情報ファイル3に出力され
るものとする。
It should be noted that each of the translation units of the source program 2a and the source program 2b can refer to the definition information of the common information if the definition information of the common information to be referred to during the translation process exists in the common information definition information file 3. It is assumed that the object program is translated and the definition information of the common information defined in the translation unit in which the object program is created is output to the common information definition information file 3.

コンパイラ10の翻訳処理手段11は、まず、原始プログラ
ム2aを入力し、原始プログラム2a内の記述に従って翻訳
処理を翻訳単位21,22,23および24の翻訳順序で翻訳単位
毎に行う。
The translation processing means 11 of the compiler 10 first inputs the source program 2a, and performs translation processing for each translation unit in the translation order of the translation units 21, 22, 23 and 24 according to the description in the source program 2a.

最初に翻訳処理が行われる翻訳単位21の翻訳処理中に共
通情報B1の参照が現れたならば、翻訳処理手段11は、共
通情報定義情報ファイル3を検索して共通情報B1の定義
情報b1が存在するか否かを調べる。ここでは、共通情報
B1の定義情報b1は共通情報定義情報ファイル3内に存在
しないので、翻訳処理手段11は、参照すべき共通情報B1
の定義情報b1が共通情報定義情報ファイル3に存在しな
いことと参照すべき共通情報B1に関する情報とを翻訳単
位名Aとともに共通情報格納領域10aに格納する。共通
情報C1の参照が現れた場合にも、翻訳処理手段11は、共
通情報B1の参照が現れた場合と同様の処理を行う。翻訳
単位21は、参照すべき共通情報B1の定義情報b1および共
通情報C1の定義情報c1が存在しないために、目的プログ
ラムは生成されない。
When a reference to the common information B1 appears during the translation process of the translation unit 21 in which the translation process is first performed, the translation processing unit 11 searches the common information definition information file 3 to find the definition information b1 of the common information B1. Check if it exists. Here is the common information
Since the definition information b1 of B1 does not exist in the common information definition information file 3, the translation processing means 11 requires the common information B1 to be referred to.
The definition information b1 of No. exists in the common information definition information file 3 and the information about the common information B1 to be referred to are stored in the common information storage area 10a together with the translation unit name A. Even when the reference of the common information C1 appears, the translation processing unit 11 performs the same process as when the reference of the common information B1 appears. No target program is generated in the translation unit 21 because the definition information b1 of the common information B1 to be referred to and the definition information c1 of the common information C1 do not exist.

翻訳単位21の翻訳処理が終了すると、翻訳結果情報処理
手段12は、翻訳単位名A,目的プログラムの生成ができな
かったこと,参照情報不足翻訳単位であるので翻訳単位
21を再翻訳処理するのに必要な情報等からなる翻訳単位
21の翻訳単位結果情報を翻訳単位結果情報格納領域10b
に格納する。
When the translation processing of the translation unit 21 is completed, the translation result information processing means 12 determines that the translation unit name A, the target program could not be generated, and the translation information lacking translation unit.
Translation unit consisting of information necessary for retranslating 21
21 translation unit result information storage area 10b
To store.

次に翻訳処理される翻訳単位22は共通情報B1の定義を含
むので、翻訳処理手段11は、翻訳単位22が定義している
共通情報B1に関する情報を翻訳単位名Bとともに共通情
報格納領域10aに格納する。翻訳単位22は、共通情報B1
の定義を含むだけなので目的プログラムが生成される。
翻訳単位22の目的プログラムが生成されると、翻訳処理
手段11は、共通情報B1の定義情報b1と翻訳単位名Bとか
らなる共通情報定義情報4bを共通情報定義情報ファイル
3に出力する。
Since the translation unit 22 to be translated next includes the definition of the common information B1, the translation processing unit 11 stores the information about the common information B1 defined by the translation unit 22 in the common information storage area 10a together with the translation unit name B. Store. Translation unit 22 is common information B1
The target program is generated because it only includes the definition of.
When the target program of the translation unit 22 is generated, the translation processing means 11 outputs the common information definition information 4b including the definition information b1 of the common information B1 and the translation unit name B to the common information definition information file 3.

翻訳単位22の翻訳が終了すると、翻訳結果情報処理手段
12は、翻訳単位名B,目的プログラムの生成ができたこと
等からなる翻訳単位22の翻訳単位結果情報を翻訳単位結
果情報格納領域10bに格納する。
When the translation of the translation unit 22 is completed, the translation result information processing means
Reference numeral 12 stores the translation unit result information of the translation unit 22 including the translation unit name B and the generation of the target program in the translation unit result information storage area 10b.

原始プログラム2aおよび2bの全ての翻訳単位に対して、
翻訳処理手段11および翻訳結果情報処理手段12は同様の
処理を行う。
For all translation units of source programs 2a and 2b,
The translation processing means 11 and the translation result information processing means 12 perform similar processing.

上記の処理の結果、翻訳単位22,24,25および26は目的プ
ログラムが生成され、翻訳単位21,23および27は翻訳処
理手段11による翻訳処理時に参照すべき共通情報の定義
情報が共通情報定義情報ファイル3に存在しないために
目的プログラムは生成されない。
As a result of the above processing, the translation units 22, 24, 25, and 26 generate the target program, and the translation units 21, 23, and 27 have the common information definition information of the common information to be referred to during the translation processing by the translation processing means 11. The object program is not generated because it does not exist in the information file 3.

したがって、翻訳単位結果情報格納領域10bにおいて、
翻訳単位21,23および27の翻訳単位結果情報は、翻訳単
位21,23および27が参照情報不足翻訳単位であることを
示している。
Therefore, in the translation unit result information storage area 10b,
The translation unit result information of the translation units 21, 23 and 27 indicates that the translation units 21, 23 and 27 are reference information-deficient translation units.

また、共通情報定義情報ファイル3には、翻訳単位名H
と共通情報H1の定義情報h1および共通情報H2の定義情報
h2とからなる共通情報定義情報4hと、翻訳単位名Bと共
通情報B1の定義情報b1とからなる共通情報定義情報4b
と、翻訳単位名Eと共通情報E1の定義情報e1とからなる
共通情報定義情報4eとが格納されている。
In addition, in the common information definition information file 3, the translation unit name H
And definition information for common information H1 and definition information for common information H2
Common information definition information 4h including h2 and common information definition information 4b including translation unit name B and definition information b1 of common information B1
And the common information definition information 4e including the translation unit name E and the definition information e1 of the common information E1 are stored.

なお、共通情報格納領域10aには、各翻訳単位21,22,23,
24,25,26および27毎に参照すべき共通情報が共通情報定
義情報ファイル3に存在するか否か,参照すべき共通情
報に関する情報および定義している共通情報に関する情
報が格納されている。
In the common information storage area 10a, each translation unit 21, 22, 23,
It stores whether common information to be referenced for each of 24, 25, 26 and 27 exists in the common information definition information file 3, information on common information to be referenced, and information on defined common information.

原始プログラム2aおよび2bの全ての翻訳単位についての
翻訳処理手段11および翻訳結果情報処理手段12による処
理が終了すると、再翻訳処理手段13は、翻訳単位結果情
報格納領域10bの各翻訳単位の翻訳単位結果情報を基
に、参照情報不足翻訳単位(参照情報不足翻訳単位の翻
訳単位名)を検出する。ここでは、参照情報不足翻訳単
位21,23および27の翻訳単位名A,CおよびGが検出され
る。
When the processing by the translation processing unit 11 and the translation result information processing unit 12 for all the translation units of the source programs 2a and 2b is completed, the retranslation processing unit 13 causes the translation unit of each translation unit in the translation unit result information storage area 10b to be translated. A translation unit lacking reference information (translation unit name of the translation unit lacking reference information) is detected based on the result information. Here, the translation unit names A, C and G of the reference information-deficient translation units 21, 23 and 27 are detected.

続いて、再翻訳処理手段13は、まず、参照情報不足翻訳
単位21の翻訳単位名Aを基に共通情報格納領域10aから
参照情報不足翻訳単位21が参照すべき共通情報B1および
C1に関する情報を取り出す。次に、再翻訳処理手段13
は、取り出した共通情報B1およびC1に関する情報を基に
共通情報B1の定義情報b1および共通情報C1の定義情報c1
が現在共通情報定義情報ファイル3に存在するか否かを
調べる。共通情報定義情報ファイル3に共通情報B1の定
義情報b1は存在するが、共通情報C1の定義情報c1は存在
しないので、再翻訳処理手段13は、次に、共通情報格納
領域10aを検索して共通情報C1を定義している翻訳単位
が存在するかどうかを調べる。定義している共通情報C1
に関する情報を持っている翻訳単位名Cの翻訳単位23が
存在するので、再翻訳処理手段13は、続いて、翻訳単位
結果情報格納領域10bの翻訳単位23の翻訳単位結果情報
を参照して翻訳単位23が参照情報不足翻訳単位であるこ
とを認識し、翻訳単位21を翻訳順序制限付きで再翻訳可
能とする。
Then, the re-translation processing means 13 firstly, based on the translation unit name A of the reference information-deficient translation unit 21, the common information B1 and the common information B1 which the reference information-deficient translation unit 21 should refer to from the common information storage area 10a.
Retrieve information about C1. Next, the retranslation processing means 13
Is the definition information b1 of the common information B1 and the definition information c1 of the common information C1 based on the extracted information about the common information B1 and C1.
Is present in the common information definition information file 3 is checked. The definition information b1 of the common information B1 exists in the common information definition information file 3, but the definition information c1 of the common information C1 does not exist, so the re-translation processing unit 13 next searches the common information storage area 10a. Check whether the translation unit that defines the common information C1 exists. Common information defined C1
Since the translation unit 23 having the translation unit name C having the information about the translation unit exists, the re-translation processing unit 13 subsequently refers to the translation unit result information of the translation unit 23 in the translation unit result information storage area 10b to translate the translation unit. Recognizing that the unit 23 is a translation unit lacking reference information, the translation unit 21 can be retranslated with translation order restriction.

再翻訳処理手段13は、翻訳単位23および27についても同
様の処理を行う。
The re-translation processing means 13 also performs the same processing for the translation units 23 and 27.

この結果、翻訳単位23は、参照すべき共通情報E1の定義
情報e1が共通情報定義情報ファイル3に存在するので、
再翻訳可能とされる。
As a result, in the translation unit 23, since the definition information e1 of the common information E1 to be referenced exists in the common information definition information file 3,
Retranslatable.

また、翻訳単位27は、参照すべき共通情報11の定義情報
i1が共通情報報定義情報ファイル3に存在せず、かつ、
共通情報11を定義している参照情報不足翻訳単位もない
ので、再翻訳不可能とされる。
Also, the translation unit 27 is the definition information of the common information 11 to be referred to.
i1 does not exist in the common information report definition information file 3, and
Since there is no reference information-deficient translation unit that defines the common information 11, retranslation is not possible.

したがって、再翻訳処理手段13は、参照情報不足翻訳単
位21,23および27のうち、翻訳順序制限付きで再翻訳可
能な翻訳単位21および再翻訳可能な翻訳単位23を選択し
て、翻訳単位21に含まれる共通情報B1および共通情報C1
の参照と、翻訳単位23に含まれる共通情報C1の定義およ
び共通情報E1の参照との依存関係を調べて、共通情報C1
の定義を含む翻訳単位23を共通情報C1の参照を含む翻訳
単位21の前に翻訳するように翻訳順序を入れ替えて、翻
訳単位23,21の翻訳順序での翻訳単位23および21の再翻
訳を翻訳処理手段11に指示する。
Therefore, the retranslation processing unit 13 selects the retranslatable translation unit 21 and the retranslatable translation unit 23 with translation order restriction from the reference information-deficient translation units 21, 23, and 27, and selects the translation unit 21. Common information B1 and common information C1 included in
Of the common information C1 and the definition of the common information C1 included in the translation unit 23 and the reference of the common information E1 are checked, and the common information C1
The translation unit is transposed so that the translation unit 23 containing the definition of is translated before the translation unit 21 containing the reference of common information C1, and the retranslation of translation units 23 and 21 in the translation order of translation units 23,21 is performed. Instruct the translation processing means 11.

〔発明の効果〕〔The invention's effect〕

以上説明したように本発明は、共通情報の定義と参照と
を別々の翻訳単位に記述可能な高級プログラミング言語
で記述された原始プログラムの翻訳において、翻訳処理
中に参照すべき共通情報および定義している共通情報に
関する情報を翻訳単位毎に格納するとともに各翻訳単位
の翻訳処理終了後に参照すべき共通情報の定義情報が生
成されていないために翻訳できなかった翻訳単位はその
旨を示す翻訳単位結果情報を格納しておきこれらの情報
を基に参照すべき共通情報の定義情報が生成されていな
いために翻訳できなかった翻訳単位の再翻訳を行うよう
にしたことにより、利用者は翻訳単位の翻訳処理順序を
意識して原始プログラムを記述したりコンパイラに対し
て翻訳順序を指示したりしなくてもよいという効果があ
る。
As described above, according to the present invention, in the translation of a source program written in a high-level programming language in which the definition and the reference of the common information can be described in different translation units, the common information and the definition to be referred to during the translation process are defined. The translation unit that cannot be translated because the definition information of the common information that should be referred to after the translation processing of each translation unit is not stored is stored as well as the information about the common information By storing the result information and re-translating the translation unit that could not be translated because the definition information of the common information that should be referred to based on these information was not generated, the user can There is an effect that it is not necessary to describe the source program or to instruct the compiler of the translation order in consideration of the translation processing order of the unit.

【図面の簡単な説明】[Brief description of drawings]

第1図は本発明の一実施例の翻訳処理方式が適用された
コンパイラの構成を示すブロック図、 第2図は本実施例の翻訳処理方式の動作を説明するため
の図である。 図において、 1……入力原始プログラムファイル、 2,2a,2b……原始プログラム、 3……共通情報定義情報ファイル、 4……共通情報定義情報、 10……コンパイラ、 10a……共通情報格納領域、 10b……翻訳単位結果情報格納領域、 11……翻訳処理手段、 12……翻訳結果情報処理手段、 13……再翻訳処理手段、 21,22,23,24,25,26,27……翻訳単位である。
FIG. 1 is a block diagram showing the configuration of a compiler to which the translation processing method of the embodiment of the present invention is applied, and FIG. 2 is a diagram for explaining the operation of the translation processing method of the embodiment. In the figure, 1 ... input source program file, 2,2a, 2b ... source program, 3 ... common information definition information file, 4 ... common information definition information, 10 ... compiler, 10a ... common information storage area , 10b …… Translation unit result information storage area, 11 …… Translation processing means, 12 …… Translation result information processing means, 13 …… Retranslation processing means, 21,22,23,24,25,26,27 …… It is a translation unit.

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】翻訳単位間の共通情報の定義と参照とを別
々の翻訳単位に記述可能であり共通情報の参照を含む翻
訳単位が参照すべき共通情報の定義を含む翻訳単位を翻
訳して生成される共通情報の定義情報を参照して翻訳さ
れる高級プログラミング言語で記述された原始プログラ
ムを入力して目的プログラムを生成するコンパイラにお
いて、 前記原始プログラムの翻訳処理を翻訳単位毎に行い翻訳
処理中の翻訳単位が共通情報の参照を含む場合には参照
すべき共通情報の定義情報が共通情報定義情報ファイル
に存在するか否かと参照すべき共通情報に関する情報と
を翻訳処理中の翻訳単位の翻訳単位名とともに共通情報
格納領域に格納して参照すべき共通情報の定義情報が前
記共通情報定義情報ファイルに存在すれば前記共通情報
定義情報ファイルから参照すべき共通情報の定義情報を
入力して翻訳し翻訳処理中の翻訳単位が共通情報の定義
を含む場合には定義している共通情報に関する情報を翻
訳処理中の翻訳単位の翻訳単位名とともに共通情報格納
領域に格納して当該翻訳単位の目的プログラムが生成さ
れたならばその結果生成される定義している共通情報の
定義情報を前記共通情報定義情報ファイルに出力する翻
訳処理手段と、 この翻訳処理手段により1つの翻訳単位の翻訳処理が終
了する毎に目的プログラムが生成されたか否かと参照す
べき共通情報の定義情報が前記共通情報定義情報ファイ
ルに存在しないために目的プログラムが生成されなかっ
た翻訳単位であれば再度翻訳処理をするのに必要な情報
とを当該翻訳単位の翻訳単位名とともに翻訳単位結果情
報として翻訳単位結果情報格納領域に格納する翻訳結果
情報処理手段と、 前記原始プログラムの全ての翻訳単位についての前記翻
訳処理手段および前記翻訳結果情報処理手段による処理
が終了した後に前記翻訳単位結果情報格納領域に格納さ
れた翻訳単位結果情報を基に参照すべき共通情報の定義
情報が前記共通情報定義情報ファイルに存在しなかった
ために目的プログラムが生成されなかった翻訳単位を抜
き出して当該翻訳単位の前記共通情報格納領域の参照す
べき共通情報に関する情報を基に前記共通情報定義情報
ファイルおよび前記共通情報格納領域を参照することに
より前記共通情報定義情報ファイルに参照すべき共通情
報の定義情報が存在しなかったために目的プログラムが
生成されなかった翻訳単位のうちから参照すべき共通情
報の定義情報が現在前記共通情報定義情報ファィルに存
在するために再翻訳可能な翻訳単位と参照すべき共通情
報の定義を含む翻訳単位との間の翻訳順序を入れ替える
ことで再翻訳可能な翻訳単位とを抽出して必要であれば
再翻訳処理の順序を入れ替えた後に再翻訳可能な翻訳単
位の前記翻訳単位結果情報格納領域の再翻訳処理をする
のに必要な情報を渡して前記翻訳処理手段に再翻訳可能
な翻訳単位の再翻訳処理を指示する再翻訳処理手段と を有することを特徴とする翻訳処理方式。
1. A definition and reference of common information between translation units can be described in different translation units, and a translation unit including a definition of common information to be referenced by a translation unit including a reference of common information is translated. A compiler for generating a target program by inputting a source program written in a high-level programming language, which is translated by referring to definition information of generated common information, in which a translation process is performed for each translation unit. If the translation unit inside contains a reference to the common information, whether the definition information of the common information to be referenced exists in the common information definition information file and information about the common information to be referenced If the definition information of the common information to be stored and referred to in the common information storage area together with the translation unit name exists in the common information definition information file, the common information definition information file If the definition information of the common information to be referenced from the file is translated and the translation unit being translated contains the definition of common information, the information about the defined common information is translated to the translation unit of the translation unit being translated. Translation processing means for outputting the definition information of the defined common information generated as a result of storing the object program of the translation unit together with the name in the common information storage area to the common information definition information file; When the translation processing unit completes the translation processing of one translation unit, whether or not the target program is generated, and definition information of common information to be referred to is not present in the common information definition information file, the target program is generated. If it is a translation unit that was not translated, the information necessary to perform the translation process again is translated as translation unit result information together with the translation unit name of the translation unit. A translation result information processing unit to be stored in the unit result information storage area, and to the translation unit result information storage area after processing by the translation processing unit and the translation result information processing unit for all translation units of the source program is completed. Since the definition information of the common information to be referred to based on the stored translation unit result information does not exist in the common information definition information file, the translation unit for which the target program was not generated is extracted and the common information of the translation unit is extracted. There is no definition information of common information to be referred to in the common information definition information file by referring to the common information definition information file and the common information storage area based on information about common information to be referred to in the storage area. Definition information of common information that should be referenced from the translation units for which the target program was not generated Is present in the common information definition information file, the retranslatable translation unit is extracted by exchanging the translation order between the retranslatable translation unit and the translation unit containing the definition of the common information to be referenced. If necessary, the order of the retranslation process is changed, and then the information necessary for performing the retranslation process of the translation unit result information storage area of the retranslatable translation unit is passed and retranslated to the translation processing means. And a retranslation processing means for instructing retranslation processing of possible translation units.
JP24184788A 1988-09-27 1988-09-27 Translation processing method Expired - Lifetime JPH06100971B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP24184788A JPH06100971B2 (en) 1988-09-27 1988-09-27 Translation processing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP24184788A JPH06100971B2 (en) 1988-09-27 1988-09-27 Translation processing method

Publications (2)

Publication Number Publication Date
JPH0290233A JPH0290233A (en) 1990-03-29
JPH06100971B2 true JPH06100971B2 (en) 1994-12-12

Family

ID=17080392

Family Applications (1)

Application Number Title Priority Date Filing Date
JP24184788A Expired - Lifetime JPH06100971B2 (en) 1988-09-27 1988-09-27 Translation processing method

Country Status (1)

Country Link
JP (1) JPH06100971B2 (en)

Also Published As

Publication number Publication date
JPH0290233A (en) 1990-03-29

Similar Documents

Publication Publication Date Title
JPH0458052B2 (en)
JPS6047606B2 (en) program input device
JPH06100971B2 (en) Translation processing method
JP2002082811A (en) Compiling method and recording medium
JPH11154093A (en) Program compiler and storage medium recording compiler program
JPS6027941A (en) Identifier generation system
JP3031767B2 (en) Natural language processor
JP4616603B2 (en) Source code search program and search table creation program
JP2607975B2 (en) Debug method
JPS63269229A (en) Compiling system for character string operation system instruction
JPH01246633A (en) Check system for compiling unit
JPH04178829A (en) File definition information editing system in load module
JPH06332687A (en) System for automatically correcting program and reflecting it
JPH05257702A (en) System for preparing macro built-in type intermediate language text file
JPH04106626A (en) Program translation processor
JPH0256639A (en) Simplified language processing system
JPH0769830B2 (en) Program translation device with expansion control function
JPS62166432A (en) Control system for program translation
JPS61245232A (en) Automatic editing method
JPH08263272A (en) Library registration method and device for common routine
JPH01211120A (en) Syntax analyzing processing method
JPS62157950A (en) Translating method for data base operating source program
JPH0750442B2 (en) External line number debugging method
JPS62204337A (en) Program translation device
JPH02230330A (en) Inference device