JP6022815B2 - Source code difference extraction method and system using parsing - Google Patents
Source code difference extraction method and system using parsing Download PDFInfo
- Publication number
- JP6022815B2 JP6022815B2 JP2012131974A JP2012131974A JP6022815B2 JP 6022815 B2 JP6022815 B2 JP 6022815B2 JP 2012131974 A JP2012131974 A JP 2012131974A JP 2012131974 A JP2012131974 A JP 2012131974A JP 6022815 B2 JP6022815 B2 JP 6022815B2
- Authority
- JP
- Japan
- Prior art keywords
- change
- data
- difference
- source code
- analysis
- 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.)
- Active
Links
Images
Landscapes
- Stored Programmes (AREA)
Description
本発明は、構文解析を用いたソースコードの差分抽出方法およびシステムに関する。 The present invention relates to a source code difference extraction method and system using syntax analysis.
コンピュータを動作させるために、Java(登録商標)、C言語、C++などのプログラミング言語を用いて、人間(場合によってはコンピュータ自身)により記述されるコンピュータプログラム(ソースコード)は、一度記述された後であっても、再度記述が見直され、場合によっては変更されることが少なくない。例えば、当該ソースコードにより動作するアプリケーションやシステムなどの開発段階、またはリリース後などに、機能(仕様)変更が発生したり、バグの発生による修正作業が発生したりする場合があるためである。ソースコードを変更した場合、変更したソースコードの品質を確保するために、変更前後のソースコードを比較し、変更内容が正しくソースコードに反映されているかの確認作業を行う。この確認作業は、ソースコードを変更した開発者自身による自己レビューのみならず、他の開発者や開発者以外の者(例えば、当該ソースコードにより動作するアプリケーションやシステムなどの利用者、すなわち顧客など)による第三者レビューによって実施される。このレビューは、変更内容が正しくソースコードに反映されているか確認するために、変更前後のソースコードを視認して変更箇所を抽出し、これを比較、検討することにより行われる。しかしながら、アプリケーションやシステムの規模によるが、ソースコードが数千、数万行に及ぶ場合や、また変更箇所も数百、数千箇所に及ぶ場合もあるため、変更前後のソースコードから変更箇所を抽出する作業(差分抽出作業)には膨大な工数を要している。また、ソースコードの記述は、類似箇所が多数あったり、同一内容を繰り返し記述していたりする場合などがあり、変更箇所の抽出に一層工数を要したり、場合によっては、変更前後のソースコードの誤った箇所同士を変更前後として対応付けてしまう場合もある。さらに、特に開発者以外の者は、ソースコードを読めない場合が多いいため、ソースコードから差分を抽出し、設計書(例えば詳細設計書など)を修正する作業がさらに必要となる。この際の設計書の修正箇所は、ソースコードの修正箇所にほぼ等しく、またソースコードと設計書の修正箇所の対応付けを誤る場合もある。このように、ソースコードの差分抽出により、工数増大や品質低下の問題が発生している。 In order to operate a computer, a computer program (source code) written by a human (or the computer itself in some cases) using a programming language such as Java (registered trademark), C language, or C ++ is written once. Even so, the description is reviewed again and is often changed in some cases. This is because, for example, a function (specification) change may occur or a correction work may occur due to the occurrence of a bug at the development stage of an application or system that operates with the source code, or after release. When the source code is changed, in order to ensure the quality of the changed source code, the source code before and after the change is compared and a check operation is performed to check whether the changed content is correctly reflected in the source code. This confirmation work includes not only self-review by the developer who changed the source code but also other developers and non-developers (for example, users of applications and systems that operate with the source code, that is, customers, etc.) ) Conducted by a third party review. This review is performed by visually checking the source code before and after the change, extracting the changed part, and comparing and examining it in order to check whether the change is correctly reflected in the source code. However, depending on the size of the application or system, the source code may be in the thousands or tens of thousands of lines, and there may be changes in the hundreds or thousands of places. The extraction work (difference extraction work) requires a huge amount of man-hours. In addition, the source code description may have many similar parts or the same content may be described repeatedly, which may require more man-hours to extract the changed part, and in some cases, the source code before and after the change. In some cases, incorrect locations are associated before and after the change. Furthermore, since a person other than the developer often cannot read the source code, it is necessary to further extract a difference from the source code and correct a design document (for example, a detailed design document). In this case, the correction part of the design document is almost equal to the correction part of the source code, and the correspondence between the source code and the correction part of the design document may be wrong. As described above, the extraction of the source code difference causes problems such as an increase in man-hours and a decrease in quality.
上記問題を解決するために、従来より、多くの差分抽出ツール(またはシステム)が利用されてきた。これらは、変更前後のソースコードの互いの1行づつを比較し、同一行を特定し、特定されなかった行を変更箇所として抽出するものである。差分抽出ツールの一態様では、例えば、GUI(グラフィカルユーザインターフェース)を介して、比較する変更前後のソースコードを選択し、GUI上の左右に変更前後のソースを表示し、変更があった行をハイライト表示したり、削除・追加された行はソースコードの一方を空行で表示するなどし、変更箇所をユーザに示す。別の態様では、結果をファイルに出力するものもある。いずれにせよ、変更前後のソースコードの行の対応付け(例えば変更前後のソースコードを横並びにして同じ高さの行を同一行としたり、変更前後の行番号を示す、など)と、変更内容が示される。 In order to solve the above problems, many difference extraction tools (or systems) have been used conventionally. These compare each line of the source code before and after the change, identify the same line, and extract the unidentified line as a changed part. In one aspect of the difference extraction tool, for example, the source code before and after the change to be compared is selected via a GUI (graphical user interface), the source before and after the change is displayed on the left and right on the GUI, and the line where the change has occurred is displayed. Highlighted lines, deleted / added lines, etc. are displayed as blank lines on one side of the source code, etc., and the changes are shown to the user. In another aspect, the result is output to a file. In any case, the source code lines before and after the change (for example, the source code before and after the change is lined up so that the same height line is the same line, the line number before and after the change is shown), and the change contents Is shown.
しかしながら、従来の差分抽出ツールは、必ずしもユーザにとって十分な情報が示されているとは言えない。例えば、行の一部の変更(例えば、IF文の複数パラメータの1つのパラメータの変更)や単にインデントの上げ下げ(以下、「字上げ」、「字下げ」という)を行った場合であっても、その行に変更があったことしか判断できず、また変更前後の行の対応関係を正確に検知することもできない。すなわち、ユーザは結局、示された情報から、「2行目から7行目が変更行として示されているが、その中の5行は変更後のソースコードでは空行のため、5行が削除され、残りの1行は、変更前のソースコードの6行目と一致するため、6行目だけが2行目として残っている」、または「1行目のIF文が変更箇所として示されているが、1つ目のパラメータ部分は同一で、2つ目のパラメータ部分は異なり、3つ目の・・・」などと、比較、検討を行う必要がある。この作業を変更箇所のほぼ全てに対して行うことになり、場合によっては誤認や見落としが発生する場合もある。このように、従来の差分抽出ツールは、本来解決すべき、ソースコードの差分抽出による工数増大や品質低下の問題を十分に解決できているとは言い難い。 However, it cannot be said that the conventional difference extraction tool necessarily shows sufficient information for the user. For example, even when a part of a line is changed (for example, one parameter of an IF statement is changed) or simply indented (hereinafter referred to as “indentation” or “indentation”). , It can only determine that the line has been changed, and it cannot accurately detect the correspondence between the lines before and after the change. That is, after all, from the information shown, the user says “2nd to 7th lines are shown as changed lines, but 5 lines are blank lines in the changed source code. Deleted and the remaining 1 line matches the 6th line of the source code before the change, so only the 6th line remains as the 2nd line "or" IF statement on the 1st line indicates the changed part However, the first parameter part is the same, the second parameter part is different, and the third parameter part needs to be compared and examined. This operation is performed for almost all of the changed portions, and in some cases, misidentification or oversight may occur. As described above, it is difficult to say that the conventional difference extraction tool can sufficiently solve the problems of man-hour increase and quality degradation due to source code difference extraction.
また、特許文献1に記載の発明など、設計書などドキュメントの保守を目的として、ソースコード(プログラム)中のコメントや制御文を構文解析し、コンピュータによりドキュメントを作成する方法が開示されているが、作成されるドキュメントは修正後のソースコードによるもののみであり、ソースコードの差分抽出をし、変更箇所を明確に示すようなドキュメントを生成するものではない。
In addition, the invention described in
本発明は、このような問題に鑑みてなされたもので、その目的とするところは、構文解析を用いたソースコードの差分抽出方法およびシステムを提供することにある。 The present invention has been made in view of such problems, and an object of the present invention is to provide a source code difference extraction method and system using syntax analysis.
本発明は、このような目的を達成するために、
変更前後のソースコードを構文解析し差分を抽出するコンピュータ装置であって、前記コンピュータ装置は、
変更前後のソースコードに含まれる予約語に基づき構文解析を行い、前記変更前後のソースコードの各々に対して、前記予約語をノードとする抽象構文木データを生成する構文解析手段と、
前記生成した抽象構文木データの木構造データの深さに基づきネスト情報の解析を行い、前記変更前後のソースコードの各々に対して、ネスト構文要素データを生成するネスト情報解析手段と、
前記生成したネスト構文要素データの各々の比較に基づき、差分抽出データを生成する差分抽出手段であって、前記差分抽出データは、前記変更前後のソースコードにおいて変更があったことを示す第1の差分識別子を含む、差分抽出手段と、
少なくとも一致判別ルールと条件追加・削除抽出ルールとに基づき前記生成した差分抽出データを解析し、差分解析データを生成する差分解析手段であって、前記差分解析データは、変更前後の変更がどのような変更かを示す第2の差分識別子、ならびに変更前後の予約語と、非予約語と、ネスト数と、行番号とを変更前後の行単位で対応して有し、前記第2の差分識別子は、前記第1の差分識別子と比較して、少なくとも、変更前後の変更内容が条件文の条件の追加、または削除であることを多く示すことができ、前記差分解析データを生成することは、
前記一致判別ルールに従った解析として、前記生成した差分抽出データのうちの、変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の行として一致するか否かを判定すること
を含む、差分解析手段と
を備えたことを特徴とする。
In order to achieve such an object, the present invention
A computer device that parses the source code before and after the change and extracts a difference, the computer device comprising:
Syntactic analysis based on reserved words included in the source code before and after the change, and for each of the source codes before and after the change, syntax analysis means for generating abstract syntax tree data having the reserved word as a node;
Nest information analysis means for analyzing nest information based on the tree structure data depth of the generated abstract syntax tree data, and generating nested syntax element data for each of the source code before and after the change,
Difference extraction means for generating difference extraction data based on the comparison of each of the generated nested syntax element data , wherein the difference extraction data indicates a change in the source code before and after the change. A difference extraction means including a difference identifier ;
A difference analysis means for analyzing the generated difference extraction data based on at least a match determination rule and a condition addition / deletion extraction rule and generating difference analysis data, wherein the difference analysis data is changed before and after the change. A second difference identifier indicating whether the change is made, a reserved word before and after the change, a non-reserved word, a nest number, and a row number corresponding to each other before and after the change, and the second difference identifier Compared with the first difference identifier, at least, it is possible to indicate that the change content before and after the change is addition or deletion of a condition of a conditional statement, and generating the difference analysis data
As an analysis according to the match determination rule, in the generated difference extraction data, the lines before and after the change are matched according to the degree of matching between the reserved words and the non-reserved words corresponding to the lines before and after the change. Difference analysis means including determining whether or not.
また、前段落に記載の発明における、前記差分解析データを生成することは、
前記条件追加・削除抽出ルールに従った解析として、前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の変更が条件文の条件の追加、または削除であるか否かを判定すること
をさらに含むことを特徴とする。
In the invention described in the preceding paragraph, generating the difference analysis data
As an analysis according to the condition addition / deletion extraction rule, each of the reserved word and the non-reserved word corresponding to the line before and after the change when it is determined as a line before and after the change in the analysis according to the match determination rule The method further includes determining whether or not the change before and after the change is an addition or deletion of a condition in the conditional sentence according to the degree of coincidence between them.
さらに、前段落に記載の発明における、前記差分解析データを生成することは、前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行のネスト数を比較して、字上げまたは字下げが発生しているか否かを判定することをさらに含み、前記第2の差分識別子は、前記第1の差分識別子と比較して、変更前後の変更内容が字上げまたは字下げであることをさらに示すことができることを特徴とする。 Further, in the invention described in the preceding paragraph, the generation of the difference analysis data may be performed by setting the nesting number of the lines before and after the change when it is determined that the lines before and after the change match in the analysis according to the match determination rule. In comparison, it further includes determining whether or not indentation or indentation has occurred, and the second difference identifier is compared with the first difference identifier, and the content of the change before and after the change is character. It is characterized in that it can be further shown to be up or down.
また、前段落に記載の発明における、前記コンピュータ装置は、前記生成した差分解析データと前記生成した変更前のソースコードに対するネスト構文要素データを設計書用文言に変換し、設計書データを生成する設計書生成手段であって、前記設計書データは、変更前後の変更内容を、変更前後の行単位で対応して有する、設計書生成手段をさらに備えたことを特徴とする。 In the invention described in the preceding paragraph, the computer apparatus converts the generated differential analysis data and the generated nested syntax element data for the source code before the change into a design document word, and generates design document data. Design document generation means, characterized in that the design document data further comprises design document generation means having the change contents before and after the change corresponding to each line before and after the change.
さらに、前段落に記載の発明における、前記設計書データは、前記変更前後の変更内容を修飾表示するためのデータと、前記変更前後の変更内容をハイライト表示するためのデータとをさらに有することを特徴とする。 Further, in the invention described in the preceding paragraph, the design document data further includes data for displaying the modified content before and after the modification, and data for highlighting the modified content before and after the change. It is characterized by.
以上説明したように、本発明によれば、変更前後のコンピュータプログラム(ソースコード)に対して構文解析、差分抽出を行い、さらに差分の詳細を解析することにより、変更箇所を明確に示すようなドキュメントを生成することが可能となる。 As described above, according to the present invention, the computer program (source code) before and after the change is subjected to syntax analysis and difference extraction, and the details of the difference are further analyzed to clearly indicate the changed portion. Documents can be generated.
以下、図面を参照しながら本発明の実施形態について詳細に説明する。 Hereinafter, embodiments of the present invention will be described in detail with reference to the drawings.
図1は、本発明の一実施形態に係るコンピュータの構成を示すブロック図である。コンピュータ100は、処理装置101に、システムバス102を介してメモリ103、入力装置104、出力装置105、通信制御装置106および不揮発性記憶媒体(ROMやHDDなど)で構成される記憶装置107が接続された構成を有する。記憶装置107は、差分抽出システム110を格納しており、差分抽出システム110は、各機能を奏するためのソフトウェアプログラムを格納するプログラム格納領域と、随時取得するデータや処理結果としてのデータなどを格納するデータ格納領域とを備えている。以下に説明するプログラム格納領域の各手段は、実際は独立したソフトウェアプログラム、そのルーチンやコンポーネントなどであり、処理装置101によって記憶装置107から呼び出されメモリ103のワークエリアに展開されて、データベースなどを適宜参照しながら順次実行されることで、各機能を奏するものである。
FIG. 1 is a block diagram showing a configuration of a computer according to an embodiment of the present invention. The
プログラム格納領域に格納されているソフトウェアプログラムは、本発明に関連するものだけを列挙すると、構文解析手段111、ネスト情報解析手段112、差分抽出手段113、差分解析手段114、および設計書生成手段115を備えている。 If only software programs related to the present invention are listed in the program storage area, syntax analysis means 111, nest information analysis means 112, difference extraction means 113, difference analysis means 114, and design document generation means 115 are listed. It has.
データ格納領域は、本発明に関連するものだけを列挙すると、ソースコードデータ記憶部121、抽象構文木データ記憶部122、ネスト・構文要素TSVデータ記憶部123、差分抽出データ記憶部124、差分解析データ記憶部125、設計書データ記憶部126、構文解析データ記憶部127、および構文変換データ記憶部128を備える。何れも、記憶装置107内に確保された一定の記憶領域である。
If only data storage areas related to the present invention are listed, a source code
図2は、本発明の一実施形態に係るソースコード差分抽出・解析処理フローを示す図である。本フローは、大きく分けて5つのステップからなる。各ステップの詳細な説明は、図を用いて後述する。ここでは、処理の大まかな流れを説明する。 FIG. 2 is a diagram showing a source code difference extraction / analysis processing flow according to an embodiment of the present invention. This flow is roughly divided into five steps. Detailed description of each step will be described later with reference to the drawings. Here, a rough flow of processing will be described.
まず、ステップ201にて、構文解析手段111が、ソースコードデータ記憶部121に記憶された変更前のソースコード(以下、「旧ソースコード」という)と、変更後のソースコード(以下、「新ソースコード」という)を取得する。続いて、構文解析手段111は、取得した新旧ソースコードの各々に対し、構文解析データ記憶部127に記憶された構文解析データ(ソースコード中の定型語、例えば、IF文の“IF”や“ELSE”などの予約語)に基づき、構文解析を行い、抽象構文木というデータ構造を生成する。抽象構文木は、その詳細は後述するが、予約語をノードとし、各予約語に対応する非予約語(例えばIF文の条件部分)を各々の葉として持つ木構造である。抽象構文木は、新旧ソースコードの各々で生成され、抽象構文木データ記憶部122に記憶される。
First, in step 201, the
次に、ステップ202にて、ネスト情報解析手段112が、生成された新旧ソースコードの抽象構文木を、抽象構文木データ記憶部122から取得し、各予約語についてルートからの深さをカウントすることでネスト情報を解析し、ネスト数を算出する。続いて、ネスト情報解析手段112は、各予約語単位に、対応する非予約語と算出したネスト数を1レコードとし、各レコードをソースコードの行番号順に持ったネスト・構文要素TSV(Tab Separated Values/タブ区切り)データを生成する。ネスト・構文要素TSVは、新旧ソースコードの各々で生成され、ネスト・構文要素TSVデータ記憶部123に記憶される。
Next, in step 202, the nest
次に、ステップ203にて、差分抽出手段113が、生成された新旧ソースコードのネスト・構文要素TSVデータを、ネスト・構文要素TSVデータ記憶部123から取得し、各レコードを比較することで、差分を抽出する。ここでの差分抽出は、従来技術と同等のものであり、新旧ソースコードにおける変更箇所(変更行)を特定するのみである。すなわち、ソースコードの削除、追加、変更を差分として抽出することはできるが、変更についてはどのような変更がされたのか、および行中の全体についての変更なのか、または一部なのかを示すことはできない。抽出された差分データは、差分抽出データ記憶部124に記憶される。
Next, in step 203, the difference extraction means 113 obtains the nest / syntax element TSV data of the generated old and new source code from the nest / syntax element TSV data storage unit 123, and compares the records. Extract the difference. The difference extraction here is equivalent to the prior art, and only specifies the changed part (changed line) in the old and new source code. That is, you can extract source code deletions, additions, and changes as differences, but what changes have been made and whether they are changes or partial changes in the line It is not possible. The extracted difference data is stored in the difference extraction
次に、ステップ204にて、差分解析手段114が、生成された差分抽出データを、差分抽出データ記憶部124から取得し、所定のルールに基づいて、各予約語、および非予約語を比較することで、各変更がどのような変更(行追加・削除、条件の追加・削除、など)なのかを解析する。また、各ネスト数を比較することで、字上げ・字下げによる変更の有無を解析する。解析結果は、差分解析データ記憶部125に記憶される。
Next, in
次に、ステップ205にて、設計書生成手段115が、旧ネスト・構文要素TSVデータをベースに、差分解析データと、構文変換データ記憶部128に記憶された構文変換データ(例えば、予約語と日本語の変換テーブル)とに基づき、設計書を生成する。
Next, in
次に、図3‐13、および18のソースコードやデータ、図14−17のフローチャートを参照して、一実施形態に係るソースコードの差分抽出および解析処理を詳細に説明する。なお、図3‐13、および18のソースコードやデータは、以下の説明において、流れに沿って説明できるよう、一貫性を持たせてある。 Next, the source code difference extraction and analysis processing according to an embodiment will be described in detail with reference to the source code and data of FIGS. 3-13 and 18 and the flowchart of FIGS. 14-17. The source code and data in FIGS. 3-13 and 18 are made consistent so that they can be explained along the flow in the following description.
図3は、本発明の一実施形態に係る旧ソースコードを示す図であり、図4は、本発明の一実施形態に係る新ソースコードを示す図である。301および401はソースコードの行数を表し、302および402にはソースコードを示す。また、図3の旧ソースコードに対し、変更を行ったものが図4の新ソースコードである。より具体的には、図3の旧ソースコードから、「QTY = 0 AND ID != 4」なる条件分岐を削除し、どのような場合であっても「MOVE 'Success' TO RTN-CDE」(旧ソースコードの6行目)を実行するように変更したものが、図4の新ソースコードである。この際、IF文により2文字分ネストされていた旧ソースコード6行目は、2文字分字上げされる。 FIG. 3 is a diagram illustrating an old source code according to an embodiment of the present invention, and FIG. 4 is a diagram illustrating a new source code according to an embodiment of the present invention. 301 and 401 indicate the number of lines of the source code, and 302 and 402 indicate the source code. The new source code shown in FIG. 4 is obtained by changing the old source code shown in FIG. More specifically, the conditional branch “QTY = 0 AND ID! = 4” is deleted from the old source code in FIG. 3 and “MOVE 'Success' TO RTN-CDE” ( The new source code in FIG. 4 is changed to execute the sixth source line of the old source code. At this time, the sixth line of the old source code that is nested by two characters by the IF statement is raised by two characters.
まず、当該新旧ソースコードに対し、従来の差分抽出ツールを用いて差分抽出を行った結果例を図5に示す。501はソースコードの行数を表し、502が旧ソースコード、503が新ソースコードである。504には、新旧ソースコードの各行を対比した結果、どのような変更が行われたかを示している。504を参照すると、旧ソースコードの2行目〜7行目に対し何らかの変更が行われ、新ソースコードの2行目になったことがわかる。しかしながら、図6に示す理想的な差分抽出結果例のように、旧ソースコードの2行目〜5行目、および7行目が削除され、6行目が字上げされたことが示されることが望ましい。
First, FIG. 5 shows an example of a result obtained by extracting a difference between the new and old source codes using a conventional difference extraction tool.
次に、一実施形態に係るソースコードの差分抽出および解析処理のうち、第1ステップ(図2のステップ201)となる新旧ソースコードの構文解析および抽象構文木の生成について説明する。 Next, syntactic analysis of old and new source code and generation of an abstract syntax tree, which are the first step (step 201 in FIG. 2), of the source code difference extraction and analysis processing according to an embodiment will be described.
第1ステップでは、図3および図4に示す新旧ソースコードの各々をインプットとし、構文解析を行い、新旧ソースコード各々の抽象構文木データをアウトプットとして生成する。当該構文解析は、構文解析データ(図示せず。具体的には、ソースコード中の定型語、例えば、IF文の“IF”や“ELSE”などの予約語と、特定のルールを有するデータである。特定のルールとは、例えば、IF文は“IF”から始まり、“IF”の後には“THEN”が続き、場合によって“ELSE”が続く、など予約語におけるルールである。)に基づいて行われる。より具体的には、ソースコードの各行に対し、構文解析データを用いて、各行が何らかの予約語を含む構文なのか、単なるコメントか、などの解析を行い、各行と行間の関係を抽象構文木というデータ構造に変換する。この際、単なるコメントは排除され、ソースコードの実行に関係する予約語および非予約語が変換される。 In the first step, each of the old and new source codes shown in FIGS. 3 and 4 is used as an input, syntax analysis is performed, and abstract syntax tree data of each of the old and new source codes is generated as an output. The parsing is performed by parsing data (not shown. Specifically, it is a fixed word in the source code, for example, a reserved word such as “IF” or “ELSE” in the IF sentence, and data having a specific rule. The specific rule is, for example, a rule in a reserved word such that an IF sentence starts with “IF”, followed by “THEN” followed by “ELSE” in some cases. Done. More specifically, for each line of the source code, the parsing data is used to analyze whether each line includes a reserved word or a simple comment, and the relationship between each line and the abstract syntax tree is analyzed. Convert to the data structure At this time, simple comments are excluded, and reserved words and non-reserved words related to the execution of the source code are converted.
図7は、本発明の一実施形態に係る旧ソースコードの抽象構文木を示す図であり、図8は、本発明の一実施形態に係る新ソースコードの抽象構文木を示す図である。当該抽象構文木は、1つのルート(図7および8では「 / 」で示す。)を基点として、各予約語をノードとし、各予約語に対応する非予約語(例えばIF文の条件部分。図7および8にでは、破線ブロックで示す。)を各々の葉として持つ木構造である。また、各ノードは行番号を持ち、各予約語のノードはネストする度にノードを深くして示される(換言すると、ノードの深さを以って、ネストレベルを表現している)。ここで、非予約語のノードを破線で示しているのは、抽象構文木上で非予約語は予約語の付随的な情報であることを意味するためである。したがって、非予約語のノードは枝分かれして示され、付随する予約語と同一のネストレベルに属していることを示している。 FIG. 7 is a diagram illustrating an abstract syntax tree of an old source code according to an embodiment of the present invention, and FIG. 8 is a diagram illustrating an abstract syntax tree of a new source code according to an embodiment of the present invention. The abstract syntax tree is based on one root (indicated by “/” in FIGS. 7 and 8), and each reserved word is a node, and a non-reserved word (for example, a conditional part of an IF sentence) corresponding to each reserved word. 7 and 8, which are indicated by broken line blocks). Each node has a row number, and each reserved word node is shown deeper each time it is nested (in other words, the nesting level is expressed by the depth of the node). Here, the non-reserved word node is indicated by a broken line because it means that the non-reserved word is ancillary information of the reserved word on the abstract syntax tree. Therefore, nodes of non-reserved words are shown in a branched manner, indicating that they belong to the same nesting level as the associated reserved words.
図7および8に新旧ソースコードの抽象構文木を示したが、これらはあくまでもデータ構造のイメージを示すもので、実際にソースコードから変換(生成)されるデータは、図9および10に示されるものである。図9は、本発明の一実施形態に係る旧ソースコードの抽象構文木データを示す図であり、図10は、本発明の一実施形態に係る新ソースコードの抽象構文木データを示す図である。抽象構文木データ901および1001は予約語毎のレコードであり、ユニークな整数値である「ID」と、従属する予約語のレコードのIDを示す「親ID」と、従属する親IDが同一の場合の他レコードとの関係(順序)を示す「兄弟間の順序」と、「予約語」、「行番号」、予約語に付随する非予約語を示す「非予約語のリスト」とからなる。ここで、抽象構文木データ上、「兄弟間の順序」を持たずに、単に「ID」を連番にして「ID」が若いレコードの方が兄弟間の順序が先である、または「行番号」が若い方が先の順序である、などと判断することもできる。また、「非予約語のリスト」は、予約語に対して付随する非予約語が複数存在する場合は、例えば、カンマなどのデリミタを用いて1つのデータ項目として持つことになるが、非予約語毎に1レコードとすることもできる。この場合、予約語と非予約語がユニークキーになり、さらに非予約語の順序を示すデータを持つことになることは、当業者であれば理解できよう。
FIGS. 7 and 8 show the abstract syntax trees of the old and new source code. These are merely images of the data structure, and the data actually converted (generated) from the source code is shown in FIGS. Is. FIG. 9 is a diagram illustrating abstract syntax tree data of an old source code according to an embodiment of the present invention, and FIG. 10 is a diagram illustrating abstract syntax tree data of a new source code according to an embodiment of the present invention. is there. The abstract
続いて、一実施形態に係るソースコードの差分抽出および解析処理のうち、第2ステップ(図2のステップ202)となる新旧ソースコードのネスト情報の解析およびネスト・構文要素TSVの生成について説明する。 Subsequently, analysis of the nesting information of the old and new source code and generation of the nesting / syntax element TSV, which are the second step (step 202 in FIG. 2), of the source code difference extraction and analysis processing according to the embodiment will be described. .
第2ステップでは、第1ステップで生成した新旧ソースコードの抽象構文木データ901および1001の各々をインプットとし、ネスト情報の解析を行い、新旧ソースコード各々のネスト・構文要素TSVをアウトプットとして生成する。当該ネスト情報の解析は、各予約語についてルートからの深さをカウントする。
In the second step, each of the abstract
図11は、本発明の一実施形態に係る旧ソースコードのネスト・構文要素TSVを示す図であり、図12は、本発明の一実施形態に係る新ソースコードのネスト・構文要素TSVを示す図である。ネスト・構文要素TSV1101および1201は予約語毎のレコードであり、予約語毎に算出したネスト数を示す「ネスト数」と、「予約語」と、予約語に付随する1番目の非予約語を示す「非予約語1」と、予約語に付随する2番目の非予約語を示す「非予約語2」と、「行番号」からなる。ここで、「ネスト数」は、上述の通り、ルートからの深さをカウントすることにより算出されるが、図11および12の例では、ネストした数を示すために、カウント数から1減算した数値を示している。また、図11および12の例では、「非予約語1」および「非予約語2」の2つの非予約語を示しているが、3番目以降の非予約語が必要な場合は、「非予約語3」以降のデータ項目を持つことを理解されたい。また、「非予約語1」および「非予約語2」は、上述した抽象構文木データ901および1001の例のように、デリミタを用いて1つのデータ項目として持つこともできる。さらに図11における予約語「THEN」および「ELSE」のレコードに見られるように、「非予約語1」には、例えば、対応する予約語「IF」のレコードの「非予約語1」の値を持つこともできる。なお、ネスト・構文要素TSV(Tab Separated Values/タブ区切り)は、TSVとしているが、必ずしもタブ区切り形式である必要はない。
FIG. 11 is a diagram illustrating a nesting / syntax element TSV of an old source code according to an embodiment of the present invention, and FIG. 12 illustrates a nesting / syntax element TSV of a new source code according to an embodiment of the present invention. FIG. Nesting / syntax elements TSV1101 and 1201 are records for each reserved word, and the “nesting number” indicating the number of nests calculated for each reserved word, “reserved word”, and the first non-reserved word attached to the reserved word “
続いて、一実施形態に係るソースコードの差分抽出および解析処理のうち、第3ステップ(図2のステップ203)となる新旧ソースコードの差分抽出および差分抽出結果データの生成について説明する。 Subsequently, in the source code difference extraction and analysis processing according to an embodiment, the new and old source code difference extraction and generation of difference extraction result data, which is the third step (step 203 in FIG. 2), will be described.
第3ステップでは、第2ステップで生成した新旧ソースコードのネスト・構文要素TSV1101および1201の各々をインプットとし、差分抽出を行い、差分抽出結果データをアウトプットとして生成する。当該差分抽出は、従来技術と同等のものであり、新旧ソースコードのネスト・構文要素TSVの各レコードを「行番号」順に比較することにより、変更されたレコード(すなわち、新旧ソースコードにおける変更行)を特定する。 In the third step, the new and old source code nested / syntax elements TSV 1101 and 1201 generated in the second step are used as inputs, difference extraction is performed, and difference extraction result data is generated as output. The difference extraction is equivalent to the conventional technique, and the records (ie, changed lines in the old and new source code) are changed by comparing the records of the nested and syntactic elements TSV of the old and new source codes in the order of “line numbers”. ).
図13は、本発明の一実施形態に係る差分抽出結果を示す図である。図13において、差分抽出結果データ1301の1行目(1302)の「2,6c2」は、「旧ソースコードの2〜6行目を、新ソースコードの2行目に変更した。」ことを示す。なお、「c」は、変更を意味する「change」の頭文字であるが、別の識別子を用いてもよい。また、「c」の他に、追加を意味する「add」の頭文字の「a」、削除を意味する「delete」の頭文字の「d」を用いて、行の追加や削除を示すことができる。例えば、「(旧ソースコードの0行目の位置に)新ソースコードの1〜3行目を追加した。」ことを示すために「0a1,3」、または「旧ソースコードの2〜5行目を削除した(削除部分は、新ソースコードでは、1行目となる)。」ことを示すために「2,5d1」などと示すことができる。また、ソースコードの2〜5行目を意味する「2,5」は、「2-5」などと表記することもできる。
FIG. 13 is a diagram illustrating a difference extraction result according to an embodiment of the present invention. In FIG. 13, “2,6c2” in the first line (1302) of the difference
次に、図13における差分抽出結果データ1301の2〜6行目(1303)は、左矢印を意味する「<」識別子を持つ旧内容部分であり、8行目(1305)は、右矢印を意味する「>」識別子を持つ新内容部分である。すなわち、「<」および「>」識別子は、「旧ソースコード→新ソースコード」への変更を意味するものであるが、別の表現を用いることもできる。また、7行目(1304)の「---」は新旧ソースコードの区切りを意味するものであるが、同様に別の表記を用いることもできる。なお、「<」および「>」識別子の隣の数値は、各レコードのネスト数を表す。
Next, the second to sixth lines (1303) of the difference
さらに変更、追加、削除がある場合は、1306に示すように追加して示すことができる。また、差分抽出結果データ1301を、図5に示すように新旧ソースコードの行を対応付けて生成することもできる。いずれにせよ、図13における差分抽出は、従来技術と同等のものであるため、行変更の場合は、旧ソースコードのある行に対して何らかの変更が行われ、新ソースコードのある行に変更された、ことしか示さない。そのため、次ステップにて、本ステップで生成した差分抽出結果データ1301をさらに解析する。
Further, when there is a change, addition, or deletion, it can be additionally shown as shown in 1306. Further, the difference
続いて、一実施形態に係るソースコードの差分抽出および解析処理のうち、第4ステップ(図2のステップ204)となる差分抽出結果データ1301の解析および差分解析結果データ1801の生成について説明する。
Subsequently, analysis of difference
第4ステップでは、第3ステップで生成した差分抽出結果データ1301をインプットとし、さらに解析を行い、後述する差分解析結果データ1801をアウトプットとして生成する。差分抽出結果データ1301の解析は、差分抽出結果データ1301における旧内容部分1303および新内容部分1305の各行における予約語および非予約語を、後述する一致判別ルール、および条件追加・削除抽出ルールに基づいて、比較し、差分として抽出された各行の変更がどのような変更(行追加・削除、条件の追加・削除、など)なのかを解析する。また、各ネスト数を比較することで、字上げ・字下げによる変更の有無を解析する。
In the fourth step, the difference
図14は、本発明の一実施形態に係る差分解析処理フローを示す図である。図14に係る処理フローが、第4ステップの詳細フローになる。 FIG. 14 is a diagram showing a difference analysis processing flow according to an embodiment of the present invention. The processing flow according to FIG. 14 is the detailed flow of the fourth step.
ステップ1401にて、差分抽出結果データ1301から1ブロック分のデータ(例えば図13の1306。以下、「差分ブロックデータ」という)を取得する。ここで差分ブロックデータが取得できない場合、すなわちファイルの終端である場合は、ステップ1402の「Yes」に進み、処理は終了する。差分ブロックデータが取得できた場合は、ステップ1402の「No」に進み、差分ブロックデータに含まれる差分識別子が「変更」(例えば「c」)を示すか判定が行われる(ステップ1403)。差分識別子が「変更」以外(例えば、「追加」を示す「a」または「削除」を示す「d」)であれば、これ以上の解析は不要であるため、取得した差分ブロックデータをそのまま差分解析結果として出力する(ステップ1404)。ステップ1404にて差分ブロックデータを出力した後、ステップ1401に戻り、次の変更の解析を行うか(ステップ1402の「No」ルート)、次の変更が無い場合は処理が終了する(ステップ1402の「Yes」ルート)。
In step 1401, data for one block (for example, 1306 in FIG. 13; hereinafter referred to as “difference block data”) is acquired from the difference
ステップ1403にて、差分識別子が「変更」を示す場合、差分ブロックデータに含まれる新内容部分から1行取得する(ステップ1405)。ここで新内容部分が複数行ある場合は、上から取得し、処理を繰り返す際に次の行を取得する。ステップ1405にて、行が取得できない場合、すなわち新内容部分の終端である場合は、ステップ1406の「Yes」に進み、ステップ1401に戻る。
If the difference identifier indicates “change” in
一方、行が取得でき、新内容部分の終端ではない場合、ステップ1406の「No」に進み、差分ブロックデータの旧内容部分から1行取得する(ステップ1407)。ここでも、旧内容部分が複数行ある場合は、上から取得し、処理を繰り返す際に次の行を取得する。ステップ1407にて、行が取得でき、旧内容部分の終端ではない場合、ステップ1408の「No」に進み、一致判別ルールに従って、新旧内容部分の1行がお互いに一致するか否かを比較する(ステップ1409)。ステップ1409、すなわち一致判別ルールに従った判定処理の詳細については、図15の説明として後述する。
On the other hand, if a row can be acquired and it is not the end of the new content portion, the process proceeds to “No” in
ステップ1409にて、取得した新旧内容部分の各1行が変更について対応する行として一致しないと判定された場合、新旧内容部分の1行を旧内容部分の次の行と比較するため、ステップ1410の「No」に進み、ステップ1407に戻る。一方、対応する行として一致すると判定された場合、ステップ1410の「Yes」に進み、条件追加・削除抽出ルールに従って差分解析結果を出力する(ステップ1411)。ステップ1411、すなわち条件追加・削除抽出ルールに従った解析処理の詳細については、図16の説明として後述する。
If it is determined in step 1409 that each line of the acquired old and new content part does not match as a corresponding line for the change, step 1410 is performed to compare one line of the old and new content part with the next line of the old content part. The process proceeds to “No” and returns to step 1407. On the other hand, if it is determined that the lines match, the process proceeds to “Yes” in step 1410, and the difference analysis result is output according to the condition addition / deletion extraction rule (step 1411). Details of the analysis processing according to
次にステップ1411にて出力した差分解析結果が「変更候補に追加」か否か判定する(ステップ1412)。「変更候補に追加」というのは、後述するが、変更の可能性が高いが、変更であることを未だ確定できないものを一時的に変更候補(リスト)に追加し、新内容部分の1行と旧内容部分の次の行との比較をさらに行うことが必要であることを意味する。そのため、ステップ1412にて、出力した差分解析結果が「変更候補に追加」であると判定された場合、「Yes」に進み、変更候補リストに変更候補を追加し(ステップ1417)、ステップ1407に戻る。ここで、変更候補リスト(図示せず)は、コンピュータ100上のメモリ103に展開される一時的なデータ領域であり、例えばリスト構造で、変更候補であると判定された、取得した新内容部分の1行を格納する。
Next, it is determined whether or not the difference analysis result output in
一方、ステップ1412にて、出力した差分解析結果が「変更候補に追加」ではないと判定された場合、「No」に進み、字上げ・字下げ抽出ルールに従って、差分解析結果を出力する(ステップ1413)。ステップ1413、すなわち字上げ・字下げ抽出ルールに従った解析処理の詳細については、図17の説明として後述する。
On the other hand, if it is determined in
次に、旧内容部分1302に、差分解析結果として出力していない行が存在するか否かを判定する(ステップ1414)。差分解析結果として出力していない行が存在しない場合は、ステップ1416に進み、未出力行が存在する場合は、当該未出力行を削除行と判断して差分解析結果を出力する(ステップ1415)。続いて、ステップ1416にて、変更候補リストを空にして(初期化して)、ステップ1405に戻り、新内容部分の次の行の解析を行う。
Next, it is determined whether or not there is a line not output as a difference analysis result in the old content portion 1302 (step 1414). If there is no line that has not been output as the difference analysis result, the process proceeds to step 1416. If there is an unoutput line, the non-output line is determined to be a deleted line and the difference analysis result is output (step 1415). . Subsequently, in
一方、ステップ1407にて、旧内容部分から行が取得できず、旧内容部分の終端である場合、ステップ1408の「Yes」に進み、変更候補リストが空か否かの判定を行う(ステップ1418)。ステップ1418にて、変更候補リストが空でない場合、「No」に進み、変更候補リストの1つ目(例えば、ステップ1417にて格納された、新内容部分の1行)を「変更」と判断して差分解析結果を出力し(ステップ1419)、ステップ1416に進む。ステップ1419において、変更候補リストの1つ目を「変更」と判断するのは、最も先に格納されたものが最も変更行である可能性の高いものとみなすためである。また、ステップ1419をはじめとする差分解析処理フローのいくつかのステップにおいて出力される差分解析結果は、図18の説明にて後述するが、例えば、「変更」と判断された新旧内容部分の行および行番号、ならびにどのような変更かを示す差分識別子である。ここで差分識別子とは、例えば、差分抽出結果データ1301の識別子のように、変更を意味する「change」の頭文字である「c」、追加を意味する「add」の頭文字の「a」、削除を意味する「delete」の頭文字の「d」、条件文の条件の追加を意味する「condition add」の頭文字の「ca」、および条件文の条件の削除を意味する「condition delete」の頭文字の「cd」などである。ステップ1419では「変更」と判断されたたため、「c」を出力する。但し、別の識別子を用いてもよい。結果として、ステップ1419にて出力される差分解析結果とは、例えば、図13に示される差分抽出結果データ1301と同形式で出力することができる。別の実施形態では、図6および7に示されるように、新旧内容部分を横並びにし、変更行を対比できるように出力することもできる。
On the other hand, if it is determined in
一方、変更候補リストが空の場合、「Yes」に進み、取得した新内容部分の1行を「追加」と判断して差分解析結果を出力し(ステップ1420)、ステップ1405に戻り、新内容部分の次の行の解析を行う。ステップ1420において出力される差分解析結果は、ステップ1419にて上述したものと同様である。
On the other hand, if the change candidate list is empty, the process proceeds to “Yes”, one line of the acquired new content part is determined as “added”, and the difference analysis result is output (step 1420). Parse the next line of the part. The difference analysis result output in step 1420 is the same as that described above in
以上の処理を、差分抽出結果データ1301のファイルの終端まで行い、後述する差分解析結果データ1801を得る。以上、差分解析処理の詳細について説明したが、ステップ1413に示す字上げ・字下げに係る差分解析など、処理の一部は、必ずしも図14に示す差分解析処理フローの中で実施する必要は無く、別処理として分離して実行することができることを当業者であれば理解できよう。
The above processing is performed up to the end of the file of the difference
次に、ステップ1409、すなわち一致判別ルールに従った判定処理の詳細について説明する。図15は、本発明の一実施形態に係る一致判別ルールに従った判定処理フローを示す図である。ステップ1501にて、取得した新旧内容部分の各1行の予約語が一致するか否かを判定する。ステップ1501にて、一致しないと判定された場合、「No」に進み、取得した新旧内容部分の各1行は変更について対応する行として不一致であると判定され(ステップ1510)、処理は終了する。
Next, details of determination processing according to step 1409, that is, the matching determination rule will be described. FIG. 15 is a diagram showing a determination processing flow according to the match determination rule according to the embodiment of the present invention. In
一方、ステップ1501にて、一致すると判定された場合、一致する予約語が「IF」であるか否か判定する(ステップ1502)。ステップ1502にて、一致する予約語が「IF」であると判定された場合、「Yes」に進み、当該予約語に対応する非予約語の全てが、取得した新旧内容部分において一致するか否かを判定する(ステップ1503)。ステップ1503にて、一致すると判定された場合、「Yes」に進み、取得した新旧内容部分の各1行は変更について対応する行として一致すると判定され(ステップ1504)、処理は終了する。
On the other hand, if it is determined in
一方、ステップ1503にて、一致しないと判定された場合、「No」に進み、対応する非予約語の一方が他方の部分集合となるか否かを判定する(ステップ1505)。ステップ1505にて、部分集合となると判定された場合、「Yes」に進み、取得した新旧内容部分の各1行は変更について対応する行として一致すると判定され(ステップ1504)、処理は終了する。ここで、部分集合とは例えば、非予約語について、旧内容部分が「QTY = 0 AND ID ! = 4」であり、新内容部分が「QTY = 0 AND ID ! = 4 AND ID ! = 5」である場合に、旧内容部分は新内容部分の部分集合であるといえる。
On the other hand, if it is determined in
一方、ステップ1505にて、部分集合とはならないと判定された場合、「No」に進み、取得した新旧内容部分の各1行は変更について対応する行として不一致であると判定され(ステップ1506)、処理は終了する。
On the other hand, if it is determined in
ステップ1502にて、一致する予約語が「IF」ではないと判定された場合、「No」に進み、当該予約語に対応する非予約語が全て一致するか否かを判定する(ステップ1507)。ステップ1507にて、一致すると判定された場合、「Yes」に進み、取得した新旧内容部分の各1行は変更について対応する行として一致すると判定され(ステップ1508)、処理は終了する。
If it is determined in
一方、ステップ1507にて、一致しないと判定された場合、「No」に進み、対応する予約語に異なるものが2つ以上あるか否かの判定を行う(ステップ1509)。ステップ1509にて、異なるものが2つ以上あると判定された場合、「Yes」に進み、取得した新旧内容部分の各1行は変更について対応する行として不一致であると判定され(ステップ1510)、処理は終了する。一方、ステップ1509にて、異なるものが2つ以上ないと判定された場合、「No」に進み、取得した新旧内容部分の各1行は変更について対応する行として一致すると判定され(ステップ1508)、処理は終了する。
On the other hand, if it is determined in step 1507 that they do not match, the process proceeds to “No”, and it is determined whether there are two or more different corresponding reserved words (step 1509). If it is determined in
次に、図14のステップ1411、すなわち条件追加・削除抽出ルールに従った解析処理の詳細について説明する。図16は、本発明の一実施形態に係る条件追加・削除抽出ルールに従った解析処理フローを示す図である。ステップ1601にて、取得した新旧内容部分の各1行の予約語が「IF」であるか否か判定する。ステップ1601にて、一致する予約語が「IF」であると判定された場合、「Yes」に進み、当該予約語に対応する非予約語の全てが、取得した新旧内容部分において一致するか否かを判定する(ステップ1602)。ステップ1602にて、一致すると判定された場合、「Yes」に進み、処理は終了する。
Next,
一方、ステップ1602にて、一致しないと判定された場合、「No」に進み、対応する非予約語の一方が他方の部分集合となるか否かを判定する(ステップ1603)。ステップ1603にて、部分集合とはならないと判定された場合、「No」に進み、処理は終了する。
On the other hand, if it is determined in
一方、ステップ1603にて、部分集合となると判定された場合、「Yes」に進み、取得した旧内容部分の1行が、取得した新内容部分の1行の部分集合であるか否かの判定を行う(ステップ1604)。ステップ1604にて、部分集合であると判定された場合、「Yes」に進み、取得した新内容部分の1行を「条件の追加」と判断して差分解析結果を出力する(ステップ1605)。ステップ1605において出力される差分解析結果は、例えば、条件文の条件の追加を意味する「condition add」の頭文字の「ca」である。
On the other hand, if it is determined in
一方、ステップ1604にて、部分集合でないと判定された場合、「No」に進み、差分解析結果として、取得した新内容部分の1行を「条件の削除」と判断して差分解析結果を出力する(ステップ1606)。ステップ1606において出力される差分解析結果は、例えば、条件文の条件の削除を意味する「condition delete」の頭文字の「cd」である。 On the other hand, if it is determined in step 1604 that it is not a subset, the process proceeds to “No”, and as the difference analysis result, one line of the acquired new content portion is determined as “deletion of condition” and the difference analysis result is output. (Step 1606). The difference analysis result output in step 1606 is, for example, “cd” as an acronym for “condition delete”, which means deletion of a condition sentence.
ステップ1601にて、一致する予約語が「IF」でないと判定された場合、「No」に進み、対応する非予約語に異なるものが2つ以上あるか否かを判定する(ステップ1607)。ステップ1607にて、異なるものが2つ以上あると判定された場合、「Yes」に進み、処理は終了する。一方、異なるものが2つ以上ないと判定された場合、「No」に進み、差分解析結果として、「変更候補に追加」と判定する(ステップ1609)。
When it is determined in step 1601 that the matching reserved word is not “IF”, the process proceeds to “No”, and it is determined whether or not there are two or more different corresponding non-reserved words (step 1607). If it is determined in
次に、図14のステップ1413、すなわち字上げ・字下げ抽出ルールに従った解析処理の詳細について説明する。図17は、本発明の一実施形態に係る字上げ・字下げ抽出ルールに従った解析処理フローを示す図である。ステップ1701にて、取得した旧内容部分の1行のネスト数が、取得した新内容部分の1行のネスト数より大きいか否かを判定する。ステップ1701にて、旧内容部分の1行のネスト数の方が大きいと判定された場合、「Yes」に進み、取得した新内容部分の1行を「字上げ」と判断して差分解析結果を出力する(ステップ1702)。ステップ1702において出力される差分解析結果は、図18の説明にて後述するが、例えば、「字上げ」と判断された新旧内容部分の行および行番号、ならびに何文字分の字上げかを示す字上げ・字下げ識別子である。ここで、字上げ・字下げ識別子とは、例えば、2文字の字上げであれば「+2」、または1文字の字下げであれば「-1」などを出力する。但し、別の識別子を用いてもよい。 Next, details of the analysis processing according to step 1413 in FIG. 14, that is, the indentation / indentation extraction rule will be described. FIG. 17 is a diagram showing an analysis processing flow according to the indentation / indentation extraction rule according to the embodiment of the present invention. In step 1701, it is determined whether or not the number of nested lines in the acquired old content portion is larger than the number of nested lines in the acquired new content portion. If it is determined in step 1701 that the number of nestings in one line of the old content portion is larger, the process proceeds to “Yes”, and one line of the acquired new content portion is determined as “indentation” and the difference analysis result Is output (step 1702). The difference analysis result output in step 1702 will be described later with reference to FIG. 18. For example, it indicates the line and line number of the old and new content portion determined to be “indent”, and how many characters are to be indented. Indentation / indentation identifier. Here, as the indentation / indentation identifier, for example, “+2” is output if the character is indented by two characters, or “−1” is output if the indentation is one character. However, another identifier may be used.
一方、ステップ1701にて、旧内容部分の1行のネスト数の方が大きくない(等しい場合も含む)と判定された場合、「No」に進み、取得した旧内容部分の1行のネスト数が、取得した新内容部分の1行のネスト数より小さいか否かを判定する(ステップ1703)。ステップ1703にて、旧内容部分の1行のネスト数の方が小さいと判定された場合、「Yes」に進み、取得した新内容部分の1行を「字下げ」と判断して差分解析結果を出力する(ステップ1704)。ステップ1704において出力される差分解析結果は、ステップ1702にて上述したものと同様である。一方、ステップ1703にて、旧内容部分の1行のネスト数の方が小さくない、すなわち新旧内容部分の各1行のネスト数は等しいと判定された場合、ネスト数の変更は発生していないため、何も出力せず、処理は終了する。
On the other hand, if it is determined in step 1701 that the number of nested lines in the old content portion is not larger (including the case where they are equal), the process proceeds to “No” and the number of nested lines in the acquired old content portion Is smaller than the number of nestings in one line of the acquired new content portion (step 1703). If it is determined in
以上の処理により、次に示す差分解析結果データ1801を得る。図18は、本発明の一実施形態に係る差分解析結果を示す図である。図18において、差分抽出結果データ1801の1行目(1802)の「2,5d」は、「旧ソースコードの2〜5行目を削除した。」ことを示す。「d」は、削除を意味する「delete」の頭文字である識別子であるが、差分解析結果データ1801において出力される識別子は、図14のステップ1419にて上述した差分識別子、およびステップ1702にて上述した字上げ・字下げである。図18における差分解析結果データ1801は、図13における差分抽出結果データ1301と同様の形式であり、より詳細な変更情報を示すことができる改良データである。そのため、「<」および「>」識別子、1807の「---」は、図13にて上述したものと同様であり、1803および1806は旧内容部分を、ならびに1808は新内容部分を、それぞれ示す。
Through the above processing, the following difference
また、より詳細な変更情報とは、条件文の条件の追加である場合、例えば、「1ca1」(「旧ソースコードの1行目の条件文の条件を追加した。」ことを示す)と、条件文の条件の追加に係る新旧内容部分を出力する。また「旧ソースコードの1行目の条件文の条件を削除し、新ソースコードの4行目として出力した。」場合、「1cd4」と、条件文の条件の追加に係る新旧内容部分を出力する。なお、この場合、新ソースコードに、1〜3行目が追加されたこともわかる。もっとも、この場合、追加された1〜3行目が「0a1,3」として出力されるであろう。 Further, when the more detailed change information is the addition of a conditional statement condition, for example, “1ca1” (indicating that “the conditional statement condition of the first line of the old source code has been added”), Output the old and new contents related to the addition of conditions in the conditional statement. Also, if “Delete the condition of the conditional statement in the first line of the old source code and output it as the fourth line of the new source code”, output “1cd4” and the old and new contents part related to the addition of the conditional statement condition. To do. In this case, it can also be seen that the first to third lines are added to the new source code. However, in this case, the added first to third lines will be output as “0a1,3”.
また、さらなる、より詳細な変更情報とは、例えば、1805〜1808として示される字上げ・字下げの変更情報である。1805の「6 -2 2」は、「旧ソースコードの6行目が、2文字分、字下げされ、新ソースコードの2行目として出力した。」ことを示す。新ソースコードの2行目として出力されるのは、1802〜1803に示されるように、旧ソースコードの2〜5行目が削除されたためである。さらに変更がある場合は、差分解析結果データ1801に行を追加して示されることは当業者であれば理解されたい。また、差分解析結果データ1801を、図6に示すように新旧ソースコードの行を対応付けて生成することもできる。
Further, the more detailed change information is, for example, inflection / indentation change information indicated as 1805 to 1808. “6-22” in 1805 indicates that “the sixth line of the old source code is indented by two characters and output as the second line of the new source code”. The reason why it is output as the second line of the new source code is that the second to fifth lines of the old source code have been deleted, as shown in 1802-1803. It should be understood by those skilled in the art that when there is a further change, the difference
続いて、一実施形態に係るソースコードの差分抽出および解析処理のうち、第5ステップ(図2のステップ205)となる設計書の生成について説明する。
Next, generation of a design document, which is the fifth step (
図19は、本発明の一実施形態に係る設計書生成処理フローを示す図であり、図20は、本発明の一実施形態に係る予約語−日本語変換テーブルを示す図であり、図21は、本発明の一実施形態に係る設計書生成結果を示す図である。図19に係る処理フローが、第5ステップの詳細フローになる。本フローは、旧ネスト・構文要素TSVデータ1101をベースに、差分解析結果データ1801と、予約語−日本語変換テーブル2001とに基づき、図21に示すように設計書を生成する。なお、図21の本文出力部2101は、変換した結果の設計書本文、変更区分出力部2102には変更内容の詳細を出力する。
19 is a diagram showing a design document generation process flow according to an embodiment of the present invention, and FIG. 20 is a diagram showing a reserved word-Japanese conversion table according to an embodiment of the present invention. These are figures which show the design document production | generation result which concerns on one Embodiment of this invention. The processing flow according to FIG. 19 is a detailed flow of the fifth step. This flow generates a design document as shown in FIG. 21 based on the difference
ステップ1901にて、旧ネスト・構文要素TSVデータ1101から1行取得する。ここで行が取得できる場合、すなわちファイルの終端でない場合は、ステップ1902の「No」に進み、取得した旧ネスト・構文要素TSVデータ1101の1行を予約語−日本語変換テーブル2001に基づき、変換し、設計書データとして出力する(ステップ1903)。
In
ここで、予約語−日本語変換テーブル2001は、「予約語」と、「非予約語のリスト」と、「設計書への出力内容」とからなる。ここで、「設計書への出力内容」は、実際に設計書本文として、本文出力部2101に出力する内容であり、「%」で囲まれた文言は非予約語を示し、取得した旧ネスト・構文要素TSVデータ1101の1行に含まれる非予約語に応じて置換される。例えば、予約語「READ」について、差分解析結果データでは「READ Q-FILE.」となっており、「Q-FILE」が非予約語のFILE(ファイル名)を示す。この場合、「設計書への出力内容」に示される「%FILE%を読み込む」の「%FILE%」部分が「Q-FILE」に置換され、図21に示すように、「Q-FILEを読み込む」と出力される。
Here, the reserved word-Japanese conversion table 2001 includes “reserved words”, “a list of non-reserved words”, and “contents to be output to the design document”. Here, “output content to design document” is the content that is actually output to the
また、別の予約語を説明すると、例えば、予約語「IF」の場合、非予約語(すなわち条件)の数により、「%EXPR1%」、「%EXPR2%」、「%EXPR3%」・・・と置換する非予約語の数が異なり、各非予約語を結ぶ条件(AND、OR)により、「設計書への出力内容」に示す“かつ”または“または”の文字列が選択され、出力される。 Further, another reserved word is explained. For example, in the case of the reserved word “IF”, “% EXPR1%”, “% EXPR2%”, “% EXPR3%”, etc. depending on the number of non-reserved words (that is, conditions). The number of non-reserved words to be replaced is different, and the character string "and" or "or" shown in "Output contents to design document" is selected according to the conditions (AND, OR) connecting each non-reserved word, Is output.
ステップ1903の後、ステップ1901に戻り、旧ネスト・構文要素TSVデータ1101から行が取得できなくなるまで、ステップ1901〜1903を繰り返す。これは、旧ネスト・構文要素TSVデータ1101に基づき、予め旧内容部分を設計書データとして出力する考えである。別の実施形態では、予め旧内容部分を出力せずに、設計書データを生成することもできる。
After step 1903, the process returns to step 1901, and
旧ネスト・構文要素TSVデータ1101から行が取得できない場合、すなわちファイルの終端である場合は、ステップ1902の「Yes」に進み、差分解析結果データ1801から、差分識別子を含む行(例えば1802)から区切り行まで取得する。ここで、区切り行とは、例えば、空行1804であり、これら取得した複数行を「一差分データ」という。一差分データは、例えば、差分解析結果データ1801における1802〜1804である。また、別の一差分データは、1805〜1808である。図18の例では、2つの一差分データが含まれる。
If a line cannot be acquired from the old nest / syntax
ステップ1904にて行が取得できない場合、すなわちファイルの終端である場合は、ステップ1905の「Yes」に進み、処理は終了する。行が取得できた場合は、ステップ1905の「No」に進み、一差分データに含まれる差分識別子(例えば、1802および1805)が「追加」を示すか判定する(ステップ1906)。差分識別子が「追加」を示すと判定される場合(例えば「0a1,6」)、「Yes」に進み、取得した差分解析結果の新内容部分を予約語−日本語変換テーブルに基づいて変換し出力し(ステップ1907)、ステップ1904に戻る。この際、図21に示すように、変更区分出力部2102に、例えば「追加」という文字列を出力する。また、より強調するために、図21に示すように、項番を網掛けする、項番のフォント色を変更するなどによりハイライト表示することもできる。
If the line cannot be acquired in
ステップ1906にて、差分識別子が「追加」を示さないと判定される場合、「No」に進み、差分識別子が「変更」を示すか判定する(ステップ1908)。差分識別子が「変更」を示すと判定される場合(例えば「8c8」)、「Yes」に進み、取得した差分解析結果の新内容部分を予約語−日本語変換テーブルに基づいて変換し出力し(ステップ1907)、さらに設計書に出力した該当行(旧内容部分において変更する行)を削除用の表記に変換し(ステップ1911)、ステップ1904に戻る。この際、図21に示すように、本文出力部2101には、旧内容を取り消し線により修飾して出力し、そのすぐ下に、新内容を出力する。また、変更区分出力部2102には、例えば「変更」という文字列を出力する。さらに、より強調するために、図21に示すように、旧内容部分と新内容部分を異なる色で網掛けする、フォント色を変更するなどによりハイライト表示することもできる。
If it is determined in step 1906 that the difference identifier does not indicate “add”, the process proceeds to “No”, and it is determined whether the difference identifier indicates “change” (step 1908). When it is determined that the difference identifier indicates “change” (for example, “8c8”), the process proceeds to “Yes”, and the new content part of the obtained difference analysis result is converted and output based on the reserved word-Japanese conversion table. (Step 1907) Further, the corresponding line output to the design document (the line to be changed in the old content part) is converted into a notation for deletion (Step 1911), and the process returns to Step 1904. At this time, as shown in FIG. 21, to the
ステップ1908にて、差分識別子が「変更」を示さないと判定される場合、「No」に進み、差分識別子が「削除」を示すか判定する(ステップ1910)。差分識別子が「削除」を示すと判定される場合(例えば「1,10d1」)、「Yes」に進み、設計書に出力した該当行(旧内容部分において削除する行)を削除用の表記に変換し(ステップ1911)、ステップ1904に戻る。この際、図21に示すように、本文出力部2101には、取り消し線により修飾されて出力される。ここで取り消し線以外の修飾(例えば、薄い文字)により、出力することができることも当業者であれば理解されたい。また、変更区分出力部2102には、例えば「削除」という文字列を出力する。また、より強調するために、図21に示すように、網掛けするなどによりハイライト表示することもできる。
If it is determined in
ステップ1910にて、差分識別子が「削除」を示さないと判定される場合、「No」に進み、差分識別子が「条件の追加」を示すか判定する(ステップ1912)。差分識別子が「条件の追加」を示すと判定される場合(例えば「12ca12」)、「Yes」に進み、取得した差分解析結果の新内容部分を予約語−日本語変換テーブルに基づいて、設計書に出力した該当部分(旧内容部分の条件文において条件を追加する部分)に追加し(ステップ1913)、ステップ1904に戻る。この際、図21に示すように、本文出力部2101には、追加する部分を、網掛けする、フォント色を変更するなどして出力する。また、変更区分出力部2102には、例えば「条件の追加」という文字列を出力する。
If it is determined in
ステップ1912にて、差分識別子が「条件の追加」を示さないと判定される場合、「No」に進み、差分識別子が「条件の削除」を示すか判定する(ステップ1914)。差分識別子が「条件の削除」を示すと判定される場合(例えば「14cd14」)、「Yes」に進み、設計書に出力した該当部分(旧内容部分の条件文において条件を削除する部分)を削除用の表記に変換し(ステップ1915)、ステップ1904に戻る。この際、図示していないが、本文出力部2101には、削除する部分を取り消し線により修飾するなどして出力し、また変更区分出力部2102には、例えば「条件の削除」という文字列を出力する。
If it is determined in
ステップ1914にて、差分識別子が「条件の削除」を示さないと判定される場合、「No」に進み、差分識別子が「字上げ」または「字下げ」を示すか判定する(ステップ1916)。差分識別子が「字上げ」または「字下げ」を示すと判定される場合(例えば「16 +1 16」、または「16 -2 16」)、「Yes」に進み、設計書に出力した該当行(旧内容部分において字上げ、または字下げする行)を、差分識別子で示される文字数分、字上げ、または字下げし(ステップ1917)、ステップ1904に戻る。この際、図21に示すように、変更区分出力部2102に、例えば「2文字字下げ」という文字列を出力する。また、より強調するために、図21に示すように、項番を網掛けする、項番のフォント色を変更するなどによりハイライト表示することもできる。なお、図21に示される「11.」などの項番は、出力した設計書の可読性を向上させるため、ネスト数に応じて、連番を付与したものであるため、必ずしも出力する必要はない、または別の表記で出力することができることを理解されたい。
If it is determined in
ステップ1916にて、差分識別子が「字上げ」または「字下げ」を示さないと判定される場合、「No」に進み、ステップ1904に戻る。もっともこの場合、差分識別子が想定された差分識別子を示さないことになるため、本ルートは、例外ルートであるといえる。そのため、本ルートに例外処理を入れることもできる。
If it is determined in
なお、ステップ1906〜1916において、差分識別子の判定処理について上述したが、この際の判定する順番は一実施例であり、判定の順番を任意に変更して処理することができることは当業者であれば理解されたい。 Note that, in steps 1906 to 1916, the difference identifier determination processing has been described above, but the determination order in this case is an example, and it is a person skilled in the art that the determination order can be arbitrarily changed and processed. Please understand.
100 コンピュータ
101 処理装置
102 システムバス
103 メモリ
104 入力装置
105 出力装置
106 通信制御装置
107 記憶装置
110 差分抽出システム
111 構文解析手段
112 ネスト情報解析手段
113 差分抽出手段
114 差分解析手段
115 設計書生成手段
121 ソースコードデータ記憶部
122 抽象構文木データ記憶部
123 ネスト・構文要素TSVデータ記憶部
124 差分抽出データ記憶部
125 差分解析データ記憶部
126 設計書データ記憶部
127 構文解析データ記憶部
128 構文変換データ記憶部
901 旧ソースコードの抽象構文木データ
1001 新ソースコードの抽象構文木データ
1101 旧ソースコードのネスト・構文要素TSV
1201 新ソースコードのネスト・構文要素TSV
1301 差分抽出結果データ
1801 差分解析結果データ
2001 予約語−日本語変換テーブル
2101 本文出力部
2102 変更区分出力部
DESCRIPTION OF
1201 New source code nesting and syntax elements TSV
1301 Difference
Claims (7)
変更前後のソースコードに含まれる予約語に基づき構文解析を行い、前記変更前後のソースコードの各々に対して、前記予約語をノードとする抽象構文木データを生成する構文解析手段と、
前記生成した抽象構文木データの木構造データの深さに基づきネスト情報の解析を行い、前記変更前後のソースコードの各々に対して、ネスト構文要素データを生成するネスト情報解析手段と、
前記生成したネスト構文要素データの各々の比較に基づき、差分抽出データを生成する差分抽出手段であって、前記差分抽出データは、前記変更前後のソースコードにおいて変更があったことを示す第1の差分識別子を含む、差分抽出手段と、
少なくとも一致判別ルールと条件追加・削除抽出ルールとに基づき前記生成した差分抽出データを解析し、差分解析データを生成する差分解析手段であって、前記差分解析データは、変更前後の変更がどのような変更かを示す第2の差分識別子、ならびに変更前後の予約語と、非予約語と、ネスト数と、行番号とを変更前後の行単位で対応して有し、前記第2の差分識別子は、前記第1の差分識別子と比較して、少なくとも、変更前後の変更内容が条件文の条件の追加、または削除であることを多く示すことができ、前記差分解析データを生成することは、
前記一致判別ルールに従った解析として、前記生成した差分抽出データのうちの、変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の行として一致するか否かを判定すること
を含む、差分解析手段と
を備えたことを特徴とするコンピュータ装置。 A computer device that parses the source code before and after the change and extracts a difference, the computer device comprising:
Syntactic analysis based on reserved words included in the source code before and after the change, and for each of the source codes before and after the change, syntax analysis means for generating abstract syntax tree data having the reserved word as a node;
Nest information analysis means for analyzing nest information based on the tree structure data depth of the generated abstract syntax tree data, and generating nested syntax element data for each of the source code before and after the change,
Difference extraction means for generating difference extraction data based on the comparison of each of the generated nested syntax element data , wherein the difference extraction data indicates a change in the source code before and after the change. A difference extraction means including a difference identifier ;
A difference analysis means for analyzing the generated difference extraction data based on at least a match determination rule and a condition addition / deletion extraction rule and generating difference analysis data, wherein the difference analysis data is changed before and after the change. A second difference identifier indicating whether the change is made, a reserved word before and after the change, a non-reserved word, a nest number, and a row number corresponding to each other before and after the change, and the second difference identifier Compared with the first difference identifier, at least, it is possible to indicate that the change content before and after the change is addition or deletion of a condition of a conditional statement, and generating the difference analysis data
As an analysis according to the match determination rule, in the generated difference extraction data, the lines before and after the change are matched according to the degree of matching between the reserved words and the non-reserved words corresponding to the lines before and after the change. And a difference analysis means including determining whether or not the computer apparatus.
前記条件追加・削除抽出ルールに従った解析として、前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の変更が条件文の条件の追加、または削除であるか否かを判定すること
をさらに含むことを特徴とする請求項1に記載のコンピュータ装置。 Generating the differential analysis data includes
As an analysis according to the condition addition / deletion extraction rule, each of the reserved word and the non-reserved word corresponding to the line before and after the change when it is determined as a line before and after the change in the analysis according to the match determination rule The computer apparatus according to claim 1, further comprising: determining whether the change before and after the change is an addition or deletion of a condition of a conditional sentence according to a degree of matching between the two.
変更前後のソースコードに含まれる予約語に基づき構文解析を行い、前記変更前後のソースコードの各々に対して、前記予約語をノードとする抽象構文木データを生成するステップと、
前記生成した抽象構文木データの木構造データの深さに基づきネスト情報の解析を行い、前記変更前後のソースコードの各々に対して、ネスト構文要素データを生成するステップと、
前記生成したネスト構文要素データの各々の比較に基づき、差分抽出データを生成するステップであって、前記差分抽出データは、前記変更前後のソースコードにおいて変更があったことを示す第1の差分識別子を含む、生成するステップと、
少なくとも一致判別ルールと条件追加・削除抽出ルールとに基づき前記生成した差分抽出データを解析し、差分解析データを生成するステップであって、前記差分解析データは、変更前後の変更がどのような変更かを示す第2の差分識別子、ならびに変更前後の予約語と、非予約語と、ネスト数と、行番号とを変更前後の行単位で対応して有し、前記第2の差分識別子は、前記第1の差分識別子と比較して、少なくとも、変更前後の変更内容が条件文の条件の追加、削除、字上げ、または字下げであることを多く示すことができ、前記差分解析データを生成するステップは、
前記一致判別ルールに従った解析として、前記生成した差分抽出データのうちの、変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の行として一致するか否かを判定するステップと、
前記条件追加・削除抽出ルールに従った解析として、前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の変更が条件文の条件の追加、または削除であるか否かを判定するステップと、
前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行のネスト数を比較して、字上げまたは字下げが発生しているか否かを判定するステップと
を含む、生成するステップと、
前記生成した差分解析データと前記生成した変更前のソースコードに対するネスト構文要素データを設計書用文言に変換し、設計書データを生成するステップであって、前記設計書データは、変更前後の変更内容を、変更前後の行単位で対応して有する、生成するステップと
を備えたことを特徴とするコンピュータ実行方法。 A computer-implemented method for parsing source code before and after the change, extracting differences, and generating design document data, the computer-executed method comprising:
Performing syntax analysis based on reserved words included in the source code before and after the change, and generating abstract syntax tree data having the reserved word as a node for each of the source codes before and after the change;
Analyzing the nested information based on the tree structure data depth of the generated abstract syntax tree data, and generating nested syntax element data for each of the source code before and after the change;
A step of generating difference extraction data based on each comparison of the generated nested syntax element data , wherein the difference extraction data is a first difference identifier indicating that there is a change in the source code before and after the change Generating, including :
Analyzing the generated difference extraction data based on at least the match determination rule and the condition addition / deletion extraction rule, and generating difference analysis data, the difference analysis data being changed before and after the change. And a reserved word before and after the change, a non-reserved word, a nesting number, and a row number corresponding to each other before and after the change, and the second difference identifier is: Compared with the first difference identifier, at least the change contents before and after the change can indicate more that the condition sentence condition is added, deleted, indented, or indented, and the difference analysis data is generated The steps to do are
As an analysis according to the match determination rule, in the generated difference extraction data, the lines before and after the change are matched according to the degree of matching between the reserved words and the non-reserved words corresponding to the lines before and after the change. Determining whether or not,
As an analysis according to the condition addition / deletion extraction rule, each of the reserved word and the non-reserved word corresponding to the line before and after the change when it is determined as a line before and after the change in the analysis according to the match determination rule Determining whether or not the change before and after the change is the addition or deletion of a condition in the conditional statement according to the degree of matching between each other;
A step of determining whether or not indentation or indentation has occurred by comparing the number of nests of the lines before and after the change when it is determined that the lines match before and after the change in the analysis according to the match determination rule Generating steps including and
The generated differential analysis data and the generated nested syntax element data for the source code before the change are converted into a design document word, and a design document data is generated, wherein the design document data is changed before and after the change. A computer-implemented method comprising: a step of generating contents corresponding to each line before and after the change.
変更前後のソースコードに含まれる予約語に基づき構文解析を行い、前記変更前後のソースコードの各々に対して、前記予約語をノードとする抽象構文木データを生成するステップであって、前記抽象構文木データは、前記予約語をノードとする木構造データであり、前記予約語と、前記予約語に対応する非予約語と、前記予約語を含む行を示す行番号データとを有する、生成するステップと、
前記生成した抽象構文木データの木構造データの深さに基づきネスト情報の解析を行い、前記変更前後のソースコードの各々に対して、ネスト構文要素データを生成するステップと、
前記生成したネスト構文要素データの各々の比較に基づき、差分抽出データを生成するステップであって、前記差分抽出データは、前記変更前後のソースコードにおいて変更があったことを示す第1の差分識別子を含む、生成するステップと、
少なくとも一致判別ルールと条件追加・削除抽出ルールとに基づき前記生成した差分抽出データを解析し、差分解析データを生成するステップであって、前記差分解析データは、変更前後の変更がどのような変更かを示す第2の差分識別子、ならびに変更前後の予約語と、非予約語と、ネスト数と、行番号とを変更前後の行単位で対応して有し、前記第2の差分識別子は、前記第1の差分識別子と比較して、少なくとも、変更前後の変更内容が条件文の条件の追加、削除、字上げ、または字下げであることを多く示すことができ、前記差分解析データを生成するステップは、
前記一致判別ルールに従った解析として、前記生成した差分抽出データのうちの、変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の行として一致するか否かを判定するステップと、
前記条件追加・削除抽出ルールに従った解析として、前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行で対応する予約語および非予約語の各々同士の一致度合いに応じて、変更前後の変更が条件文の条件の追加、または削除であるか否かを判定するステップと、
前記一致判別ルールに従った解析において変更前後の行として一致すると判定された場合、前記変更前後の行のネスト数を比較して、字上げまたは字下げが発生しているか否かを判定するステップと
を含む、生成するステップと、
前記生成した差分解析データと前記生成した変更前のソースコードに対するネスト構文要素データを設計書用文言に変換し、設計書データを生成するステップであって、前記設計書データは、変更前後の変更内容を、変更前後の行単位で対応して有する、生成するステップと
を備えたことを特徴とするコンピュータプログラム。 A computer program comprising computer-executable instructions for causing a computer to execute a computer execution method for parsing source code before and after change, extracting a difference, and generating design document data, the computer execution method comprising:
Performing a syntax analysis based on reserved words included in the source code before and after the change, and generating abstract syntax tree data having the reserved word as a node for each of the source codes before and after the change, the abstract code The syntax tree data is tree structure data having the reserved word as a node, and includes the reserved word, a non-reserved word corresponding to the reserved word, and line number data indicating a line including the reserved word. And steps to
Analyzing the nested information based on the tree structure data depth of the generated abstract syntax tree data, and generating nested syntax element data for each of the source code before and after the change;
A step of generating difference extraction data based on each comparison of the generated nested syntax element data , wherein the difference extraction data is a first difference identifier indicating that there is a change in the source code before and after the change Generating, including :
Analyzing the generated difference extraction data based on at least the match determination rule and the condition addition / deletion extraction rule, and generating difference analysis data, the difference analysis data being changed before and after the change. And a reserved word before and after the change, a non-reserved word, a nesting number, and a row number corresponding to each other before and after the change, and the second difference identifier is: Compared with the first difference identifier, at least the change contents before and after the change can indicate more that the condition sentence condition is added, deleted, indented, or indented, and the difference analysis data is generated The steps to do are
As an analysis according to the match determination rule, in the generated difference extraction data, the lines before and after the change are matched according to the degree of matching between the reserved words and the non-reserved words corresponding to the lines before and after the change. Determining whether or not,
As an analysis according to the condition addition / deletion extraction rule, each of the reserved word and the non-reserved word corresponding to the line before and after the change when it is determined as a line before and after the change in the analysis according to the match determination rule Determining whether or not the change before and after the change is the addition or deletion of a condition in the conditional statement according to the degree of matching between each other;
A step of determining whether or not indentation or indentation has occurred by comparing the number of nests of the lines before and after the change when it is determined that the lines match before and after the change in the analysis according to the match determination rule Generating steps including and
The generated differential analysis data and the generated nested syntax element data for the source code before the change are converted into a design document word, and a design document data is generated, wherein the design document data is changed before and after the change. A computer program comprising: a step of generating contents corresponding to each line before and after the change.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2012131974A JP6022815B2 (en) | 2012-06-11 | 2012-06-11 | Source code difference extraction method and system using parsing |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2012131974A JP6022815B2 (en) | 2012-06-11 | 2012-06-11 | Source code difference extraction method and system using parsing |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2013257639A JP2013257639A (en) | 2013-12-26 |
JP6022815B2 true JP6022815B2 (en) | 2016-11-09 |
Family
ID=49954053
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2012131974A Active JP6022815B2 (en) | 2012-06-11 | 2012-06-11 | Source code difference extraction method and system using parsing |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP6022815B2 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP7306026B2 (en) * | 2019-04-01 | 2023-07-11 | カシオ計算機株式会社 | Program for converting program, information processing apparatus, and information processing method |
CN115167834B (en) * | 2022-09-08 | 2022-12-23 | 杭州新中大科技股份有限公司 | Automatic source code generation method and device based on code datamation |
CN116302089B (en) * | 2023-05-23 | 2023-08-18 | 华中科技大学 | Picture similarity-based code clone detection method, system and storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH04165425A (en) * | 1990-10-29 | 1992-06-11 | Nippon Telegr & Teleph Corp <Ntt> | Method and device for extracting nesting relation in symbol string |
JPH05143351A (en) * | 1991-11-22 | 1993-06-11 | Nec Corp | Source program comparing system |
-
2012
- 2012-06-11 JP JP2012131974A patent/JP6022815B2/en active Active
Also Published As
Publication number | Publication date |
---|---|
JP2013257639A (en) | 2013-12-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104899010B (en) | The multi-lingual opinion on public affairs method and system of source code | |
US9690788B2 (en) | File type recognition analysis method and system | |
CA3088692A1 (en) | Visualizing comment sentiment | |
US9811449B2 (en) | Test scenario generation support device and test scenario generation support method | |
CN102339252A (en) | Static state detecting system based on XML (Extensive Makeup Language) middle model and defect mode matching | |
US10049032B2 (en) | Methods for generating a negative test input data and devices thereof | |
Hamza et al. | Generating UML use case models from software requirements using natural language processing | |
US20190272324A1 (en) | Language model, method and apparatus for interpreting zoning legal text | |
KR20120051419A (en) | Apparatus and method for extracting cascading style sheet | |
JP4815934B2 (en) | Text mining device, text mining method, text mining program | |
JP6022815B2 (en) | Source code difference extraction method and system using parsing | |
CN113792027B (en) | General database conversion device | |
CN103761095A (en) | Method for generating universal header data information of upgraded file | |
JP2010061176A (en) | Text mining device, text mining method, and text mining program | |
CN102707938B (en) | Table-form software specification manufacturing and supporting method and device | |
JP2008112363A (en) | Document processor and document processing program | |
CN115599388A (en) | API (application programming interface) document generation method, storage medium and electronic equipment | |
US11416246B2 (en) | Information processing apparatus, analysis system, analysis method, and non-transitory computer readable medium storing analysis program | |
CN115579096A (en) | Automatic generation and analysis verification method, system and storage medium for drug alert E2B R3 standard report | |
US10120652B2 (en) | System and method for representing software development requirements into standard diagrams | |
JP2013218507A (en) | Structure analyzer and program | |
Singh et al. | pyTLEX: A Python Library for TimeLine EXtraction | |
JP4387324B2 (en) | Property conversion device | |
US20240004620A1 (en) | Automated generation of web applications based on wireframe metadata generated from user requirements | |
US20230251857A1 (en) | Development support device, non-transitory computer-readable medium, and development support method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20150608 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20160212 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20160223 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20160418 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20160913 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20161006 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 6022815 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
R250 | Receipt of annual fees |
Free format text: JAPANESE INTERMEDIATE CODE: R250 |
|
S533 | Written request for registration of change of name |
Free format text: JAPANESE INTERMEDIATE CODE: R313533 |
|
R350 | Written notification of registration of transfer |
Free format text: JAPANESE INTERMEDIATE CODE: R350 |