JP3003459B2 - Program creation support device - Google Patents

Program creation support device

Info

Publication number
JP3003459B2
JP3003459B2 JP5138303A JP13830393A JP3003459B2 JP 3003459 B2 JP3003459 B2 JP 3003459B2 JP 5138303 A JP5138303 A JP 5138303A JP 13830393 A JP13830393 A JP 13830393A JP 3003459 B2 JP3003459 B2 JP 3003459B2
Authority
JP
Japan
Prior art keywords
program
source code
rule
vocabulary
grammar
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
JP5138303A
Other languages
Japanese (ja)
Other versions
JPH06348465A (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.)
Mitsubishi Electric Corp
Original Assignee
Mitsubishi Electric 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 Mitsubishi Electric Corp filed Critical Mitsubishi Electric Corp
Priority to JP5138303A priority Critical patent/JP3003459B2/en
Publication of JPH06348465A publication Critical patent/JPH06348465A/en
Application granted granted Critical
Publication of JP3003459B2 publication Critical patent/JP3003459B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【産業上の利用分野】この発明は、プログラムの作成及
び編集を対話的に行なうのを支援するプログラム作成支
援装置に関するものであり、特にプログラムの対象とす
るプログラミング言語の文法を容易に変更可能とするこ
とにより、多言語の対応を可能としたり、プログラミン
グ言語の改定に対応し易いことを特徴とする。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a program creation supporting apparatus for supporting creation and editing of a program interactively, and more particularly, to a program creation supporting apparatus capable of easily changing a grammar of a programming language targeted by the program. By doing so, it is possible to cope with multiple languages, and it is easy to cope with revision of a programming language.

【0002】[0002]

【従来の技術】図11は、例えば情報処理学会誌第31
巻第8号1030頁に示された従来のプログラム作成支
援装置を示す構成図である。図において、1はプログラ
ムを対話的に作成および編集するプログラム編集手段、
2は作成および編集したプログラムの動作を対話的に検
証するプログラム検証手段、3は作成および編集された
プログラムのソースコードを解析し中間表現に変換する
ソースコード解析手段、4は中間表現からプログラムの
ソースコードを生成するソースコード生成手段、5は中
間表現を格納する中間表現格納手段、6はこのプログラ
ム作成支援装置によって作成されたプログラムのソース
コードである。
2. Description of the Related Art FIG.
It is a block diagram which shows the conventional program creation support apparatus shown by volume 8 page 1030. In the figure, 1 is a program editing means for interactively creating and editing a program,
2 is a program verification means for interactively verifying the operation of the created and edited program, 3 is a source code analyzing means for analyzing the source code of the created and edited program and converting it into an intermediate representation, and 4 is a program Source code generation means for generating source code, intermediate expression storage means for storing intermediate expressions, and source code of a program created by the program creation support device.

【0003】本プログラム作成支援装置では、使用者、
即ちプログラム作成者は、プログラム編集手段1を用い
ることによってプログラムのソースコード6を直接テキ
ストエディタで編集するよりも効率的で理解しやすい形
式での編集手段が与えられ、また、作成したプログラム
の動作を検証するための手段としてプログラム検証手段
2が与えられる。使用者がプログラム編集手段1で作成
したプログラムは、一旦中間表現格納手段5に、ある中
間表現の形式で格納され、ソースコード生成手段4によ
りプログラムのソースコード6へ変換される。プログラ
ムのソースコード6を編集する際には、ソースコード解
析手段3により中間表現に変換し、中間表現格納手段5
に格納する。中間表現格納手段5に格納されたプログラ
ムの中間表現に対して、プログラム編集手段1及びプロ
グラム検証手段2を用いることにより編集を行い、再び
ソースコード生成手段4によってプログラムのソースコ
ード6を得る。
In this program creation support device, a user,
That is, the program creator is provided with an editing means in a format which is more efficient and easy to understand than by directly editing the source code 6 of the program by using a text editor by using the program editing means 1. The program verification means 2 is provided as means for verifying. The program created by the user with the program editing means 1 is temporarily stored in the intermediate expression storage means 5 in the form of a certain intermediate expression, and is converted by the source code generation means 4 into the source code 6 of the program. When editing the source code 6 of the program, the source code is converted into an intermediate representation by the source code
To be stored. The intermediate representation of the program stored in the intermediate representation storage means 5 is edited by using the program editing means 1 and the program verification means 2, and the source code generation means 4 obtains the source code 6 of the program again.

【0004】このようなプログラム作成支援装置では、
通常ソースコード解析手段3及びソースコード生成手段
4は、ある特定のプログラミング言語に特化されている
ため、他のプログラミング言語に対して同様のプログラ
ム作成支援を行いたい場合や、または、プログラミング
言語の改良等が発生した場合などはソースコード解析手
段3及びソースコード生成手段4を他のプログラミング
言語または新しいバージョンのプログラミング言語用に
変更する必要がある。
In such a program creation support device,
Usually, since the source code analysis means 3 and the source code generation means 4 are specialized for a specific programming language, it is necessary to provide similar program creation support to other programming languages, or When an improvement or the like occurs, it is necessary to change the source code analysis means 3 and the source code generation means 4 for another programming language or a new version of the programming language.

