JPH07239787A - Extraction device for information from parsing tree - Google Patents

Extraction device for information from parsing tree

Info

Publication number
JPH07239787A
JPH07239787A JP6054952A JP5495294A JPH07239787A JP H07239787 A JPH07239787 A JP H07239787A JP 6054952 A JP6054952 A JP 6054952A JP 5495294 A JP5495294 A JP 5495294A JP H07239787 A JPH07239787 A JP H07239787A
Authority
JP
Japan
Prior art keywords
information
language
tree
tool
parse tree
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.)
Granted
Application number
JP6054952A
Other languages
Japanese (ja)
Other versions
JP3328056B2 (en
Inventor
Hiroaki Kimura
博昭 木村
Masahiro Noguchi
正浩 野口
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.)
Nippon Steel Corp
Original Assignee
Nippon Steel 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 Nippon Steel Corp filed Critical Nippon Steel Corp
Priority to JP05495294A priority Critical patent/JP3328056B2/en
Publication of JPH07239787A publication Critical patent/JPH07239787A/en
Application granted granted Critical
Publication of JP3328056B2 publication Critical patent/JP3328056B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Landscapes

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

Abstract

PURPOSE:To easily extract information from a source program of any language and to make the correspondence relation between the original source program and the extracted information clear. CONSTITUTION:At a request given by one of tools 9, 10..., an instruction extracting means 6 extracts necessary information from the parsing tree of the object language, converts only the extracted information to a common format which does not depend upon the language of the extracted information, and supplied it to the use currently in use. When a source program of any language among 7, 8... is handled, information on the common format among respective languages is supplied to the tool to enable the languages to be processed by the one tool, the correspondence relation between the parsing tree and extracted information is prevented from becoming unclear as a result of the conversion to the common format, and the result of the processing into an object source program by the tool is easily reflected.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は構文解析木からの情報抽
出装置に関し、特に、ソースプログラムの解析を行うソ
フトウェア開発等を行う際に用いて好適なものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an information extraction device from a syntax analysis tree, and is particularly suitable for use in software development for analyzing a source program.

【0002】[0002]

【従来の技術】従来より、ソースプログラムの解析を行
うアプリケーションソフトウェア等の開発を行う際に
は、現存するソースプログラムを構文解析し、この解析
の結果得られる情報を様々なツール(例えば、コールグ
ラフ生成器やデータフロー解析器)で処理するといった
ことが行われている。このようなソフトウェアは、種々
の手続き型言語のソースプログラムを対象としている。
2. Description of the Related Art Conventionally, when developing application software for analyzing a source program, an existing source program is parsed, and information obtained as a result of this analysis is analyzed by various tools (for example, call graph). It is performed by a generator or a data flow analyzer). Such software is intended for source programs in various procedural languages.

【0003】このように、種々の言語のソースプログラ
ムの解析結果から必要な情報を抽出し、この情報を用い
て所定の処理をツールで行うことができるようにするた
めに、従来は主に次の2つの方法が採られている。
As described above, in order to extract necessary information from the analysis results of source programs of various languages and to enable a tool to perform a predetermined process by using this information, conventionally, the following is mainly used. Two methods are adopted.

【0004】すなわち、第1の方法は、各言語ごとにプ
ログラム解析システムを作成する方法である。例えば、
対象となるソースプログラムに第1の言語と第2の言語
との2つがある場合には、第1の言語用のプログラム解
析システムと第2の言語用のプログラム解析システムと
をそれぞれ作成するといった具合である。
That is, the first method is a method of creating a program analysis system for each language. For example,
When the target source program has two languages, the first language and the second language, a program analysis system for the first language and a program analysis system for the second language are created respectively. Is.

【0005】また、第2の方法は、各言語のソースプロ
グラムの解析結果を各言語に共通な中間表現に翻訳し、
この中間表現を用いてツールで解析等の処理を行うとい
った方法である。
The second method is to translate the analysis result of the source program of each language into an intermediate representation common to each language,
A method is to perform processing such as analysis with a tool using this intermediate representation.

【0006】[0006]

【発明が解決しようとする課題】上述した第1の方法
は、各言語に対応したツールを各言語ごとに作成するの
で、各言語に依存した細かい情報まで扱うことができ
る。しかし、各言語ごとにツールを作成しなければなら
ないので、そのためのコストが多くかかるという問題が
あった。また、ツールの機能を拡張するときなどは、各
言語ごとに対応させなければならないので、拡張時にも
非常に手間がかかるという問題があった。
In the first method described above, a tool corresponding to each language is created for each language, so that even detailed information depending on each language can be handled. However, since it is necessary to create a tool for each language, there is a problem in that it costs a lot. In addition, when the function of the tool is expanded, it is necessary to correspond to each language, so that there is a problem that it takes a lot of time to expand the function.

【0007】一方、第2の方法は、各言語のソースプロ
グラムの解析結果を各言語に共通する中間表現に翻訳す
るようにしているので、対象とする言語にかかわらず共
通にツールを作成することができる。このため、この第
2の方法では、上述のような問題は起こらない。
On the other hand, in the second method, the analysis result of the source program of each language is translated into an intermediate representation common to each language, so that a common tool is created regardless of the target language. You can Therefore, the problem described above does not occur in this second method.

【0008】しかしながら、この第2の方法は、ソース
プログラムの解析結果の全てについて中間表現への翻訳
が一括して行われるようになされている。このため、元
のソースプログラムと翻訳後の中間表現との対応が取り
にくくなるので、例えば、中間表現の中のある部分が元
のソースプログラムのどの部分に対応するのかを求めた
り、各ツールにおける処理の結果に応じて元のソースプ
ログラムを変換したりするということは困難であった。
また、各言語に特有な部分の情報が中間表現への翻訳の
際に失われてしまうという問題もあった。
However, in the second method, all the analysis results of the source program are collectively translated into the intermediate representation. For this reason, it becomes difficult to make correspondence between the original source program and the intermediate expression after translation. For example, it is necessary to find out which part of the original source program a certain part of the intermediate expression corresponds to, It was difficult to convert the original source program according to the processing result.
In addition, there is a problem that information of a part peculiar to each language is lost during the translation into the intermediate representation.