【0005】このようにプログラム作成支援装置を他の
プログラミング言語または新しいバージョンのプログラ
ミング言語用に変更する作業を軽減するためには、例え
ば1970年産業図書株式会社発行の「コンパイラ・コ
ンパイラ」(井上謙蔵著)第7章で述べられているコン
パイラ・コンパイラ技術を適用することが考えられる。
図11は、コンパイラ・コンパイラ技術を適用してソー
スコード解析手段の変更を容易にする例である。
[0005] In order to reduce the work of changing the program creation support device to another programming language or a new version of a programming language, for example, a "compiler compiler" (Kenzo Inoue, published by Sangyo Tosho Co., Ltd., 1970) Authors) It is conceivable to apply the compiler and compiler technology described in Chapter 7.
FIG. 11 is an example in which a compiler / compiler technique is applied to facilitate change of a source code analysis unit.

【0006】図12において、構文解析器生成手段8
は、語彙/文法ルールおよび解析のための意味定義から
なる構文解析ルール7を読み込み、構文解析ルール7に
規定されたプログラミング言語で記述されたプログラム
のソースコード6を解析し、中間表現に変換するソース
コードを自動生成する。これによって、ソースコード解
析手段3は、構文解析ルール7のみを変更するのみで、
他のプログラム言語または新しいバージョンのプログラ
ム言語用に変更することができる。しかし、一方で、ソ
ースコード生成手段の変更に関しては、構文解析器生成
手段8に対応するツールがないため、従来より人手によ
って作り替える必要があった。
In FIG. 12, a parser generating means 8
Reads a parsing rule 7 composed of vocabulary / grammar rules and semantic definitions for analysis, analyzes a source code 6 of a program described in a programming language specified in the parsing rule 7, and converts it into an intermediate representation. Automatically generate source code. As a result, the source code analysis means 3 only changes the syntax analysis rule 7 only.
It can be changed for another programming language or a new version of the programming language. However, on the other hand, regarding the change of the source code generation means, since there is no tool corresponding to the syntax analyzer generation means 8, it has conventionally been necessary to recreate it manually.

【0007】[0007]

【発明が解決しようとする課題】従来のプログラム作成
支援装置は、以上のようにソースコード生成手段を容易
に作成する手段が存在しないため、プログラミング言語
の変更に対するソースコード生成手段の変更のための労
力が大きいという問題、および、ソースコード解析手段
3とソースコード生成手段4の語彙/文法に関する一貫
性の保証が困難であるという問題があった。
As described above, the conventional program creation support apparatus has no means for easily creating the source code generation means as described above. There is a problem that labor is large and a problem that it is difficult to guarantee consistency of the vocabulary / grammar of the source code analysis unit 3 and the source code generation unit 4.

【0008】この発明は上記のような問題点を解消する
ためになされたもので、ソースコード生成手段を作成す
るための手段を設けることによってコード生成ルールを
変更するだけでソースコード生成手段を任意のプログラ
ミング言語向けに変更することを可能とし、さらに、コ
ード生成ルールの中の語彙/文法ルールに構文解析ルー
ルの中の語彙/文法ルールをそのまま利用することによ
りソースコード解析手段とソースコード生成手段の語彙
/文法に関する一貫性の保証を得ることを目的とする。
SUMMARY OF THE INVENTION The present invention has been made to solve the above-mentioned problems. By providing a means for creating a source code generation means, the source code generation means can be arbitrarily changed only by changing the code generation rules. Source code analysis means and source code generation means by making it possible to use the vocabulary / grammar rules in the parsing rules as they are for the vocabulary / grammar rules in the code generation rules. The goal is to get consistency assurance regarding the vocabulary / grammar of the

【0009】[0009]

【課題を解決するための手段】請求項1に記載の発明に
係わるプログラム作成支援装置は、下記の要素を有する
ものである。 (a)プログラムを対話的に作成及び編集するプログラ
ム編集手段 (b)前記プログラム編集手段により作成及び編集され
たプログラムの動作を対話的に検証するプログラム検証
手段 (c)作成および編集されたプログラムのソースコード
を解析し中間表現に変換するソースコード解析手段 (d)前記中間表現を格納する中間表現格納手段 (e)プログラミング言語の語彙/文法ルールを内含し
た構文解析ルール (f)前記構文解析ルールから自動的にソースコード解
析手段を生成する構文解析器生成手段 (g)プログラミング言語の語彙/文法ルールを内含し
たコード生成ルール (h)前記コード生成ルールからソースコード生成手段
を自動的に生成するコード生成器生成手段
According to a first aspect of the present invention, there is provided a program creation support apparatus having the following elements. (A) a program editing means for interactively creating and editing a program; and (b) a program verifying means for interactively verifying the operation of the program created and edited by the program editing means. Source code analysis means for analyzing a source code and converting it into an intermediate expression (d) Intermediate expression storage means for storing the intermediate expression (e) Parsing rules including vocabulary / grammar rules of a programming language (f) The syntax analysis (G) a code generation rule including a vocabulary / grammar rule of a programming language; and (h) a source code generation means that automatically generates a source code analysis means from the code generation rule. Code generator generating means to generate

【0010】請求項2に記載の発明に係わるプログラム
支援装置は、下記の要素を有するものである。 (a)プログラムを対話的に作成及び編集するプログラ
ム編集手段 (b)前記プログラム編集手段により作成及び編集され
たプログラムの動作を対話的に検証するプログラム検証
手段 (c)作成および編集されたプログラムのソースコード
を解析し中間表現に変換するソースコード解析手段 (d)前記中間表現を格納する中間表現格納手段 (e)プログラミング言語の語彙/文法ルールを内含し
た構文解析ルール (f)前記構文解析ルールから自動的にソースコード解
析手段を生成する構文解析器生成手段 (g)プログラミング言語の語彙/文法ルールを内含し
たコード生成ルール (h)前記コード生成ルールからソースコード生成手段
を自動的に生成するコード生成器生成手段 (i)前記構文解析ルールからソースコード生成手段を
生成するためのコード生成ルールで利用可能な語彙/文
法ルールを抽出する語彙/文法ルール抽出手段
[0010] A program support apparatus according to a second aspect of the present invention has the following elements. (A) a program editing means for interactively creating and editing a program; and (b) a program verifying means for interactively verifying the operation of the program created and edited by the program editing means. Source code analysis means for analyzing a source code and converting it into an intermediate expression (d) Intermediate expression storage means for storing the intermediate expression (e) Parsing rules including vocabulary / grammar rules of a programming language (f) The syntax analysis (G) a code generation rule including a vocabulary / grammar rule of a programming language; and (h) a source code generation means that automatically generates a source code analysis means from the code generation rule. Code generator generating means for generating (i) source code generating means from the syntax analysis rules Vocabulary / grammar rule extraction means for extracting the available vocabulary / grammar rule in the code generation rules for forming

【0011】[0011]

【作用】請求項1に記載の発明に係わるプログラム作成
支援装置においては、語彙/文法ルールを内含したコー
ド生成ルールからソースコード生成手段を自動的に生成
するコード生成器生成手段を備えるようにしたことに特
徴がある。このことによりソースコードを記述するプロ
グラム言語の変更の際には、語彙/文法ルールのみを変
更することで容易に対応できる。
According to the first aspect of the present invention, there is provided a program creation support apparatus including a code generator generation means for automatically generating a source code generation means from a code generation rule including vocabulary / grammar rules. There is a feature in doing. Thus, when the programming language for writing the source code is changed, it can be easily handled by changing only the vocabulary / grammar rules.

【0012】請求項2に記載の発明に係わるプログラム
作成支援装置においては、請求項1に記載の発明にソー
スコード解析手段を生成するための構文解析ルールから
ソースコード生成手段を生成するためのコード生成ルー
ルで利用可能な語彙/文法ルールを抽出する語彙/文法
ルール抽出手段を付加したことに特徴がある。このこと
によりソースコード解析手段とソースコード生成手段
が、共通の語彙/文法ルールを有することになり言語の
一貫性を得るのが容易になる。
According to a second aspect of the present invention, there is provided a program creation support apparatus for generating a source code generation unit from a syntax analysis rule for generating a source code analysis unit according to the first aspect of the invention. It is characterized in that a vocabulary / grammar rule extracting means for extracting a vocabulary / grammar rule that can be used in the generation rule is added. As a result, the source code analysis unit and the source code generation unit have a common vocabulary / grammar rule, and it is easy to obtain language consistency.

【0013】[0013]

【実施例】【Example】

実施例1.以下、この発明の一実施例を図について説明
する。図1は本発明の一実施例によるプログラム作成支
援装置の構成図である。図において、従来例と同一のも
のは、同一の符号を付して説明を省略する。9はプログ
ラムのソースコード6を記述するプログラミング言語の
語彙/文法ルールおよび中間表現格納手段5に格納され
ている中間表現からプログラムソースコード7を生成す
るための意味定義からなるコード生成ルール、10はコ
ード生成ルール9を読み込み、中間表現格納手段に格納
されている中間表現から、コード生成ルールに規定され
ているプログラミング言語の語彙/文法に従ったプログ
ラムソースコードを出力するソースコード生成手段を自
動的に生成するコード生成器生成手段、11は構文解析
ルール7からソースコード生成手段を生成するためのコ
ード生成ルールで利用可能な語彙/文法ルールを抽出す
る語彙/文法ルール抽出手段である。
Embodiment 1 FIG. An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a configuration diagram of a program creation support device according to an embodiment of the present invention. In the figure, the same components as those of the conventional example are denoted by the same reference numerals, and description thereof is omitted. Reference numeral 9 denotes a vocabulary / grammar rule of a programming language that describes the source code 6 of the program, and a code generation rule including a semantic definition for generating the program source code 7 from the intermediate expression stored in the intermediate expression storage unit 5. Source code generation means for reading the code generation rule 9 and outputting a program source code in accordance with the vocabulary / grammar of the programming language specified in the code generation rule from the intermediate expression stored in the intermediate expression storage means automatically Is a vocabulary / grammar rule extracting means for extracting a vocabulary / grammar rule usable in a code generation rule for generating a source code generating means from the syntax analysis rule 7.

【0014】次に動作について説明する。まず、図1に
おける語彙/文法ルール抽出手段を用いて、構文解析ル
ール7からコード生成ルール9を作成する動作について
説明する。図2は例えばyacc/lexと呼ばれる構
文解析器生成手段を用いた場合の構文解析ルールを表わ
したものである。図において、201は解析のための語
彙ルール、202は終端記号列、203は終端記号列に
対応するアクション、204は解析のための構文ルー
ル、205はタイプ付きトークンの定義、206はタイ
プ無しトークンの定義、207は非終端記号のタイプ定
義、208は非終端記号のエントリ、209および21
1はそれぞれ非終端記号208の展開規則、210は展
開規則209に対応する解析のための意味定義、212
は展開規則211に対応する解析のための意味定義であ
る。
Next, the operation will be described. First, the operation of creating the code generation rule 9 from the syntax analysis rule 7 using the vocabulary / grammar rule extraction means in FIG. 1 will be described. FIG. 2 shows a parsing rule when a parser generating means called, for example, "yacc / lex" is used. In the figure, 201 is a vocabulary rule for analysis, 202 is a terminal symbol string, 203 is an action corresponding to the terminal symbol string, 204 is a syntax rule for analysis, 205 is a definition of a typed token, and 206 is a typeless token , 207 is a nonterminal symbol type definition, 208 is a nonterminal symbol entry, 209 and 21
1 is the expansion rule of the non-terminal symbol 208, 210 is the semantic definition for analysis corresponding to the expansion rule 209, 212
Is a semantic definition for analysis corresponding to the expansion rule 211.