【0009】本発明は、このような問題を解決するため
に成されたものであり、どのような言語のソースプログ
ラムからも情報を容易に取り出せるようにするととも
に、元のソースプログラムとその中間表現との対応関係
を明確にすることができるようにすることを目的として
いる。
The present invention has been made to solve such a problem, and makes it possible to easily extract information from a source program of any language, and at the same time, the original source program and its intermediate representation. The purpose is to be able to clarify the correspondence relationship with.

【0010】[0010]

【課題を解決するための手段】本発明の構文解析木から
の情報抽出装置は、ソースプログラムの構文解析木から
情報を抽出し、所定の処理を施すようにしたツールに、
上記抽出した情報を提供する構文解析木からの情報抽出
装置において、種々のプログラミング言語で記述されて
いるソースプログラムから構文解析木を作成するために
上記各プログラミング言語ごとに設けられた複数の構文
解析手段と、上記複数の構文解析手段からそれぞれ出力
される構文解析木を上記ツールからの要求に応じて調
べ、上記ツールが対象としているプログラミング言語の
構文解析木から情報を抽出するとともに、上記抽出した
情報を上記各プログラミング言語に共通する形式に変換
して上記ツールに供給する情報抽出手段とを具備するも
のである。
An information extraction device from a syntax analysis tree of the present invention is a tool for extracting information from a syntax analysis tree of a source program and performing a predetermined process,
In the information extraction device from the syntactic analysis tree that provides the extracted information, a plurality of syntactic analysis provided for each of the programming languages in order to create the syntactic analysis tree from the source programs described in various programming languages. Means and the syntax analysis tree output from each of the plurality of syntax analysis means according to a request from the tool, and extract the information from the syntax analysis tree of the programming language targeted by the tool. An information extracting means for converting information into a format common to each programming language and supplying it to the tool is provided.

【0011】本発明の他の特徴とするところは、上記複
数の構文解析手段よりそれぞれ出力される構文解析木か
ら情報を抽出するために上記各プログラミング言語ごと
に設けられた複数の構文解析木アクセス手段と、上記複
数の構文解析木アクセス手段の中から上記ツールが対象
としているプログラミング言語に対応する構文解析木ア
クセス手段を上記ツールからの要求に応じて選択するこ
とにより、対象とする構文解析木アクセス手段を切り替
える言語切替手段と、上記言語切替手段で選択された構
文解析木アクセス手段により抽出された情報を各プログ
ラミング言語に共通する形式に変換する共通形式への変
換手段とにより上記情報抽出手段を構成したものであ
る。
Another feature of the present invention is to access a plurality of parse trees provided for each of the programming languages in order to extract information from the parse trees output from the plurality of syntax analysis means. Means and a parse tree access means corresponding to the programming language targeted by the tool from among the plurality of parse tree access means according to a request from the tool. The information extracting means includes a language switching means for switching the access means and a conversion means for converting the information extracted by the syntax analysis tree access means selected by the language switching means into a format common to each programming language. Is configured.

【0012】本発明の更に他の特徴とするところは、上
記言語切替手段で選択された構文解析木アクセス手段に
より抽出された情報を上記各プログラミング言語に共通
する形式に変換するか否かを選択する選択手段を具備す
るものである。
Still another feature of the present invention is that whether or not the information extracted by the parse tree access means selected by the language switching means is converted into a format common to each programming language is selected. The selection means is provided.

【0013】[0013]

【作用】本発明は上記技術手段より成るので、何れのプ
ログラミング言語のソースプログラムを対象とするかに
かかわらず、プログラミング言語に依存しない共通形式
の情報がツールに与えられるようになり、複数のプログ
ラミング言語のソースプログラムを1つのツールで処理
することが可能となる。また、ツールからの要求に応じ
て対応する構文解析木から取り出される情報のみが中間
形式に変換されるようになるので、取り出された情報と
構文解析木との対応関係が明確になる。
Since the present invention comprises the above technical means, regardless of which programming language source program is targeted, the tool is provided with information in a common format independent of the programming language, and a plurality of programming languages are provided. It is possible to process a language source program with one tool. Further, only the information extracted from the corresponding parse tree in response to the request from the tool is converted into the intermediate format, so that the correspondence relationship between the extracted information and the parse tree becomes clear.

【0014】本発明の他の特徴によれば、複数のプログ
ラミング言語を1つのツールで処理することが可能とな
り、しかも、処理しようとするプログラミング言語を動
的に選択することが可能となるので、種々の言語のソー
スプログラムから必要な情報を抽出する際の労力が軽減
される。
According to another feature of the present invention, a plurality of programming languages can be processed by one tool, and the programming language to be processed can be dynamically selected. Efforts to extract necessary information from source programs in various languages are reduced.

【0015】本発明の更に他の特徴によれば、構文解析
木から抽出される情報のうち、プログラミング言語に特
有な情報については中間形式に変換しないこともできる
ので、中間形式への変換の際にプログラミング言語に特
有な部分の情報が失われてしまうという不都合がなくな
る。
According to still another feature of the present invention, among the information extracted from the parse tree, the information specific to the programming language may not be converted into the intermediate format. In addition, the inconvenience of losing the information specific to the programming language is eliminated.

【0016】[0016]

【実施例】以下、本発明の一実施例を図面に基づいて説
明する。図1は、本実施例による構文解析木からの情報
抽出装置を適用したプログラム解析システムの要部構成
を示すブロック図である。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described below with reference to the drawings. FIG. 1 is a block diagram showing a main configuration of a program analysis system to which an information extraction device from a syntax analysis tree according to this embodiment is applied.