【0015】図3は、図1における語彙/文法ルール抽
出手段11によって図2の構文解析ルールから抽出され
た語彙/文法ルールの例である。図において、31はタ
イプ付きトークンの出力マクロ、32はタイプ無しトー
クンの出力マクロ、33は非終端記号のタイプ定義、3
4は文法ルールである。
FIG. 3 shows an example of vocabulary / grammar rules extracted from the syntax analysis rules of FIG. 2 by the vocabulary / grammar rule extracting means 11 in FIG. In the figure, 31 is an output macro of a token with a type, 32 is an output macro of a token without a type, 33 is a type definition of a non-terminal symbol, 3
4 is a grammar rule.

【0016】図4は、図1の語彙/文法ルール抽出手段
11の動作を示すフローチャートである。図4におい
て、ステップ401では、図2に示した構文解析ルール
から文字列を読み込み、ステップ402では、読み込ん
だ文字列がタイプ付きトークンか否かを調べる。もしタ
イプ付きトークンであれば、タイプに合わせた出力マク
ロを作成しファイルに出力する。一方、もしタイプ付き
トークンでなければ、図2における終端記号列202お
よび終端記号列に対応するアクション203を参考にし
て終端記号列の出力マクロを作成し、ファイルに出力す
る。ここでタイプ付きトークンから作成された出力マク
ロは図3におけるタイプ付きトークンの出力マクロ31
であり、タイプ無しトークンから作成された出力マクロ
は図3におけるタイプなしトークンの出力マクロ32で
ある。
FIG. 4 is a flowchart showing the operation of the vocabulary / grammar rule extracting means 11 of FIG. 4, in step 401, a character string is read from the syntax analysis rule shown in FIG. 2, and in step 402, it is checked whether the read character string is a typed token. If it is a typed token, create an output macro that matches the type and output it to a file. On the other hand, if the token is not a typed token, a terminal symbol string output macro is created with reference to the terminal symbol string 202 and the action 203 corresponding to the terminal symbol string in FIG. Here, the output macro created from the typed token is the output macro 31 of the typed token in FIG.
And the output macro created from the untyped token is the output macro 32 of the untyped token in FIG.

【0017】また、図2においてはタイプ付きトークン
205およびタイプ無しトークン206の処理が終了す
ることになる。次に、図4において、ステップ405で
はトークン定義が終了か否かを調べ、もし終了でなけれ
ば再びステップ401に戻りステップ402、403、
404に示される処理を繰り返す。ステップ405にお
いて、もしトークン定義が終了であれば、ステップ40
6に進み図2に示す構文解析ルールから文字列を読み込
む。ステップ408において、読み込んだ文字列が非終
端記号のタイプ定義か否かを調べる。もし読み込んだ文
字列が非終端記号のタイプ定義であれば、ステップ40
7において非終端記号タイプ定義をそのままファイルに
出力し、再びステップ406にもどる。ステップ408
において、もし非終端記号のタイプ定義でなければ、ス
テップ409に進み、構文解析ルールから文字列を読み
込む。ここで出力された非終端記号のタイプ定義は、図
3における非終端記号のタイプ定義33であり、図2に
おいては非終端記号のタイプ定義207まで処理が終了
することになる。
In FIG. 2, the processing of the typed token 205 and the typeless token 206 ends. Next, in FIG. 4, in step 405, it is checked whether or not the token definition is completed. If not, the process returns to step 401 and returns to steps 402, 403,
The process shown at 404 is repeated. In step 405, if the token definition is completed, step 40
Then, the process proceeds to step 6 to read a character string from the syntax analysis rule shown in FIG. In step 408, it is checked whether the read character string is a nonterminal symbol type definition. If the read string is a nonterminal symbol type definition, step 40
In step 7, the nonterminal symbol type definition is output to a file as it is, and the process returns to step 406 again. Step 408
If it is not the type definition of the non-terminal symbol, the flow advances to step 409 to read a character string from the parsing rule. The nonterminal symbol type definition output here is the nonterminal symbol type definition 33 in FIG. 3, and the process ends up to the nonterminal symbol type definition 207 in FIG. 2.

【0018】次に、図4において、ステップ409で読
み込んだ文字列に対して、ステップ411において構文
解析ルールが終了したか否かを調べる。もし、終了して
いなければ、図2の210および212に示すような意
味定義の部分を削除し、非終端記号208と展開規則2
09および211のみをファイルに出力する。これによ
り、図2に示す構文解析ルールは、図3に示す語彙/文
法ルールの形式に変換される。
Next, in FIG. 4, it is checked in step 411 whether or not the syntax analysis rule has been completed for the character string read in step 409. If not finished, the part of the semantic definition as shown by 210 and 212 in FIG.
Output only 09 and 211 to a file. As a result, the syntax analysis rule shown in FIG. 2 is converted into the vocabulary / grammar rule format shown in FIG.

【0019】図1の語彙/文法ルール抽出手段11を用
いて得られた語彙/文法ルールは、生成のための意味定
義を追記することにより図1のコード生成ルール9とな
る。図5はコード生成ルール9の記述の概要を示す図で
ある。図において、51は非終端記号のエントリ、52
は任意のCプログラム、53および55は非終端記号の
エントリ1に対応する展開規則、54は展開規則53に
対応する生成のための意味定義、56は展開規則55に
対応する生成のための意味定義である。
The vocabulary / grammar rule obtained by using the vocabulary / grammar rule extracting means 11 of FIG. 1 becomes the code generation rule 9 of FIG. 1 by adding a meaning definition for generation. FIG. 5 is a diagram showing an outline of the description of the code generation rule 9. In the figure, 51 is an entry of a non-terminal symbol, 52
Is an arbitrary C program, 53 and 55 are expansion rules corresponding to the nonterminal symbol entry 1, 54 is a semantic definition for generation corresponding to the expansion rule 53, and 56 is a semantic definition for generation corresponding to the expansion rule 55 It is.

【0020】図5のコード生成ルール9の記述の概要に
ついて詳しく説明する。非終端記号51、展開規則53
および55は、先の語彙/文法ルール抽出手段によって
抽出された文法ルールと同一のものである。したがっ
て、図1のコード生成ルール9を作成するために、抽出
された語彙/文法ルールに追記する部分は、図5の任意
のCプログラム52と生成のための意味定義54および
56である。任意のCプログラム52には、ソースコー
ド清書のためのプログラムや中間表現からデータを抽出
するためのプログラムなどが、例えばC言語で記述され
る。
The outline of the description of the code generation rule 9 in FIG. 5 will be described in detail. Non-terminal symbol 51, expansion rule 53
And 55 are the same as the grammar rules extracted by the vocabulary / grammar rule extraction means. Therefore, the portions to be added to the extracted vocabulary / grammar rules in order to create the code generation rule 9 in FIG. 1 are the arbitrary C program 52 in FIG. 5 and the meaning definitions 54 and 56 for generation. In the arbitrary C program 52, a program for copying source code, a program for extracting data from an intermediate expression, and the like are described in, for example, the C language.

【0021】次に、生成のための意味定義54および5
6には、条件文、引数定義、改行出力の3つの事項を記
述する。まず、条件文は、引数に条件式を採り「con
d]という関数名で表わされる関数である。条件文は、
非終端記号エントリ51の展開規則が複数存在する場合
の選択条件、または、展開規則の中に再び非終端記号エ
ントリが含まれるような再帰的な文法ルールに対する終
了条件が記述される。展開規則が複数存在する場合に
は、条件文の条件式を満たす展開規則が選ばれる、再帰
的な文法ルールの場合には、条件文の条件式が満たされ
る間のみ繰り返しルールが適用される。
Next, semantic definitions 54 and 5 for generation
6 describes three items: a conditional statement, an argument definition, and a line feed output. First, the conditional statement takes a conditional expression as an argument,
d]. The conditional statement is
A selection condition when there are a plurality of expansion rules of the non-terminal symbol entry 51 or an end condition for a recursive grammar rule in which the non-terminal symbol entry is included again in the expansion rule is described. If there are a plurality of expansion rules, an expansion rule that satisfies the conditional expression of the conditional statement is selected. In the case of a recursive grammar rule, the repetition rule is applied only while the conditional expression of the conditional statement is satisfied.

【0022】引数定義は、「$(数字)=式」という形
式で記述される代入文で、展開規則中の非終端記号への
値の代入を表わす。例えば、図5の生成のための意味定
義54によれば、対応する展開規則53における非終端
記号1には式1の値が代入され、非終端記号2には式2
の値が代入される。最後に、改行出力は、「end_o
f_line」で表わされる出力マクロであり、清書の
ために、対応する展開規則の適用後、改行コードを出力
する。図3に示す語彙/文法ルールに生成のための意味
定義を追記した例を図6に示す。
The argument definition is an assignment statement described in the form of “$ (number) = expression” and represents the assignment of a value to a non-terminal symbol in the expansion rule. For example, according to the semantic definition 54 for generation in FIG. 5, the value of the expression 1 is substituted for the non-terminal 1 in the corresponding expansion rule 53, and the expression 2 is substituted for the non-terminal 2
Is assigned. Finally, the line feed output is "end_o
This is an output macro represented by "f_line", and outputs a line feed code after applying a corresponding expansion rule for a fair copy. FIG. 6 shows an example in which a meaning definition for generation is added to the vocabulary / grammar rule shown in FIG.

【0023】次に、図1におけるコード生成ルール9か
らコード生成器生成手段10を用いてソースコード生成
手段4を生成する動作について説明する。図7は図5に
示すコード生成ルールからコード生成器生成手段を用い
て生成されたソースコード生成手段のC言語プログラム
である。図において、71は関数エントリ、72は任意
のCプログラム、73および74はコード生成のための
プログラムである。また、図6に示すコード生成ルール
の例は、図8に示すC言語プログラムとして生成され
る。
Next, the operation of generating the source code generation means 4 from the code generation rule 9 in FIG. 1 using the code generator generation means 10 will be described. FIG. 7 is a C-language program of the source code generation means generated from the code generation rules shown in FIG. 5 using the code generator generation means. In the figure, 71 is a function entry, 72 is an arbitrary C program, and 73 and 74 are programs for code generation. Further, the example of the code generation rule shown in FIG. 6 is generated as a C language program shown in FIG.