【0017】図1において、1は本実施例による構文解
析木からの情報抽出装置であり、第1の言語の構文解析
手段2,第2の言語の構文解析手段3,…と、上記構文
解析手段2,3,…のそれぞれから与えられる構文解析
木を記憶しておくための第1の言語の構文解析木記憶手
段4,第2の言語の構文解析木記憶手段5,…と、情報
抽出手段6とにより構成されている。
In FIG. 1, reference numeral 1 denotes an information extraction device from a syntax analysis tree according to this embodiment, which is a syntax analysis means 2 for a first language, a syntax analysis means 3, for a second language, ... .. for storing the parse tree given by each of the means 2, 3, ... For storing the parse tree for the first language 4, the parse tree storage means for the second language 5 ,. And means 6.

【0018】上記各構文解析手段2,3,…は、それぞ
れ第1の言語のソースプログラム7,第2の言語のソー
スプログラム8,…ごとに対応して設けられており、上
記各言語のソースプログラム7,8,…を解析して各言
語の構文解析木を作成するものである。ここで、構文解
析木とは、ソースプログラムの構造を木構造で表現した
ものである。また、ソースプログラムの言語としては、
例えば、FORTRAN,C,COBOL,PASCA
L,BASICなどがある。
The syntactic analysis means 2, 3, ... Are provided in correspondence with the source program 7 of the first language, the source program 8 of the second language ,. The program 7, 8, ... Is analyzed to create a syntax analysis tree for each language. Here, the syntactic analysis tree is a tree structure representing the structure of the source program. Also, as the language of the source program,
For example, FORTRAN, C, COBOL, PASCA
L, BASIC, etc.

【0019】また、上述の情報抽出手段6は、コールグ
ラフ生成器9,データフロー解析器10,…などの各ツ
ールから与えられる要求に応じて、上記各構文解析木記
憶手段4,5,…に格納されている構文解析木から必要
な情報を抽出し、これを言語に依存しない各言語に共通
する形式に変換して上記コールグラフ生成器9,データ
フロー解析器10,…に供給するものである。なお、構
文解析木から抽出される情報は、上記各ツール9,1
0,…からの要求によって様々である。
Further, the above-mentioned information extracting means 6 responds to a request given from each tool such as the call graph generator 9, the data flow analyzer 10, ... Which extracts necessary information from the syntax parse tree stored in, converts it into a format common to each language independent of the language, and supplies it to the call graph generator 9, the data flow analyzer 10 ,. Is. The information extracted from the syntax analysis tree is the above tools 9, 1
It varies depending on the request from 0, ....

【0020】上記情報抽出手段6は、構文解析木のノー
ドを順番に辿る機能や、値が参照された変数あるいは代
入された変数を求める機能や、構文解析木のノードがソ
ースプログラムのどの部分に当たるのかを求める機能な
どを有している。そして、コールグラフ生成器9,デー
タフロー解析器10,…などの各ツールから与えられる
要求に応じてこれらの機能が実行され、これによって必
要な情報が構文解析木から抽出されるようになされてい
る。
The information extraction means 6 has a function of sequentially tracing the nodes of the parse tree, a function of obtaining a variable whose value is referred to or a variable to which a value is assigned, and a node of the parse tree corresponds to which part of the source program. It has a function to ask for Then, these functions are executed in response to a request given from each tool such as the call graph generator 9, the data flow analyzer 10, ..., By this, necessary information is extracted from the parse tree. There is.

【0021】ここで、上記コールグラフ生成器9は、ソ
ースプログラムから抽出した情報を用いてプログラムの
解析や加工を行ってコールグラフの生成を行うためのも
のである。例えば、コールグラフ生成器9は、ソースプ
ログラム中の関数や手続きがどこで定義され、どこで呼
び出されているかという情報を情報抽出手段6から受け
取り、上記関数や手続き間の呼び出し関係を求める。
The call graph generator 9 is for generating a call graph by analyzing and processing the program using the information extracted from the source program. For example, the call graph generator 9 receives information about where a function or procedure in a source program is defined and where it is called from the information extracting means 6, and obtains a calling relationship between the functions and procedures.

【0022】また、データフロー解析器10は、プログ
ラム中のデータの流れを解析するためのものである。例
えば、データフロー解析器10は、ソースプログラム中
の変数の定義がどこで行われ、どこで使用されているか
という情報を情報抽出手段6から受け取り、データフロ
ーの解析を行う。
The data flow analyzer 10 is for analyzing the flow of data in the program. For example, the data flow analyzer 10 receives from the information extraction means 6 information about where a variable in the source program is defined and where it is used, and analyzes the data flow.

【0023】次に、上述した情報抽出手段6の具体的な
構成を、図2に示す。図2において、11は第1の言語
の構文解析木アクセス手段であり、各ツール9,10,
…から与えられる要求に応じて、第1の言語の構文解析
木記憶手段4をアクセスし、そこから必要な情報を取り
出すためのものである。
Next, FIG. 2 shows a concrete configuration of the above-mentioned information extracting means 6. In FIG. 2, reference numeral 11 is a parse tree access unit of the first language, and each tool 9, 10,
This is for accessing the parse tree storage means 4 of the first language in response to a request given from ... and extracting necessary information therefrom.