【0024】図9および図10は、図1におけるコード
生成器生成手段10の動作を示すフローチャートであ
る。図において、ステップ901では図5および図6に
示すコード生成ルール9から文字列を読み込み、ステッ
プ902において「%token」という文字列を「#
define」という文字列に変換してファイルに出力
する。ステップ903においてトークン定義が終了した
か否かを調べ、もし終了していなければステップ901
に戻り、終了していればステップ904に進む。ステッ
プ904では、コード生成ルールから文字列を読み込
み、ステップ905において非終端記号タイプ定義か否
かを調べる。
FIGS. 9 and 10 are flowcharts showing the operation of the code generator generating means 10 in FIG. In the figure, in step 901, a character string is read from the code generation rule 9 shown in FIGS. 5 and 6, and in step 902, the character string "% token" is replaced with "#
It is converted to a character string "define" and output to a file. In step 903, it is determined whether or not the token definition has been completed.
Returning to step 904, if it has been completed, the process proceeds to step 904. In step 904, a character string is read from the code generation rule, and in step 905, it is checked whether or not a nonterminal symbol type is defined.

【0025】もし非終端記号タイプ定義であれば、非終
端記号とそのタイプを内部テーブルに記憶し、ステップ
904に戻る。そうでなければ、ステップ907に進
む。次に、ステップ907では図5の非終端記号のエン
トリ51を読み込み、先にステップ906で記憶した非
終端記号とそのタイプの対応から非終端記号を関数名と
し、タイプを引数の型とするC言語の関数として出力す
る(図7関数エントリ71参照)。ステップ908で
は、コード生成ルールを続けて読み込み、図5の任意の
Cプログラム52があれば、そのまま出力する(図7任
意のCプログラム72参照)。
If it is a non-terminal symbol type definition, the non-terminal symbol and its type are stored in an internal table, and the process returns to step 904. Otherwise, go to step 907. Next, in step 907, the non-terminal symbol entry 51 shown in FIG. (See function entry 71 in FIG. 7). In step 908, the code generation rule is read continuously, and if there is any C program 52 in FIG. 5, it is output as it is (see the arbitrary C program 72 in FIG. 7).

【0026】図5の展開規則53および55について
は、ステップ909からステップ918において処理さ
れる。ステップ909では、コード生成ルール9を読み
込み、条件文(cond文)であれば、if文として出
力する。ステップ910では展開規則の文字列を読み込
み、ステップ911においてそれが非終端記号と判定さ
れたら、ステップ912において、図5の生成のための
意味定義54および56の引数定義にしたがって非終端
記号を関数名とする関数呼び出しとして出力する。
The expansion rules 53 and 55 in FIG. 5 are processed in steps 909 to 918. In step 909, the code generation rule 9 is read, and if it is a conditional statement (cond statement), it is output as an if statement. In step 910, the character string of the expansion rule is read. Output as a function call.

【0027】ステップ913においてタイプ付き終端記
号と判定されたら、ステップ914において、先にステ
ップ902で終端記号名で定義されている出力マクロを
用いて引数定義に従った呼び出しを出力する。ステップ
915において終端記号採判定されたら、ステップ91
6において先にステップ902で定義されている終端記
号名の出力マクロの呼び出しを出力する。
If it is determined in step 913 that the terminal symbol is a typed terminal symbol, in step 914, a call in accordance with the argument definition is output using an output macro defined by the terminal symbol name in step 902. If the terminal symbol is determined in step 915, step 91 is executed.
In step 6, the output macro call of the terminal symbol name defined in step 902 is output.

【0028】ステップ917では、他の展開規則がある
か否かを調べ、もしあれば、cond文をelse i
f文として出力し、ステップ910に戻る。もし、他の
展開規則がなければ、ステップ919において他のコー
ド生成ルールがあるか否かを調べ、もしあればステップ
907に戻り、なければ終了する。
In step 917, it is checked whether or not there is another expansion rule.
Output as an f statement, and return to step 910. If there is no other expansion rule, it is checked in step 919 whether there is another code generation rule, and if there is, the process returns to step 907;

【0029】[0029]

【発明の効果】以上のように、この発明によればコード
生成器生成手段は、コード生成ルールを読み込み、中間
表現格納手段に格納されている中間表現から、コード生
成ルールに規定されているプログラミング言語の語彙/
文法に従ったプログラムソースコードを出力するソース
コード生成手段を自動的に生成するように構成したの
で、構文解析器生成手段と合わせて利用することによ
り、構文解析ルールおよびコード生成ルールの変更のみ
で、プログラミング言語の変更に対応したプログラム作
成支援装置の変更を容易に行えるという効果がある。
As described above, according to the present invention, the code generator generation means reads the code generation rules, and reads the program defined by the code generation rules from the intermediate expression stored in the intermediate expression storage means. Language vocabulary /
Since the source code generator that outputs the program source code according to the grammar is configured to be automatically generated, it can be used in combination with the parser generator so that only the parsing rules and code generation rules need to be changed. In addition, there is an effect that the program creation support device can be easily changed in response to a change in the programming language.

【0030】また、語彙/文法ルール抽出手段は、構文
解析ルールからソースコード生成手段を生成するための
コード生成ルールで利用可能な語彙/文法ルールを抽出
するので、ソースコード解析手段とソースコード生成手
段の語彙/文法に関する一貫性の保証を得ることが可能
となる。
The vocabulary / grammar rule extracting means extracts the vocabulary / grammar rules usable in the code generation rules for generating the source code generating means from the syntax analysis rules. It is possible to obtain a guarantee of consistency regarding the vocabulary / grammar of the means.

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

【図1】本発明の一実施例によるプログラム作成支援装
置の構成図である。
FIG. 1 is a configuration diagram of a program creation support device according to an embodiment of the present invention.

【図2】本発明の一実施例による構文解析ルールの例を
示す図である。
FIG. 2 is a diagram illustrating an example of a syntax analysis rule according to an embodiment of the present invention.

【図3】本発明の一実施例による語彙/文法ルールの例
を示す図である。
FIG. 3 is a diagram showing an example of vocabulary / grammar rules according to one embodiment of the present invention.

【図4】本発明の一実施例による語彙/文法ルール抽出
手段のフローチャート図である。
FIG. 4 is a flowchart of a vocabulary / grammar rule extracting unit according to an embodiment of the present invention.

【図5】本発明の一実施例によるコード生成ルールの概
要の説明図である。
FIG. 5 is an explanatory diagram of an outline of a code generation rule according to an embodiment of the present invention.

【図6】本発明の一実施例によるコード生成ルールの例
を示す図である。
FIG. 6 is a diagram showing an example of a code generation rule according to an embodiment of the present invention.

【図7】本発明の一実施例によるソースコード生成手段
の概要の説明図である。
FIG. 7 is an explanatory diagram of an outline of a source code generation unit according to an embodiment of the present invention.

【図8】本発明の一実施例によるソースコード生成手段
の例を示す図である。
FIG. 8 is a diagram showing an example of source code generation means according to one embodiment of the present invention.

【図9】本発明の一実施例によるコード生成器生成手段
のフローチャート図である。
FIG. 9 is a flowchart of a code generator generating means according to an embodiment of the present invention.

【図10】図9の続きである。FIG. 10 is a continuation of FIG. 9;

【図11】従来のプログラム作成支援装置の構成図であ
る。
FIG. 11 is a configuration diagram of a conventional program creation support device.

【図12】従来のプログラム作成支援装置に改良を加え
た構成図である。
FIG. 12 is a configuration diagram in which a conventional program creation support device is improved.

【符号の説明】[Explanation of symbols]

1 プログラム編集手段 2 プログラム検証手段 3 ソースコード解析手段 4 ソースコード生成手段 5 中間表現格納手段 6 プログラムソースコード 7 構文解析ルール 8 構文解析器生成手段 9 コード生成ルール 10 コード生成器生成手段 11 語彙/文法ルール抽出手段 REFERENCE SIGNS LIST 1 program editing means 2 program verification means 3 source code analysis means 4 source code generation means 5 intermediate representation storage means 6 program source code 7 syntax analysis rules 8 syntax analyzer generation means 9 code generation rules 10 code generator generation means 11 vocabulary / Grammar rule extraction means

フロントページの続き (56)参考文献 特開 平4−102919(JP,A) 特開 平5−108318(JP,A) ”確定節文法のための内部構造変換機 能付きパーザとアンパーザの自動生成方 式”,情報処理学会論文誌,(1990 /11),Vol.31,No.11,pp. 1616−1626 情報処理(1990−8),情報処理学 会,vol.31,No.8,pp.1013 −1047 ”演算子識別アルゴリズムのyacc を使った実現(2)”,bit,(1993 /1),Vol.25,No.1,pp. 95−97 「yacc−Yet Another Compiler−Compile r」,Sun Microsystem s,(1990) ”コンパイラの代数的仕様記述と自動 生成”,電子情報通信学会論文誌 D− I,(1990/12),Vol.J73−D− I,pp.979−989 (58)調査した分野(Int.Cl.7,DB名) G06F 9/06 - 9/46 Continuation of the front page (56) References JP-A-4-102919 (JP, A) JP-A-5-108318 (JP, A) "Automatic generation of a parser and an parser with internal structure conversion function for definite clause grammar" Method, ”Transactions of the Information Processing Society of Japan, (1990/11), Vol. 31, No. 11, pp. 1616-1626 Information processing (1990-8), Information Processing Society, vol. 31, No. 8, pp. 1013-1047 "Implementation of operator identification algorithm using yacc (2)", bit, (1993/1), Vol. 25, No. 1, pp. 95-97, "yacc-Yet Another Compiler-Compiler", Sun Microsystems, (1990) "Algebraic specification description and automatic generation of compiler", IEICE Transactions DI, (1990 / 12), Vol. J73-DI, p. 979-989 (58) Field surveyed (Int.Cl. 7 , DB name) G06F 9/06-9/46

Claims (2)