【0024】上記第1の言語の構文解析木アクセス手段
11は、構文解析木の移動・検出部11aと、情報の抽
出部11bと、構文解析木の変更部11cとを有してい
る。上記構文解析木の移動・検出部11aは、第1の言
語の構文解析木のノードを順番に辿っていくとともに、
その構文解析木が元のソースプログラム中のどの部分に
対応するのかを検出するものである。この構文解析木移
動・検出部11aは、構文解析木をどのように辿ってき
たかとか、今どの部分をアクセスしているかといった状
態を表す情報を保持している。
The parse tree access means 11 of the first language has a parse tree moving / detecting section 11a, an information extracting section 11b, and a parse tree changing section 11c. The parsing tree moving / detecting unit 11a sequentially follows the nodes of the parsing tree of the first language,
It detects which part of the original source program the parse tree corresponds to. The parse tree moving / detecting unit 11a holds information indicating a state such as how the parse tree is followed and which part is being accessed now.

【0025】また、上記情報の抽出部11bは、各ツー
ル9,10,…から与えられる要求に応じて第1の言語
の構文解析木から必要な情報を取り出す。例えば、情報
の抽出部11bは、関数や変数がソースプログラム中の
どこで定義され、また、どこで呼び出されているかとい
った情報を第1の言語の構文解析木から取り出す。さら
に、上記構文解析木の変更部11cは、各ツール9,1
0,…からの要求に応じて対象とする構文解析木を変更
するためのものである。
Further, the information extracting unit 11b extracts necessary information from the syntactic analysis tree of the first language in response to a request given from each of the tools 9, 10, .... For example, the information extraction unit 11b extracts information such as where the function or variable is defined in the source program and where it is called from the syntax analysis tree of the first language. Further, the parsing tree changing unit 11c includes the tools 9, 1
This is for changing the target parse tree in response to a request from 0, ....

【0026】次いで、12は選択手段であり、上記第1
の言語の構文解析木アクセス手段11により抽出された
情報を各言語に共通する形式に変換するか否かを選択す
るものである。ここでは、各言語に特有な部分の情報は
共通形式に変換されず、その他の情報が変換されるよう
に選択が行われる。また、13は共通形式への変換手段
であり、上記選択手段12より与えられる情報をプログ
ラミング言語に依存しない共通形式に変換するものであ
る。
Next, 12 is a selection means, which is the first
This is to select whether or not to convert the information extracted by the syntax analysis tree access unit 11 of the language into a format common to each language. Here, the selection is made such that the information of the part peculiar to each language is not converted into the common format, but other information is converted. Reference numeral 13 is a common format conversion means for converting the information provided by the selection means 12 into a common format independent of the programming language.

【0027】以上のように、本実施例においては、構文
解析木アクセス手段11、選択手段12および共通形式
への変換手段13により、第1の言語の構文解析木から
必要な情報を抽出してこれを共通形式に変換するための
構成がなされている。第2の言語に関しても上述の構成
と同様にして構成されている。つまり、構文解析木アク
セス手段14、選択手段15および共通形式への変換手
段16により、第2の言語の構文解析木から必要な情報
を抽出してこれを共通形式に変換するための構成がなさ
れている。図示しない他の言語についても同様である。
As described above, in this embodiment, the necessary information is extracted from the parse tree of the first language by the parse tree access means 11, the selection means 12 and the common format conversion means 13. A configuration is provided for converting this into a common format. The second language is also configured in the same manner as the above configuration. That is, the parse tree access unit 14, the selection unit 15, and the common format conversion unit 16 are configured to extract necessary information from the parse tree of the second language and convert it into the common format. ing. The same applies to other languages not shown.

【0028】次いで、17は言語切替手段であり、対象
としているプログラミング言語に応じて、その言語用の
構文解析木アクセス手段を、各言語の構文解析木アクセ
ス手段11,14,…の中から選択する。そして、言語
切替手段17は、何れかの構文解析木アクセス手段を選
択した後は、その構文解析木アクセス手段とそのとき使
用中のツールとの間におけるインタフェースとして機能
する。
Next, 17 is a language switching means, which selects the parse tree access means for that language from among the parse tree access means 11, 14, ... In accordance with the target programming language. To do. Then, after selecting one of the parse tree access means, the language switching means 17 functions as an interface between the parse tree access means and the tool currently being used.

【0029】次に、以上のように構成した本実施例によ
る構文解析木からの情報抽出装置の動作を具体例を挙げ
て説明する。ここでは、C言語およびFORTRANの
2つの言語のソースプログラムからコールグラフを生成
する場合を例にとって説明する。つまり、図1に示した
第1の言語のソースプログラム7はC言語のプログラム
であり、第2の言語のソースプログラム8はFORTR
ANのプログラムであるとする。
Next, the operation of the information extraction device from the syntax analysis tree according to the present embodiment configured as described above will be described with reference to a specific example. Here, a case where a call graph is generated from a source program of two languages of C language and FORTRAN will be described as an example. That is, the first language source program 7 shown in FIG. 1 is a C language program, and the second language source program 8 is FORTR.
Suppose it is an AN program.

【0030】この場合、C言語のソースプログラム7と
FORTRANのソースプログラム8として、それぞれ
図3および図4に示したものがあるとする。これらのソ
ースプログラム7,8は、それぞれの言語の構文解析手
段2,3によりそれぞれの言語の構文解析木に変換され
る。そして、これらの構文解析木が各言語の構文解析木
記憶手段4,5に記憶される。
In this case, it is assumed that the C language source program 7 and the FORTRAN source program 8 include those shown in FIGS. 3 and 4, respectively. These source programs 7 and 8 are converted into syntax analysis trees of respective languages by the syntax analysis means 2 and 3 of the respective languages. Then, these parse trees are stored in the parse tree storage means 4 and 5 for each language.

【0031】すなわち、C言語のソースプログラム7
は、第1の言語の構文解析手段2で構文解析木に変換さ
れ、その構文解析木が第1の言語の構文解析木記憶手段
4に記憶される。また、FORTRANのソースプログ
ラム8は、第2の言語の構文解析手段3で構文解析木に
変換され、その構文解析木が第2の言語の構文解析木記
憶手段5に記憶される。こうして記憶される構文解析木
は、各プログラミング言語に依存しており、その構造は
プログラミング言語によって異なっている。
That is, the C language source program 7
Is converted into a syntax analysis tree by the syntax analysis means 2 of the first language, and the syntax analysis tree is stored in the syntax analysis tree storage means 4 of the first language. Further, the FORTRAN source program 8 is converted into a parse tree by the parse tree 3 of the second language, and the parse tree is stored in the parse tree storage 5 of the second language. The parse tree stored in this way depends on each programming language, and its structure differs depending on the programming language.

【0032】ところで、コールグラフを生成するために
は、C言語においては、どの関数定義の中でどの関数呼
び出しがあるかを求めることが必要である。また、FO
RTRANにおいては、どのプログラム定義,サブルー
チン定義,関数定義の中でどのサブルーチン呼び出し,
関数呼び出しがあるかを求める必要がある。
By the way, in order to generate a call graph, in the C language, it is necessary to find out which function call is included in which function definition. Also, FO
In RTRAN, which program definition, subroutine definition, which subroutine call in function definition,
Need to ask if there is a function call.

【0033】このように、各プログラミング言語の構造
の差異に起因して、コールグラフを生成する際に必要と
なる情報は、プログラミング言語ごとに異なっている。
そこで、各言語の構文解析木から抽出される情報に対し
て情報抽出手段6で所定の処理を施すことにより、上記
サブルーチンや関数などを言語に依存しない共通形式の
手続きとして表現するようにしている。
As described above, due to the difference in the structure of each programming language, the information required when generating a call graph differs for each programming language.
Therefore, the information extraction means 6 performs a predetermined process on the information extracted from the syntax analysis tree of each language, so that the above-mentioned subroutines and functions are expressed as a common format procedure that does not depend on the language. .

【0034】例えば、図3に示したC言語のソースプロ
グラム中における関数aの定義,関数bの定義,関数c
の定義を、それぞれ手続きaの定義,手続きbの定義,
手続きcの定義というように表現する。また、図4に示
したFORTRANのソースプログラム中におけるプロ
グラムcの定義,サブルーチンaの定義,関数bの定義
を、それぞれ手続きcの定義,手続きaの定義,手続き
bの定義というように表現する。
For example, the definition of function a, the definition of function b, and the function c in the C language source program shown in FIG.
, The definition of procedure a, the definition of procedure b,
It is expressed as the definition of procedure c. Further, the definition of the program c, the definition of the subroutine a, and the definition of the function b in the source program of FORTRAN shown in FIG. 4 are expressed as the definition of the procedure c, the definition of the procedure a, and the definition of the procedure b, respectively.

【0035】このようにすることによって、コールグラ
フ生成器9は、C言語のソースプログラム7からもFO
RTRANのソースプログラム8からも必要な情報を取
り出してコールグラフを生成することができる。これに
より、各言語に対応するコールグラフ生成器を各言語ご
とに作る必要がなくなるので、コストを削減することが
できる。
By doing so, the call graph generator 9 can obtain the FO from the C language source program 7.
The call graph can be generated by taking out necessary information from the RTRAN source program 8. This eliminates the need to create a call graph generator corresponding to each language for each language, thus reducing costs.

【0036】また、上述のように、プログラミング言語
に依存しない形でコールグラフ生成器を作ることができ
るので、対象とするプログラミング言語を追加する場合
に、その言語の構文解析木アクセス手段を作るだけで、
コールグラフ生成器には変更を加えることなく追加する
ことができ、その労力を軽減することができる。
Further, as described above, since the call graph generator can be created in a form independent of the programming language, when adding the target programming language, it is only necessary to create the parse tree access means for that language. so,
It can be added to the call graph generator without any modification, and the labor can be reduced.

【0037】ここで、例えば、C言語の構文解析木から
必要な情報を抽出し、抽出した情報を共通形式に変換す
る際の動作について、図1,図2を参照して説明する。
まず、コールグラフ生成器9は、情報抽出手段6に対し
てC言語を対象とする旨の要求を送る。情報抽出手段6
の中の言語切替手段17は、この要求を受け取って、各
言語の構文解析木アクセス手段11,14,…の中か
ら、第1の言語の構文解析木アクセス手段11を選択す
る。
Here, for example, the operation of extracting necessary information from the C language syntax analysis tree and converting the extracted information into a common format will be described with reference to FIGS. 1 and 2.
First, the call graph generator 9 sends a request to the information extracting means 6 to target the C language. Information extraction means 6
Upon receipt of this request, the language switching means 17 in the above section selects the parse tree access means 11 of the first language from the parse tree access means 11, 14 ,.

【0038】次いで、手続きの定義と呼び出しの情報が
欲しいという要求がコールグラフ生成器9から情報抽出
手段6に対して出されると、その要求は上記言語切替手
段17を介して第1の言語の構文解析木アクセス手段1
1に与えられる。そして、この第1の言語の構文解析木
アクセス手段11により、第1の言語の構文解析木記憶
手段4に記憶されているC言語の構文解析木が解析さ
れ、必要な情報が抽出される。
Next, when the call graph generator 9 issues a request to the information extracting means 6 for the procedure definition and call information, the request is sent via the language switching means 17 to the first language. Parsing tree access means 1
Given to 1. Then, the parse tree access unit 11 of the first language analyzes the C parse tree stored in the parse tree storage unit 4 of the first language to extract necessary information.

【0039】こうして抽出された情報は、選択手段12
に与えられる。そして、与えられた情報がC言語に特有
のものか否かがこの選択手段12により判別され、C言
語に特有でない情報のみが共通形式への変換手段13に
与えられて、言語に依存しない共通形式に変換される。
The information thus extracted is selected by the selecting means 12
Given to. Then, whether or not the given information is peculiar to the C language is discriminated by the selecting means 12, and only the information not peculiar to the C language is given to the converting means 13 to the common format so that the common information independent of the language is obtained. Converted to format.