(57)【特許請求の範囲】(57) [Claims] 【請求項1】 下記の要素を有するプログラム作成支援
装置 (a)プログラムを対話的に作成及び編集するプログラ
ム編集手段 (b)前記プログラム編集手段により作成及び編集され
たプログラムの動作を対話的に検証するプログラム検証
手段 (c)作成および編集されたプログラムのソースコード
を解析し中間表現に変換するソースコード解析手段 (d)前記中間表現を格納する中間表現格納手段 (e)プログラミング言語の語彙/文法ルールを内含し
た構文解析ルール (f)前記構文解析ルールから自動的にソースコード解
析手段を生成する構文解析器生成手段 (g)プログラミング言語の語彙/文法ルールを内含し
たコード生成ルール (h)前記コード生成ルールからソースコード生成手段
を自動的に生成するコード生成器生成手段。
1. A program creation support device having the following elements: (a) program editing means for interactively creating and editing a program; and (b) interactively verifying the operation of the program created and edited by the program editing means. (C) Source code analysis means for analyzing the source code of a created and edited program and converting it to an intermediate expression (d) Intermediate expression storage means for storing the intermediate expression (e) Vocabulary / grammar of programming language (F) a parser generating means for automatically generating source code analyzing means from the parsing rules; (g) a code generating rule including vocabulary / grammar rules of a programming language (h A) a code generator generating means for automatically generating source code generating means from the code generation rules; .
【請求項2】 下記の要素を有するプログラム作成支援
装置 (a)プログラムを対話的に作成及び編集するプログラ
ム編集手段 (b)前記プログラム編集手段により作成及び編集され
たプログラムの動作を対話的に検証するプログラム検証
手段 (c)作成および編集されたプログラムのソースコード
を解析し中間表現に変換するソースコード解析手段 (d)前記中間表現を格納する中間表現格納手段 (e)プログラミング言語の語彙/文法ルールを内含し
た構文解析ルール (f)前記構文解析ルールから自動的にソースコード解
析手段を生成する構文解析器生成手段 (g)プログラミング言語の語彙/文法ルールを内含し
たコード生成ルール (h)前記コード生成ルールからソースコード生成手段
を自動的に生成するコード生成器生成手段 (i)前記構文解析ルールからソースコード生成手段を
生成するためのコード生成ルールで利用可能な語彙/文
法ルールを抽出する語彙/文法ルール抽出手段。
2. A program creation support device having the following elements: (a) program editing means for creating and editing a program interactively; and (b) interactively verifying the operation of the program created and edited by the program editing means. (C) Source code analysis means for analyzing the source code of a created and edited program and converting it to an intermediate expression (d) Intermediate expression storage means for storing the intermediate expression (e) Vocabulary / grammar of programming language (F) a parser generating means for automatically generating source code analyzing means from the parsing rules; (g) a code generating rule including vocabulary / grammar rules of a programming language (h A) a code generator generating means for automatically generating source code generating means from the code generation rules; (I) the syntax vocabulary / grammar rule extraction means for extracting the available vocabulary / grammar rules from the analysis rule in the code generation rules for generating a source code generating means.
JP5138303A 1993-06-10 1993-06-10 Program creation support device Expired - Lifetime JP3003459B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP5138303A JP3003459B2 (en) 1993-06-10 1993-06-10 Program creation support device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP5138303A JP3003459B2 (en) 1993-06-10 1993-06-10 Program creation support device

Publications (2)

Publication Number Publication Date
JPH06348465A JPH06348465A (en) 1994-12-22
JP3003459B2 true JP3003459B2 (en) 2000-01-31

Family

ID=15218727

Family Applications (1)

Application Number Title Priority Date Filing Date
JP5138303A Expired - Lifetime JP3003459B2 (en) 1993-06-10 1993-06-10 Program creation support device

Country Status (1)

Country Link
JP (1) JP3003459B2 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3069050B2 (en) * 1996-07-24 2000-07-24 日本ソフト開発株式会社 Program conversion method
JP6906155B2 (en) * 2016-03-01 2021-07-21 直太 稲本 Automatic software generator capable of reverse engineering

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
"コンパイラの代数的仕様記述と自動生成",電子情報通信学会論文誌 D−I,(1990/12),Vol.J73−D−I,pp.979−989
"演算子識別アルゴリズムのyaccを使った実現(2)",bit,(1993/1),Vol.25,No.1,pp.95−97
"確定節文法のための内部構造変換機能付きパーザとアンパーザの自動生成方式",情報処理学会論文誌,(1990/11),Vol.31,No.11,pp.1616−1626
「yacc−Yet Another Compiler−Compiler」,Sun Microsystems,(1990)
情報処理(1990−8),情報処理学会,vol.31,No.8,pp.1013−1047

Also Published As

Publication number Publication date
JPH06348465A (en) 1994-12-22

Similar Documents

Publication Publication Date Title
US5946488A (en) Method for selectively and incrementally displaying the results of preprocessing
JPS6375835A (en) Apparatus for generating intended code, program, list and design document
JPS61282935A (en) Method and apparatus for alloting and inspecting attribute in program
JPH08314728A (en) Method and apparatus for conversion of source program into object program
JPH0778742B2 (en) Computer program language conversion device and method thereof
Angelov et al. PGF: A portable run-time format for type-theoretical grammars
JP3003459B2 (en) Program creation support device
JPH02112068A (en) System for simply displaying text
JPH07160490A (en) Coding assistance device
JP3141945B2 (en) Compiling device
JP3419483B2 (en) Natural language processing apparatus and method
JPH0895761A (en) Program production support device
JPH10269066A (en) Automatic shell preparation device by japanese
JP3370243B2 (en) Compilation method and apparatus
JP2720643B2 (en) Program generator generator
JPH02281337A (en) Method for extending translator generator
CN117827171A (en) Method and device for generating project source codes through json schema file
JP3233800B2 (en) Machine translation equipment
JPH02159629A (en) Computer language translating system
Almufti A SYSTEM FOR THE MANIPULATION
JPS63226730A (en) Automatic program forming method
JPH04370829A (en) Source code editing system
JP2001034482A (en) Compile device, program optimizing device, compile processing method and recording medium
JPH0546373A (en) Flow chart generation processor
Sharma et al. PARSING TECHNIQUES: A REVIEW