【0040】例えば、図3に示したC言語のソースプロ
グラムの構文解析木からは、次のような情報が抽出され
る。 ・関数aの定義がある。 ・関数bの定義がある。 ・関数cの定義があり、その中で、 −関数aの呼び出しがある。 −関数bの呼び出しがある。
For example, the following information is extracted from the syntax analysis tree of the C language source program shown in FIG. -There is a definition of function a.・ Function b is defined. There is a definition of the function c, in which there is a call to the function a. There is a call to function b.

【0041】この場合、上記のような情報は共通形式へ
の変換手段13に与えられ、次のようなプログラミング
言語に依存しない共通形式の情報に変換される。 ・手続きaの定義がある。 ・手続きbの定義がある。 ・手続きcの定義があり、その中で、 −手続きaの呼び出しがある。 −手続きbの呼び出しがある。
In this case, the above information is given to the common format conversion means 13 and converted into the following common format information which does not depend on the programming language.・ Procedure a is defined.・ Procedure b is defined. There is a definition of procedure c, in which: -Call of procedure a. There is a call to procedure b.

【0042】次いで、以上のようにして共通形式に変換
された情報は、言語切替手段17を介してコールグラフ
生成器9に送られる。そして、こうして送られてきた情
報に基づいてコールグラフ生成器9で所定の処理が施さ
れることにより、図5に示すようなコールグラフが生成
される。
Next, the information converted into the common format as described above is sent to the call graph generator 9 via the language switching means 17. Then, the call graph generator 9 performs a predetermined process on the basis of the information thus sent, thereby generating a call graph as shown in FIG.

【0043】このように、本実施例による構文解析木か
らの情報抽出装置においては、従来のように構文解析木
から抽出される情報の全てを中間形式に変換するのでは
なく、ツールからの要求に応じて対応する構文解析木か
ら取り出された情報のみを中間形式に変換するようにし
ている。このため、取り出された情報が構文解析木のど
の部分に対応しているのかを容易に判断することができ
るようになる。
As described above, in the information extraction device from the parse tree according to the present embodiment, not all the information extracted from the parse tree is converted into the intermediate format as in the conventional case, but the request from the tool is issued. According to the above, only the information extracted from the corresponding parse tree is converted into the intermediate format. Therefore, it becomes possible to easily determine which part of the parse tree the extracted information corresponds to.

【0044】したがって、例えば、ツールによる処理の
結果に行番号やソースコードの一部を付けて出力した
り、構文解析木を変更する場合にその構文解析木がどこ
にあるのかを求めたりすることが容易になる。
Therefore, for example, it is possible to add a line number or a part of the source code to the result of processing by the tool and output it, or to find out where the parse tree is when changing the parse tree. It will be easier.

【0045】また、中間形式への変換に際しては、プロ
グラミング言語に特有な部分については変換を行わない
ようにしているので、変換の際に言語特有な部分の情報
が失われてしまうという不都合をなくすことができる。
これにより、対象としているソースプログラムから必要
な情報を確実に取り出すことができる。
Further, when converting to the intermediate format, since the conversion is not performed for the part peculiar to the programming language, there is no inconvenience that the information of the part peculiar to the language is lost during the conversion. be able to.
As a result, it is possible to reliably extract the necessary information from the target source program.

【0046】なお、中間形式に変換されなかった言語特
有な部分の情報についても処理を施すためには、その言
語専用のツール(例えば、第1の言語に特有な部分の情
報を処理するためのツール,第2の言語に特有な部分の
情報を処理するためのツールなど)を設けて、これらの
ツールによって処理する必要がある。しかし、これらの
ツールを設けたとしても、各言語に対応するツールを各
言語ごとに設けるといった従来技術に比べて、全体とし
てのツール数は格段に少なくなる。
In order to process the information of the language-specific part which has not been converted into the intermediate format, a tool dedicated to that language (for example, the information of the part specific to the first language is processed). Tools, tools for processing information specific to the second language, etc.) must be provided and processed by these tools. However, even if these tools are provided, the number of tools as a whole is significantly smaller than that in the conventional technique in which a tool corresponding to each language is provided for each language.

【0047】さらに、本実施例による構文解析木からの
情報抽出装置によれば、複数のプログラミング言語の構
文解析木を1つのツールで処理することができ、しか
も、どの言語の構文解析木を処理するのかを動的に選択
することができるので、構文解析木からの情報抽出を容
易に行うことができるようになり、これによってプログ
ラム解析ツールの開発作業の効率を向上させることがで
きる。また、各言語ごとに使用するツールを変える必要
がないので、オペレータにとっても非常に便利である。
Furthermore, according to the information extraction device from the syntax analysis tree according to the present embodiment, the syntax analysis trees of a plurality of programming languages can be processed by one tool, and the syntax analysis tree of which language is processed. Since it is possible to dynamically select whether or not to do so, it becomes possible to easily extract information from the syntactic analysis tree, which can improve the efficiency of the development work of the program analysis tool. Moreover, since it is not necessary to change the tool used for each language, it is very convenient for the operator.

【0048】[0048]

【発明の効果】本発明は上述したように、ツールからの
要求に応じて対象としているプログラミング言語の構文
解析木から必要な情報を取り出し、これを言語に依存し
ない共通形式に変換してから上記ツールに供給するよう
にしたので、どのようなプログラミング言語を扱う場合
にも、言語に依存しない共通形式の情報がツールに与え
られるようになり、複数のプログラミング言語のソース
プログラムを1つのツールで処理することができるよう
になる。したがって、プログラミング言語に依存しない
形でツールを作ることができる。
As described above, according to the present invention, necessary information is extracted from the syntax analysis tree of the target programming language in response to the request from the tool, and this is converted into a common format independent of the language, and then the above Since it is supplied to the tool, no matter what programming language is used, common format information independent of language is given to the tool, and source programs of multiple programming languages are processed by one tool. You will be able to. Therefore, the tool can be created in a form independent of the programming language.

【0049】また、ツールからの要求に応じて対応する
構文解析木から取り出される情報のみを中間形式に変換
するようにしたので、取り出された情報が構文解析木の
どの部分に対応しているのかを判断することが容易にな
り、ツールにおける処理の結果を元のソースプログラム
に容易に反映させることができるようになる。
Further, since only the information extracted from the corresponding parse tree is converted into the intermediate format in response to the request from the tool, which part of the parse tree corresponds to the extracted information. Can be easily determined, and the result of processing by the tool can be easily reflected in the original source program.

【0050】本発明の他の特徴によれば、複数のプログ
ラミング言語を1つのツールで処理することができ、か
つ、処理しようとするプログラミング言語を動的に選択
することができるようになるので、種々のプログラミン
グ言語から情報を抽出する際の労力を軽減してその情報
抽出を容易にすることができ、例えば、プログラム解析
ツールの開発の作業効率を向上させることができる。
According to another feature of the present invention, a plurality of programming languages can be processed by one tool, and a programming language to be processed can be dynamically selected. The effort for extracting information from various programming languages can be reduced and the information can be easily extracted. For example, the work efficiency of the development of a program analysis tool can be improved.

【0051】また、プログラミング言語に依存しない形
でツールを作ることができるので、ツールには何の変更
も加えなくても済むようになる。これにより、対象とす
るプログラミング言語を追加する場合に、その言語用の
構文解析木アクセス手段を作るだけで対象とするプログ
ラミング言語を追加することができるようになり、プロ
グラミング言語を追加する際の労力を軽減することがで
きる。
Further, since the tool can be created in a form independent of the programming language, it is not necessary to make any changes to the tool. As a result, when adding a target programming language, it becomes possible to add the target programming language simply by creating a parse tree access means for that language, and the effort when adding the programming language. Can be reduced.

【0052】本発明の更に他の特徴によれば、構文解析
木から抽出される情報のうち、プログラミング言語に特
有な情報については中間形式に変換しないようにしたの
で、中間形式への変換の際にプログラミング言語に特有
な部分の情報が失われてしまうという不都合をなくすこ
とができ、元のソースプログラムから必要な情報を確実
に取り出すことができる。
According to another feature of the present invention, among the information extracted from the parse tree, the information peculiar to the programming language is not converted into the intermediate format. In addition, it is possible to eliminate the inconvenience that the information peculiar to the programming language is lost, and it is possible to reliably extract the necessary information from the original source program.

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

【図1】本発明の一実施例である情報抽出装置を適用し
たプログラム解析システムの要部構成を示すブロック図
である。
FIG. 1 is a block diagram showing a main configuration of a program analysis system to which an information extraction device according to an embodiment of the present invention is applied.

【図2】情報抽出手段の具体的な構成を示すブロック図
である。
FIG. 2 is a block diagram showing a specific configuration of information extraction means.

【図3】C言語で記述されたソースプログラムの一例を
示す図である。
FIG. 3 is a diagram showing an example of a source program written in C language.

【図4】FORTRANで記述されたソースプログラム
の一例を示す図である。
FIG. 4 is a diagram showing an example of a source program written in FORTRAN.

【図5】コールグラフの生成結果を示す図である。FIG. 5 is a diagram showing a call graph generation result.

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

1 情報抽出装置 2 第1の言語の構文解析手段 3 第2の言語の構文解析手段 4 第1の言語の構文解析木記憶手段 5 第2の言語の構文解析木記憶手段 6 情報抽出手段 7 第1の言語のプログラム 8 第2の言語のプログラム 9 コールグラフ生成器 10 データフロー解析器 11 第1の言語の構文解析木アクセス手段 11a 構文解析木の移動・検出部 11b 情報の抽出部 11c 構文解析木の変更部 12 選択手段 13 共通形式への変換手段 14 第2の言語の構文解析木アクセス手段 15 選択手段 16 共通形式への変換手段 17 言語切替手段 DESCRIPTION OF SYMBOLS 1 Information extraction device 2 1st language syntactic analysis means 3 2nd language syntactic analysis means 4 1st language syntactic analysis tree storage means 5 2nd language syntactic analysis tree storage means 6 Information extraction means 7th 1 language program 8 2nd language program 9 Call graph generator 10 Data flow analyzer 11 1st language syntax analysis tree access means 11a Movement / detection unit of syntax analysis tree 11b Information extraction unit 11c Syntax analysis Change part of tree 12 Selection means 13 Conversion means to common format 14 Parsing tree access means of second language 15 Selection means 16 Conversion means to common format 17 Language switching means

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 ソースプログラムの構文解析木から情報
を抽出し、所定の処理を施すようにしたツールに、上記
抽出した情報を提供する構文解析木からの情報抽出装置
において、 種々のプログラミング言語で記述されているソースプロ
グラムから構文解析木を作成するために上記各プログラ
ミング言語ごとに設けられた複数の構文解析手段と、 上記複数の構文解析手段からそれぞれ出力される構文解
析木を上記ツールからの要求に応じて調べ、上記ツール
が対象としているプログラミング言語の構文解析木から
情報を抽出するとともに、上記抽出した情報を上記各プ
ログラミング言語に共通する形式に変換して上記ツール
に供給する情報抽出手段とを具備することを特徴とする
構文解析木からの情報抽出装置。
1. An information extraction apparatus for extracting information from a syntax analysis tree of a source program, which provides the extracted information to a tool adapted to perform a predetermined process, in various programming languages. A plurality of parsing means provided for each programming language for creating a parsing tree from the described source program, and a parsing tree output from each of the plurality of parsing means are output from the tool. Information extraction means that checks according to a request, extracts information from a syntax analysis tree of a programming language targeted by the tool, converts the extracted information into a format common to each programming language, and supplies the converted information to the tool. An information extraction device from a syntax parse tree, comprising:
【請求項2】 請求項1記載の構文解析木からの情報抽
出装置において、上記情報抽出手段は、上記複数の構文
解析手段よりそれぞれ出力される構文解析木から情報を
抽出するために上記各プログラミング言語ごとに設けら
れた複数の構文解析木アクセス手段と、 上記複数の構文解析木アクセス手段の中から上記ツール
が対象としているプログラミング言語に対応する構文解
析木アクセス手段を上記ツールからの要求に応じて選択
することにより、対象とする構文解析木アクセス手段を
切り替える言語切替手段と、 上記言語切替手段で選択された構文解析木アクセス手段
により抽出された情報を各プログラミング言語に共通す
る形式に変換する共通形式への変換手段とにより構成さ
れていることを特徴とする構文解析木からの情報抽出装
置。
2. The information extraction device from a syntax analysis tree according to claim 1, wherein the information extraction means extracts each information from the syntax analysis tree output from each of the plurality of syntax analysis means. A plurality of parse tree access means provided for each language and a parse tree access means corresponding to the programming language targeted by the tool from among the plurality of parse tree access means are provided in response to a request from the tool. Language conversion means for switching the target parse tree access means, and the information extracted by the parse tree access means selected by the language switch means is converted into a format common to each programming language. An information extraction device from a syntactic parse tree, which is configured by a conversion means to a common format.
【請求項3】 上記言語切替手段で選択された構文解析
木アクセス手段により抽出された情報を上記各プログラ
ミング言語に共通する形式に変換するか否かを選択する
選択手段を具備することを特徴とする請求項2記載の構
文解析木からの情報抽出装置。
3. A selection means for selecting whether or not to convert the information extracted by the parse tree access means selected by the language switching means into a format common to each programming language. An apparatus for extracting information from a syntax analysis tree according to claim 2.
JP05495294A 1994-03-01 1994-03-01 Information extraction device from parse tree Expired - Lifetime JP3328056B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP05495294A JP3328056B2 (en) 1994-03-01 1994-03-01 Information extraction device from parse tree

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP05495294A JP3328056B2 (en) 1994-03-01 1994-03-01 Information extraction device from parse tree

Publications (2)

Publication Number Publication Date
JPH07239787A true JPH07239787A (en) 1995-09-12
JP3328056B2 JP3328056B2 (en) 2002-09-24

Family

ID=12985013

Family Applications (1)

Application Number Title Priority Date Filing Date
JP05495294A Expired - Lifetime JP3328056B2 (en) 1994-03-01 1994-03-01 Information extraction device from parse tree

Country Status (1)

Country Link
JP (1) JP3328056B2 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009009362A (en) * 2007-06-28 2009-01-15 Hitachi Information Systems Ltd Program variable management system
KR101691600B1 (en) * 2016-04-28 2017-01-02 지티원 주식회사 Program Analysis Method Based on Common Structure Transformation and Apparatus Therefor
JP2020522790A (en) * 2017-05-22 2020-07-30 アビニシオ テクノロジー エルエルシー Automatic dependency analyzer for heterogeneously programmed data processing systems

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009009362A (en) * 2007-06-28 2009-01-15 Hitachi Information Systems Ltd Program variable management system
KR101691600B1 (en) * 2016-04-28 2017-01-02 지티원 주식회사 Program Analysis Method Based on Common Structure Transformation and Apparatus Therefor
JP2020522790A (en) * 2017-05-22 2020-07-30 アビニシオ テクノロジー エルエルシー Automatic dependency analyzer for heterogeneously programmed data processing systems

Also Published As

Publication number Publication date
JP3328056B2 (en) 2002-09-24

Similar Documents

Publication Publication Date Title
CN103077064B (en) A kind of parsing also executive language method and interpreting means
JPH07239787A (en) Extraction device for information from parsing tree
JP2002342078A (en) Program development system and method
JP2501394B2 (en) Procedure call translation device
JPH10289123A (en) Optimization code debugging system
JPH0868831A (en) Method and equipment for testing semiconductor
JPH10207738A (en) Language processing system
KR100747910B1 (en) Apparatus and method for auto generating interface function in agent system
JPH06231181A (en) Distributed database control system
JP3113048B2 (en) Software component synthesizer
CN117421362A (en) Database dynamic switching method, device, equipment and medium
JPH05181652A (en) Program reverse device
KR960024913A (en) Command processing and screen management method of SMX-1
JP2001034482A (en) Compile device, program optimizing device, compile processing method and recording medium
JPH0573335A (en) Automatic in-line development system for program
JPH05225013A (en) Virtual data base system
JPH0561687A (en) Processing system for compiler
JPH0816371A (en) Simulation program generating system
JPH09319619A (en) Pseudo subroutine generator
JPH0223428A (en) Translation type executing system for command type end user language
JPH0250730A (en) Language converting system based upon common machine word
JPH0667865A (en) Device for preparing remote procedure accessing program
KR20020053972A (en) The Apparatus and method of translation from SDL to C
JPH04148335A (en) Object outputting system for language processing program
JPH08263272A (en) Library registration method and device for common routine

Legal Events

Date Code Title Description
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20020604

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080712

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20080712

Year of fee payment: 6

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090712

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20090712

Year of fee payment: 7

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20100712

Year of fee payment: 8

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110712

Year of fee payment: 9

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20110712

Year of fee payment: 9

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120712

Year of fee payment: 10

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20120712

Year of fee payment: 10

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130712

Year of fee payment: 11

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term