JP3933892B2 - Specification creation program and computer-readable medium storing specification creation program - Google Patents

Specification creation program and computer-readable medium storing specification creation program Download PDF

Info

Publication number
JP3933892B2
JP3933892B2 JP2001214929A JP2001214929A JP3933892B2 JP 3933892 B2 JP3933892 B2 JP 3933892B2 JP 2001214929 A JP2001214929 A JP 2001214929A JP 2001214929 A JP2001214929 A JP 2001214929A JP 3933892 B2 JP3933892 B2 JP 3933892B2
Authority
JP
Japan
Prior art keywords
comment
sentence
source code
keyword
storage means
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
JP2001214929A
Other languages
Japanese (ja)
Other versions
JP2002169692A (en
Inventor
孝次 佐々木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fujitsu Ltd
Original Assignee
Fujitsu Ltd
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 Fujitsu Ltd filed Critical Fujitsu Ltd
Priority to JP2001214929A priority Critical patent/JP3933892B2/en
Publication of JP2002169692A publication Critical patent/JP2002169692A/en
Application granted granted Critical
Publication of JP3933892B2 publication Critical patent/JP3933892B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Description

【0001】
【発明の属する技術分野】
本発明は、各種プログラミング言語により記述されたソースコードに基づき、仕様書データを作成する仕様書作成プログラム及び仕様書作成プログラムを格納したコンピュータ可読媒体に、関する。
【0002】
【従来の技術】
一般に、C++その他のプログラミング言語により記述されたソースコード中には、コンパイルされてもオブジェクトコードに変換されないコメント文が、含まれている。通常、このコメント文には、プログラムの処理内容についての説明等が記述されている。このため、ソースコードからコメント文が抽出されると、プログラムの処理内容についての説明が、得られる。
【0003】
そこで、ソースコードからコメント文を抽出することにより、当該プログラムの仕様書を自動的に作成する仕様書作成装置が、利用されている。この仕様書作成装置は、ソースコードからコメント文を抽出して仕様書を作成する機能の他に、作成された仕様書をオペレータにより編集させる機能,及び,編集された仕様書の内容をソースコードへ反映させる機能を、有している。
【0004】
通常、ソースコードは、複数の「集合体」を含んでいる。例えば、このソースコードが、C++により記述されている場合には、クラス,メンバ関数,外部関数,及び外部変数等が、その集合体に相当する。特に、これら集合体のうちの関数(メンバ関数及び外部関数)は、その内部に処理手続が記述されているため、「処理手続を有する集合体」という。
【0005】
なお、コメント文は、集合体の直前に記述されているコメント文(第1種のコメント文)と、処理手続を有する集合体における処理手続内に記述されているコメント文(第2種のコメント文)とに、分類される。従来の仕様書作成装置は、第1種のコメント文を、ソースコードから抽出することにより、仕様書を自動作成する。そして、オペレータは、この仕様書作成装置を操作することにより、作成された仕様書を編集する。即ち、オペレータは、自動作成された仕様書に対し、不備な点を追加入力したり、不適切な記述を変更する。
【0006】
さらに、この仕様書作成装置は、変更された仕様書における変更点を、元のソースコードに反映させる。即ち、仕様書作成装置は、更新された仕様書の内容をコメント文の形式に変換し、変換したコメント文(第1種のコメント文)を、当該コメント文が対応する集合体の直前に配置された変更前の旧コメント文と置換することにより、編集による変更点をソースコードに反映させる。
【0007】
【発明が解決しようとする課題】
上記の従来技術による仕様書作成装置は、第2種のコメント文を処理対象としていない。仮に、この仕様書作成装置が第2種のコメント文をも処理対象にする場合を想定すると、以下のような問題がある。即ち、この仕様書作成装置は、ソースコードから第1種のコメント文及び第2種のコメント文を抽出して、仕様書を作成したとしても、編集により変更された仕様書の変更点のうち、第2種のコメント文に対応するものを、元のソースコードに反映させることができないという問題がある。この仕様書作成装置は、第2種のコメント文に関する変更点を、処理手続を有する集合体(関数)の内部におけるどの位置に挿入すべきか、認識できないためである。
【0008】
この第2種のコメント文に関する仕様書中の変更点が、ソースコードへ反映されるためには、仕様書作成装置が、ソースコード中における記述行番号などの絶対的な位置を手がかりに当該変更点を関数内に挿入することも、考えられる。しかし、この場合には、仕様書が自動作成された後、編集による仕様書の変更点がこのソースコードに反映されるまでの期間中に、このソースコードは一切変更されてはならない。即ち、当該期間中は、オペレータは、このソースコードを修正することができなくなる。このため、開発効率が低下してしまう。
【0009】
従って、従来の仕様書作成装置は、第1種のコメント文のみを処理の対象としていた。即ち、従来の仕様書作成装置は、ソースコードから第1種のコメント文のみを抽出して、仕様書を作成していた。
【0010】
しかしながら、第1種のコメント文のみに基づいて作成された仕様書は、その記述の内容が充分ではない。そこで、第2種のコメント文をも処理の対象として取り扱うことができる仕様書作成装置,仕様書作成プログラム,及び仕様書作成プログラムを格納したコンピュータ可読媒体を提供することを、本発明の課題とする。
【0011】
【課題を解決するための手段】
本発明は、上記課題を解決するために、以下のような構成を採用した。
【0012】
即ち、本発明の仕様書作成装置は、入力装置,表示装置,及びプログラムに従った処理を実行する処理装置と、仕様書作成プログラムを格納した記憶媒体を、備えており、処理対象となるソースコードからコメント文を抽出して、仕様書データを作成する。
【0013】
この仕様書作成プログラムは、処理装置に対して、ソースコード中のコメント文が配置されるべき位置に、ユニークなコメントキーワードを含んだコメント文を配置させ、このコメント文を抽出して仕様書データを作成させ、作成した仕様書データを表示装置に表示させ、入力装置を介して当該表示内容を変更する旨の指示がなされた場合には、この指示に従って、仕様書データ中のコメント文の内容を変更させ、ソースコード中のコメント文を、仕様書データ中のコメント文のうちのコメントキーワードが一致するもので置き換えさせる。
【0014】
このように構成されると、ソースコード中のコメント文は、一意的に識別可能なコメントキーワードを含むことになる。これら各コメント文は、そのコメントキーワードにより、個別に管理される。このため、これら各コメント文が抽出されて仕様書データが作成され、この仕様書データがオペレータにより編集された場合に、仕様書データ中の変更点は、そのコメントキーワードを手掛かりに,ソースコード中のコメント文に、反映される。
【0015】
ソースコード中のコメント文は、集合体の直前に記述されるもの(第1種のコメント)と、処理手続を有する集合体内に記述されるもの(第2種のコメント)とに、分類される。そして、コメントキーワードにより管理されるのは、第2種のコメントだけであってもよい。但し、これに限らず、第1種のコメントも、コメントキーワードにより管理されてもよい。
【0016】
なお、ソースコードは、C++,C,BASIC,Java(米国、その他の国における米国Sun Microsystems社の商標または登録商標),FORTRAN,PASCAL,COBOL,又はその他のプログラミング言語により記述されたものである。
【0017】
【発明の実施の形態】
以下、図面に基づいて本発明の一実施形態による仕様書作成装置について、説明する。この仕様書作成装置は、パーソナルコンピュータ又はワークステーション等のコンピュータに、後述する処理を実行するソフトウェアを実装することにより、構成されていてもよい。
【0018】
図1は、この仕様書作成装置のハードウェア構成図である。この図1に示されるように、仕様書作成装置は、バス及び図示せぬインタフェースを介して相互に接続されたCPU11,RAM12,HDD13,CD−ROMドライブ14,ディスプレイ15,キーボード16,マウス17,及びプリンタ18を、備えている。
【0019】
CPU11は、各種プログラムを実行することにより所定の処理を行う処理装置である。RAM12は、データを記憶可能である。そして、CPU11は、このRAM12上に、各種プログラムや各種テーブル等を展開する。
【0020】
HDD(Hard Disk Drive)13は、磁気的に情報を保持可能な複数のディスク,及び,これら各ディスクに対してデータを読み書きする磁気ヘッドを、有する。そして、CPU11は、このHDD13を制御することにより、各ディスクに対してデータを読み書きさせる。このHDD13は、記憶媒体及びコンピュータ可読媒体に相当する。
【0021】
CD−ROMドライブ14は、CD−ROMを着脱可能に装填するスロット,及びCD−ROMからデータを読み出す光学ヘッドを、有する。そして、CPU11は、このCD−ROMドライブ4を制御することにより、装填されたCD−ROM内のデータを、読み出す。
【0022】
ディスプレイ15は、CRTやLCD等によりなり、画像データ及び文字データを画面表示する。そして、CPU11は、このディスプレイ15を制御して、画像データ及び文字データを、画面表示させる。このディスプレイ15は、表示装置に相当する。
【0023】
キーボード16は、オペレータにキャラクタコードを入力させるためのものである。マウス17は、ディスプレイ15上の所定領域に対応した仮想空間上の位置をオペレータに指定させるためのポインティングデバイスである。CPU11は、これらキーボード16及びマウス17からの入力を取得する。これらキーボード16及びマウス17は、入力装置に相当する。
【0024】
プリンタ18は、紙等の各種媒体に、文字やイメージを印刷する装置である。CPU11は、このプリンタ18へ文字データやイメージデータを送信することにより、これらのデータを印刷させる。
【0025】
なお、HDD13には、予め、オペレーティングシステム及びアプリケーションプログラム等のソフトウェアが、インストールされている。このソフトウェアは、CD−ROM内に書き込まれた状態で、配布されることがある。この場合には、このソフトウェアは、CD−ROMドライブ14を介してHDD13にインストールされる。
【0026】
上記オペレーティングシステムは、システム管理用のカーネル,及びGUIを提供するウインドウシステムを、含んでいる。そして、CPU11は、オペレーティングシステムの少なくとも一部がRAM12上に展開された状態で、このオペレーティングシステムのコードに従って動作する。
【0027】
また、アプリケーションプログラムは、オペレーティングシステムが提供するAPIを介して、このオペレーティングシステムの機能を呼び出すことにより、所定の処理を実現するプログラムである。そして、CPU11は、オペレーティングシステムが稼動した状態において、このアプリケーションプログラムを実行する。より具体的には、このアプリケーションプログラムは、エディタ及びコンパイラを有するソフトウェア開発環境,並びに,仕様書作成プログラムを、含んでいる。
【0028】
そして、オペレータは、エディタを用いてソースコードを記述することにより、ソフトウェア開発を行う。記述されたソースコードは、HDD13内に格納される。図2は、C++言語により記述されたソースコード例を示す図である。
【0029】
この図2において、先頭が“//”である行が、コメント文である。なお、このコメント文は、「集合体」の直前に記述されている第1種のコメント文と、「処理手続を有する集合体」(関数)における処理手続内に記述されている第2種のコメント文とに、分類される。
【0030】
この図2の例では、第7行目の“int getline()”以降が集合体(関数)であるため、第1行目乃至第6行目は、第1種のコメント文である。即ち、“//概要”,“//ファイルの行数を求める”,“//戻り値”,“//ファイルの行数”,“//パラメタ説明”,及び“//なし”,が、第1種のコメント文である。
【0031】
なお、この第1種のコメント文は、所定の記述方式に従って記述されている。この記述方式によると、オペレータは、関数のプログラム(ソースコード)を作成する際に、必ず、当該関数についての“概要”,“戻り値”,及び“パラメタ説明”の各項目についての説明を記述することが、定められている。さらに、これら各項目についての説明は、夫々、“//概要”,“//戻り値”,及び“//パラメタ説明”の各コメント文の直後に記述されることが、定められている。
【0032】
この図2において、第9,12,16行目は、関数内に記述されているので、第2種のコメント文である。即ち、“//変数の初期化を行う”,“//ファイルの終端を検出するまで行数を数える”,及び“//行数を画面に表示する”が、第2種のコメント文である。
【0033】
仕様書作成プログラムは、このようなソースコードに基づいて、当該ソースコードに対応した仕様書を作成するためのプログラムである。以下、この仕様書作成プログラムを実行するCPU11の処理について、図3のフローチャートを参照して概説する。この図3のフローチャート開始後の最初のS1では、CPU11は、ソースコードから第1種のコメント文を抽出して、以下に示すコメントデータベースを作成する。
【0034】
図4は、図2のソースコードにおける集合体(getline関数)についてのコメントデータベースの内容を模式的に示す図である。このコメントデータベースには、コメント項目として、“概要”,“戻り値”,“パラメタ説明”,及び“機能説明”が、設定されている。また、このコメントデータベースには、これら各コメント項目に夫々対応する複数のコメントフィールド(図4の“コメント”欄)が、設定されている。なお、このコメントデータベースは、仕様書データに相当する。
【0035】
この図4に示されるように、図2のソースコード中の第1種のコメント文における“//概要”の次の“//ファイルの行数を求める”が、概要に対応するコメントとして、コメントフィールドに格納されている。同様に、“//戻り値”の次の“//ファイルの行数”が、戻り値に対応するコメント文として、コメントフィールドに格納されている。同様に、“//パラメタ説明”の次の“//なし”が、パラメタ説明に対応するコメント文としてコメントフィールドに格納されている。なお、機能説明に対応するコメントフィールドは、後述の処理において、第2種のコメント文から抽出されるので、この時点では空欄になっている。
【0036】
次のS2では、CPU11は、ディスプレイ15上に、図5に示されるコメントキーワード形式設定画面20を表示する。オペレータは、このコメントキーワード形式設定画面20の先頭キーワード欄21に、キーボード16を介して後述するコメントキーワードの形式を入力する。なお、この図5の例では、コメントキーワードの形式として、“*.*)”が入力されている。この状態で、オペレータは、マウス17によりボタン22をクリックすることにより、コメントキーワードの形式を“*.*)”に設定する。
【0037】
この“*.*)”は、仕様書プログラムにおいて予め規定された書式を模式的に示すものである。より具体的には、この“*.*)”は、“1”,“1.2”,“2.3.5”等の階層表現可能な項番を、意味している。後述するように、仕様書プログラムは、第2種のコメント文の夫々に対して、該コメント文に一意的に関連付けられたコメントキーワードを付与することにより、これら各コメント文を管理する。
【0038】
次のS3では、CPU11は、ディスプレイ15上に、図6に示されるコメントキーワード挿入位置設定画面30を表示する。オペレータは、このコメントキーワード挿入位置設定画面30を見ながらコメントキーワードの設定位置を決定する。このコメントキーワード挿入位置設定画面30は、一対のチェックボックス31,32を、含んでいる。図6は、オペレータがマウス17を操作して第1のチェックボックス31のみをチェックした状態を、示している。この第1のチェックボックス31がチェックされた場合には、ソースコード内に既に記述された第2種のコメント文中に、後述の処理においてコメントキーワードが挿入される。なお、この図6に示された設定は、図7のように必要なコメント文が全て記述されたソースコードを処理対象とする場合に、なされる。
【0039】
一方、図8は、オペレータがマウス17を操作して第2のチェックボックス32のみをチェックした状態を、示している。この第2のチェックボックス32がチェックされた場合には、後述の処理において、関数内における所定の指定箇所に、コメントキーワードが挿入される。この図8に示された設定は、図9のように第2種のコメントが何も記述されていないソースコードを処理対象とする場合に、なされる。
【0040】
なお、図8に示されるように、第2のチェックボックス32がチェックされた場合には、新たに、3つのチェックボックス33,34,35が、表示される。これら各チェックボックス33,34,35は、指定箇所を特定するためのものである。
【0041】
そして、第3のチェックボックス33がチェックされた場合には、順次文が、指定箇所として特定される(但し、順次文が連続する場合には、先頭の順次文のみが指定箇所として特定されれる)。即ち、連続する順次文の先頭,及び,連続しない連続しない順次文(単独の順次文)が、指定箇所として特定される。第4のチェックボックス34がチェックされた場合には、for,do,while及びif等の繰返し文及び判定文が、指定箇所として特定される。第5のチェックボックス35がチェックされた場合には、return,goto及びcontinue等の分岐文が、指定箇所として特定される。
【0042】
図10は、オペレータがマウス17を操作して第1のチェックボックス31,及び,第2のチェックボックス32をチェックした状態を、示している。この図10に示されるように、オペレータは、これら両チェックボックス31,32の双方をチェックすることもできる。この場合には、ソースコード内に既に記述されたコメント文中,及び,指定箇所の双方に、コメントキーワードが挿入される。なお、図2のように、第2種のコメント文がいくつか記述されているものの、記述が不充分である場合には、この図10に示された設定が、なされる。
【0043】
そして、オペレータは、マウス17を操作して、これら図6,図8又は図10に示されたコメントキーワード挿入位置設定画面30におけるボタン36をクリックすることにより、このコメントキーワード挿入位置設定画面30において設定された内容を、決定する。
【0044】
次のS4では、CPU11は、ソースコード中にコメントキーワードを挿入する。このコメントキーワードは、S3において設定された位置に挿入される。このS3において、図6のように設定されていた場合には、S4において、ソースコード内に既に記述されたコメント文中に、コメントキーワードが挿入される。即ち、図7のソースコードは、図11に示されるように変換される。
【0045】
一方、図8のように設定(S3)されていた場合には、このS4において、指定箇所にコメントキーワードが挿入される。即ち、図9のソースコードは、図12に示されるように変換される。この図12に示されるように、コメントキーワードは、図9においてコメント文が存在していなかった位置に、挿入されている。
【0046】
また、図10のように設定(S3)されていた場合には、このS4において、ソースコード内に既に記述されたコメント文,及び,指定箇所の双方に、コメントキーワードが挿入される。即ち、図2のソースコードは、図13に示されるように変換される。なお、このS4の処理については、後において詳述する。
【0047】
次のS5では、CPU11は、ソースコードから第2種のコメントを抽出して、コメントデータベースに格納する。例えば、図13のソースコードからは、“//1)変数の初期化を行う”,“//2)ファイルの終端を検出するまで行数を数える”,“//2.1)”,“//2.1.1)”,“//3)行数を画面に表示する”,及び“//4)”が、抽出される。なお、これら各コメント文は、S4で挿入されたコメントキーワードを含んでいる。抽出された各コメント文は、コメントデータベース(図4)の機能説明に対応するコメントフィールドに、格納される。図14は、これら各コメント文が格納された状態のコメントデータベースの内容を、模式的に示す図である。なお、このS5の処理については、後において詳述する。
【0048】
次のS6では、CPU11は、ディスプレイ15上に、図15に示される編集画面40を表示する。オペレータは、この編集画面40を見ながら、キーボード16を操作することにより、仕様書の内容を編集する。さらに、CPU11は、編集後の仕様書の内容をコメントデータベースに反映させる。
【0049】
図15に示されるように、この編集画面40は、4つの編集フィールド41〜44を、含んでいる。これら各編集フィールド41〜44には、図14に示されたコメントデータベースの内容が表示されている。
【0050】
第1の編集フィールド41には、コメントデータベースの概要に対応するコメントフィールドの内容“ファイルの行数を求める”が、表示されている。第2の編集フィールド42には、コメントデータベースの戻り値に対応するコメントフィールドの内容“ファイルの行数”が、表示されている。第3の編集フィールド43には、コメントデータベースのパラメタ説明に対応するコメントフィールドの内容“なし”が、表示されている。これら第1乃至第3の編集フィールド41〜43に表示された内容は、第1種のコメント文から抽出されたものである。
【0051】
第4の編集フィールド44には、コメントデータベースの機能説明に対応するコメントフィールドの内容が、表示されている。即ち、“1)変数の初期化を行う”,“2)ファイルの終端を検出するまで行数を数える”,“2.1)”,“2.1.1)”,“3)行数を画面に表示する”,及び“4)”が、表示されている。この第4の編集フィールド44に表示された内容は、第2種のコメント文から抽出されたものである。
【0052】
オペレータは、各編集フィールド41〜44にカーソルを合わせ、キーボード16を操作することにより、これら各編集フィールド41〜44の内容を変更することができる。図15の例では、第4の編集フィールド44に、記載の不充分な部分があるので、オペレータは、その不充分な部分を補う。即ち、オペレータは、“2.1)”,“2,1,1)”及び“4)”の部分に、説明文を追加する。
【0053】
図16は、編集後の編集画面40を示す画面例である。この図16に示されるように、図15の“2.1)”,“2,1,1)”及び“4)”の部分は、夫々、“2.1)改行文字か調べる”,“2,1,1)改行文字の場合、行数をカウントする”及び“4)行数を呼出し元へ返す”に、変更されている。
【0054】
この編集が終了した後、CPU11は、各編集フィールド41〜44の内容を、コメントデータベースに格納することにより、上記変更点をこのコメントデータベースに反映させる。図17は、変更点が反映されたコメントデータベースの内容を模式的に示す図である。
【0055】
この図17に示されるように、図16の編集画面40における第1の編集フィールド41の内容は、コメントデータベースの概要に対応するコメントフィールドへ格納される。同様に、第2の編集フィールド42の内容は、戻り値に対応するコメントフィールドに格納される。同様に、第3の編集フィールド43の内容は、パラメタ説明に対応するコメントフィールドに格納される。同様に、第4の編集フィールド44の内容は、機能説明に対応するコメントフィールドに格納される。
【0056】
次のS7では、CPU11は、プリンタ18に仕様書を印刷させる。即ち、CPU11は、S6において処理されたコメントデータベースの内容を所定の書式に対応させて、プリンタ18に仕様書として印刷させる。この仕様書は、例えば、図16の画面と略同じ書式で、印刷されてもよい。なお、このコメントデータベースの内容は、HTML形式,各種ワープロソフトのファイル形式,又は各種表計算ソフトのファイル形式等に変換されて、HDD13内に格納されてもよい。
【0057】
次のS8では、CPU11は、S6において処理されたコメントデータベースの内容のうちの第1種のコメント文に関する部分を、ソースコードに反映させる。なお、S6において、図15の編集画面40が図16に示されるように変更された場合には、第1種のコメントに対応する第1乃至第3の編集フィールド41〜43は、その内容が更新されていない。この場合には、コメントデータベースにおける当該部分も変化しないので、ソースコードにおける第1のコメント文の部分も、変化しない。
【0058】
次のS9では、CPU11は、S6において処理したコメントデータベースの内容のうちの第2種のコメント文に関する部分を、ソースコードに反映させる。図18は、更新されたソースコードを示す図である。この図18に示されるように、図13の“2.1)”,“2,1,1)”,及び“4)”の部分は、夫々、“2.1)改行文字か調べる”,“2,1,1)改行文字の場合、行数をカウントする”,及び“4)行数を呼び出し元へ返す”に、変更されている。なお、このS9の処理については、後において詳述する。
【0059】
以下、上述した図3のフローチャートにおけるS4の処理について、図19を参照してさらに説明する。なお、この図19のフローチャートは、CPU11が、HDD13内に格納されたソースコードを開き、関数の開始部分まで読み込む処理がなされた後に、開始する。
【0060】
この図19のフローチャート開始後の最初のS401では、CPU11は、ソースコードを、処理対象となる関数の最後の部分まで読み込んで解析し、構文テーブルを作成する。即ち、CPU11は、ソースコードの各行毎に、文の種類を判別するとともに、プログラミング言語の論理構造におけるネストの深さを判別する。このネストの深さは、ネスト番号(自然数)で表される。このネスト番号は、最も浅いネストに1が対応している。そして、1段階ずつネストが深くなるにつれて、ネスト番号は、1ずつ増加してゆく。なお、構文テーブルの作成領域は、RAM12又はHDD13内に確保されている。
【0061】
さらに、CPU11は、コメントキーワードの管理用の項番テーブルを、RAM12又はHDD13内に、確保している。この項番テーブルは、0又は自然数を格納可能なフィールドを、複数含んでいる。この項番テーブルのフィールド数は、処理対象となるソースコードにおける最大のネスト番号に一致している。なお、項番テーブルは、その初期状態において、各フィールドが0に設定されている。以下、説明を簡潔にするために、この項番テーブルのフィールド数を3とする。この場合において、項番テーブルの初期状態における値は、“0;0;0”である。この項番テーブルの最初のフィールドは、ネスト番号1に対応しており、次のフィールドは、ネスト番号2に対応している。以下、順次同様に、項番テーブルの各フィールドは、各ネスト番号に対応している。
【0062】
図20は、図2のソースコードに基づく構文テーブルの模式図である。この構文テーブルは、ソースコードの各行に関して、文の種類,ネスト番号,及び,当該行に記載された文そのものを、含んでいる。即ち、この構文テーブルの各レコードは、“文の種類”フィールド,“ネスト番号”フィールド,及び“文”フィールドを、含んでいる。なお、この構文テーブルにおける各レコードは、ソースコードにおける文の記載順に従って、配列されている。この図20の構文テーブルに対して、後述のS402以降の処理がなされた場合に得られる構文テーブルは、図21に示されている。
【0063】
図20において、“//変数の初期化を行う”の文を含む先頭のレコードは、文の種類がコメント文であり、ネスト番号が1と判別されている。そして、“int c,nl;”及び“nl=0;”は、夫々、文の種類が順次文であり、ネスト番号が1と判別されている。次の“//ファイルの終端を検出するまで行数を数える”の文を含むレコードは、文の種類がコメント文であり、ネスト番号が1と判別されている。
【0064】
次の“while((c=getchar()) !=EOF)”の文を含むレコードは、文の種類が繰返し文であり、ネスト番号が2と判別されている。即ち、CPU11は、C++の言語構造に従って、ネストが1段階深くなったと、判別している。次の“if(c=='\n') ”の文を含むレコードは、文の種類が判定文であり、ネスト番号が3と判別されている。即ち、CPU11は、C++の言語構造に従って、ネストがさらに1段階深くなったと、判別している。
【0065】
次の“++nl;”の文を含むレコードは、文の種類が順次文であり、ネスト番号が3と判別されている。次の“//行数を画面に表示する”の文を含むレコードは、文の種類がコメント文であり、ネスト番号が1と判別されている。即ち、CPU11は、C++の言語構造に従って、ネストが2段階浅くなったと、判別している。次の“printf("%d\n",nl);”の文を含むレコードは、文の種類が順次文であり、ネスト番号が1と判別されている。次の“return nl;”の文を含むレコードは、文の種類が分岐文であり、ネスト番号が1と判別されている。
【0066】
以降の処理において、CPU11は、構文テーブルを、その先頭のレコードから1レコードずつ順次処理して行く。但し、現段階では、構文テーブルの各レコードは全て未処理であり、処理済のレコードはまだ存在しない。
【0067】
S402では、CPU11は、構文テーブルに未処理のレコードがあるかどうか、判別する。そして、CPU11は、未処理のレコードがあれば処理をS403へ進め、未処理のレコードがなければ処理を終了させる。
【0068】
S403では、CPU11は、構文テーブルにおける未処理のレコードのうちの先頭の1レコードを、処理対象レコードとして取り出す。
【0069】
次のS404では、CPU11は、処理対象レコードの文の種類が、コメント文であるかどうか判別する。そして、CPU11は、この文の種類がコメント文である場合には、処理をS405へ進め、それ以外の場合には、処理をS409へ進める。
【0070】
S405では、CPU11は、処理対象レコードの文(コメント文)が、コメントキーワードを含んでいるかどうか、判別する。そして、CPU11は、コメントキーワードが含まれている場合には、処理をS406へ進め、コメントキーワードが含まれていない場合には、処理をS407へ進める。なお、図20の構文テーブルにおける各文は、いずれもコメントキーワードを含んでいない。このため、この図20の構文テーブルが処理される場合には、S406の処理は1度も行われないことになる。このS406の処理については、別の構文テーブルの例を用いて、後述する。
【0071】
S407では、CPU11は、コメント文にコメントキーワードを挿入する設定がなされているかどうか判別する。図6又は図10に示されたように、コメントキーワード挿入位置設定画面30の第1のチェックボックス31がチェックされていた場合には、CPU11は、コメントキーワードを挿入するものと判別して、処理をS408へ進める。一方、図8に示されたように、コメントキーワード挿入位置設定画面30の第1のチェックボックス31がチェックされていなかった場合には、CPU11は、コメントキーワードを挿入しないものと判別して、処理をS402へ戻す。
【0072】
S408では、CPU11は、項番テーブルを更新し、コメントキーワードを生成してコメント文中に挿入する。この項番テーブルの更新は、ネスト番号に基づいてなされる。即ち、CPU11は、処理対象レコードのネスト番号を参照し、このネスト番号に対応するフィールドの値を1増加させる。このため、図20の構文テーブルにおける最初のレコードが処理対象レコードである場合には、このレコードのネスト番号が1であるため、項番テーブルにおける1番目のフィールドが、インクリメントされる。即ち、この場合には、項番テーブルの値は“0;0;0”から“1;0;0”に更新される。
【0073】
なお、更新されたフィールドよりも後のフィールドは、0にリセットされる。例えば、更新前の項番テーブルの値が“2;1;1”であって、処理対象レコードのネスト番号が1である場合には、この項番テーブルの値は、“3;0;0”に更新される。
【0074】
そのうえで、CPU11は、更新された項番テーブルの値からコメントキーワードを生成する。例えば、項番テーブルの値が“2;1;1”であれば、コメントキーワードは、“2.1.1)”として生成される。但し、このコメントキーワードは、項番テーブルの各フィールドのうちのその値が0でないもののみに基づいて、生成される。このため、項番テーブルの値が“1;0;0”であれば、コメントキーワードは、“1)”として生成される。
【0075】
さらに、CPU11は、生成したコメントキーワードを、処理対象のレコードのコメント文の“//”の直後に挿入する。例えば、図20の構文テーブルにおける先頭のレコードの文は、“//変数の初期化を行う”から“//1)変数の初期化を行う”になる。
【0076】
一方、S409は、処理対象レコードの文の種類がコメント文以外である場合(S404;No)の処理である。このため、文の種類は、順次文,繰返し文,判定文,又は分岐文である。
【0077】
このS409では、CPU11は、処理対象のレコードの文に対応するコメント文が不足しているかどうか、判別する。即ち、CPU11は、処理対象のレコードの直前のレコードにおける文の種類が、コメント文である場合には、コメント文が不足していないと判別して、処理をS402へ戻す。なお、処理対象のレコード及び直前のレコードにおける文の種類が、いずれも順次文である場合にも、CPU11は、コメント文が不足していないと判別して、処理をS402へ戻す。一方、それ以外の場合には、CPU11は、コメント文が不足していると判別して、処理をS410へ進める。
【0078】
S410では、CPU11は、指定箇所にコメントキーワードを挿入する設定がなされているかどうか判別する。図6に示されたように、コメントキーワード挿入位置設定画面30の第2のチェックボックス32がチェックされていなければ、CPU11は、コメントキーワードを挿入しないものと判別して、処理をS402へ戻す。一方、図8又は図10に示されたように、コメントキーワード挿入位置設定画面30の第2のチェックボックス32がチェックされていた場合には、CPU11は、コメントキーワードを挿入するものと判別して、処理をS411へ進める。
【0079】
但し、コメントキーワード挿入位置設定画面30の第2のチェックボックス32がチェックされていたとしても、以下の3つの場合には、CPU11は、処理をS402へ戻す。第1に、処理対象レコードの文の種類が順次文であるときに、第3のチェックボックス33がチェックされていない場合。第2に、処理対象レコードの文の種類が繰返し文又は判定文であるときに、第4のチェックボックス34がチェックされていない場合。第3に、処理対象レコードの文の種類が分岐文であるときに、第5のチェックボックス35がチェックされていない場合。
【0080】
S411では、CPU11は、構文テーブルにおける処理対象レコードと該処理対象レコードの直前のレコードとの間に、新たなレコードを追加する。この追加されるレコードは、その文の種類がコメント文として設定される。また、この追加されるレコードは、そのネスト番号が、処理対象レコードの直前のレコードのネスト番号と同じ値に、設定される。また、この追加されるレコードの文は、内容のない空のコメント文として“//”のみが設定される。そして、CPU11は、追加した新しいレコードを、上記処理対象レコードの代わりに、処理対象レコードとする。
【0081】
例えば、図20の構文テーブルにおいて、処理対象レコードが“if(c=='\n') ”の文を含むレコードである場合には、このレコードと、“while((c=getchar()) !=EOF)”の文を含むレコードとの間に、新たなレコードが追加される。そして、この追加されたレコードが、処理対象レコードになる。
【0082】
次のS412では、CPU11は、S408の場合と同様に、項番テーブルを更新し、コメントキーワードを生成してコメント文に挿入する。なお、処理対象レコードは、S411で追加された新たなレコードであるため、そのコメント文は、内容のない空のコメント文として“//”のみを含んでいる。このため、例えば、生成されたコメントキーワードが“2.1)”であれば、このコメント文は、“//”から“//2.1)”になる。そのうえで、CPU11は、処理をS402へ戻す。
【0083】
この図19のフローチャートの処理がなされることにより、そのS401の処理で図20の構文テーブルが得られた場合には、S402以降の処理により、図21の構文テーブルが得られる。なお、上記の例では、ソースコード中に含まれる関数が1つのみであった。これに対し、ソースコード中に、関数が複数含まれている場合には、CPU11は、図19のフローチャートによる処理を各関数に対応させて繰り返せばよい。
【0084】
以下、この図19のフローチャートにおいて、説明を省略したS406の処理について、図22のソースコードを参照して、説明する。この図22のソースコードは、図3のフローチャートに従って一度処理された後に、オペレータによりさらに変更が加えられたものである。このため、図22のソースコードは、コメントキーワードを不完全な状態で含んでいる。即ち、コメントキーワードが部分的に不足しているだけでなく、付与されたコメントキーワードの番号体系に乱れがある。
【0085】
この図22のソースコードに対して、S401の処理がなされると、図23に示される構文テーブルが、作成される。そして、S401の直後の第1回目のS402においては、構文テーブルに未処理のレコードがあるので、処理はS403へ進む。S403では、“//2)変数の初期化を行う”の文を含む先頭のレコードが、処理対象レコードとして取得される。次のS404では、この処理対象レコードの文の種類がコメント文であるので、処理はS405へ進む。S405において、処理対象レコードの文にコメントキーワードが含まれているので、処理はS406へ進む。
【0086】
S406では、CPU11は、項番テーブルを更新し、コメントキーワードを生成して、コメント文中に既に設定されたコメントキーワードをリナンバする。なお、初期状態における項番テーブルは、“0;0;0”であり、処理対象のレコードのネスト番号は1であるので、この項番テーブルは、“1;0;0”に更新される。このため、生成されるコメントキーワードは、“1)”になる。そして、CPU11は、生成したコメントキーワード“1)”を、処理対象レコードのコメント文“//2)変数の初期化を行う”中の“2)”の部分と置換することにより、コメントキーワードをリナンバする。リナンバ後の処理対象レコードのコメント文は、“//1)変数の初期化を行う”になる。
【0087】
同様にして、このS406において、処理対象レコードが“//3)ファイルの終端を検出するまで行数を数える”の文を含むレコードである場合には、この文は、S406の処理により、“//2)ファイルの終端を検出するまで行数を数える”になる。同様に、処理対象レコードが“//6)行数を画面に表示する”の文を含むレコードである場合には、この文は、S406の処理により、“//3)行数を画面に表示する”になる。
【0088】
このため、S401において図23の構文テーブルが得られた場合にも、S402以降の処理により、図21の構文テーブルが得られる。この図19のフローチャートにおいて、CPU11は、元になるソースコードが不適切なコメントキーワードを含んでいたとしても、そのコメントキーワードをリナンバすることにより、正しいコメントキーワードが付された構文テーブルを得ることができる。
【0089】
以下、上述した図3のフローチャートにおけるS5の処理について、図24のフローチャートを参照してさらに説明する。なお、この図24において、CPU11は、構文テーブルを、その先頭のレコードから1レコードずつ順次処理して行く。但し、この図24のフローチャート開始前の状態において、図3のS4において更新された構文テーブル(図21)の各レコードは全て未処理であり、処理済のレコードはまだ存在しない。
【0090】
この図24のフローチャート開始後の最初のS501では、CPU11は、構文テーブルに未処理のレコードがあるかどうか、判別する。そして、CPU11は、未処理のレコードがあれば処理をS502へ進め、未処理のレコードがなければ処理を終了させる。
【0091】
S502では、CPU11は、構文テーブルにおける未処理のレコードのうちの先頭の1レコードを、処理対象レコードとして取り出す。
【0092】
次のS503では、CPU11は、処理対象レコードの文の種類が、コメント文であるかどうか判別する。そして、CPU11は、この文の種類がコメント文である場合には、処理をS504へ進め、それ以外の場合には、処理をS501へ戻す。
【0093】
S504では、CPU11は、処理対象レコードの文(コメント文)が、コメントキーワードを含んでいるかどうか、判別する。そして、CPU11は、コメントキーワードが含まれている場合には、処理をS505へ進め、コメントキーワードが含まれていない場合には、処理をS501へ戻す。なお、図21の構文テーブルにおける各コメント文は、いずれもコメントキーワードを含んでいる。
【0094】
S505では、CPU11は、処理対象レコードの文(コメント文)を、コメントデータベースに格納する。なお、図3のフローチャートのS1において作成されたコメントデータベースは、図4に示されるように、その機能説明に対応するコメントフィールドが空欄になっている。このS505において、CPU11は、処理対象レコードのコメント文を、コメントデータベースの機能説明に対応するコメントフィールドに格納する。そして、CPU11は、処理をS501へ戻す。
【0095】
この図24のフローチャート(図3のS5)の処理が完了すると、図4のコメントデータベースは、図14に示された状態に、更新される。なお、図3のS6において、この図14のコメントデータベースは、図17に示された状態に、さらに更新される。
【0096】
以下、図3のフローチャートにおけるS9の処理について、図25のフローチャートを参照してさらに説明する。なお、図25のフローチャートにおいて、CPU11は、構文テーブル(図21)を、その先頭のレコードから1レコードずつ順次処理して行く。但し、この図25のフローチャート開始前の状態において、構文テーブルの各レコードは全て未処理であり、処理済のレコードはまだ存在しない。
【0097】
この図25のフローチャート開始後の最初のS901では、CPU11は、構文テーブルに未処理のレコードがあるかどうか、判別する。そして、CPU11は、未処理のレコードがあれば処理をS902へ進め、未処理のレコードがなければ処理を終了させる。
【0098】
S902では、CPU11は、構文テーブルにおける未処理のレコードのうちの先頭の1レコードを、処理対象レコードとして取り出す。
【0099】
次のS903では、CPU11は、処理対象レコードの文の種類が、コメント文であるかどうか判別する。そして、CPU11は、この文の種類がコメント文である場合には、処理をS904へ進め、それ以外の場合には、処理をS901へ戻す。
【0100】
S904では、CPU11は、処理対象レコードの文(コメント文)が、コメントキーワードを含んでいるかどうか、判別する。そして、CPU11は、コメントキーワードが含まれている場合には、処理をS905へ進め、コメントキーワードが含まれていない場合には、処理をS901へ戻す。なお、図21の構文テーブルにおける各コメント文は、いずれもコメントキーワードを含んでいる。
【0101】
S905では、CPU11は、処理対象レコードのコメント文に含まれるコメントキーワードが、S6において処理したコメントデータベース(図17)の機能説明に対応するコメントフィールド中に、含まれているかどうかを判別する。そして、CPU11は、このコメントキーワードが含まれている場合には、当該コメントキーワードを処理対象コメントキーワードとして処理をS906へ進める。一方、CPU11は、このコメントキーワードが含まれていない場合には、処理をS901へ戻す。
【0102】
S906では、CPU11は、コメントデータベースに基づいてソースコードを更新する。まず、CPU11は、コメントデータベース(図17)の機能説明に対応するコメントフィード内に格納されたコメント文のうち、処理対象コメントキーワードを含む文を抽出する。そして、CPU11は、ソースコード(図13)のコメント文のうちの処理対象コメントキーワードを含むものを特定する。そのうえで、CPU11は、ソースコードにおける特定したコメント文を、コメントデータベースから抽出したコメント文で、置き換える。
【0103】
この図25のフローチャート(図3のS9)の処理により、図3のS6において処理されたコメントデータベース(図17)の機能説明に対応するコメントフィールドの内容が、ソースコードに反映される。即ち、図13のソースコードは、図17のコメントデータベースに基づき、図18のソースコードに変換される。
【0104】
上述の本実施形態による仕様書作成装置は、ソースコードから、第1種のコメント文だけでなく第2種のコメント文をも抽出して、自動的に仕様書を作成することができる。自動的に作成された仕様書は、第1種のコメント文だけが含まれた仕様書に比べて、その記載内容が充実しているので、オペレータによる編集作業が省力化される。
【0105】
さらに、この仕様書作成装置は、仕様書の編集作業における変更点を、ソースコードへ反映させることができる。即ち、第1種のコメント文に関する変更点だけでなく、第2種のコメント文に関する変更点も、ソースコードへ反映される。
【0106】
なお、第2種のコメント文のソースコードへの反映は、コメントキーワードに基づいてなされる。このため、自動作成された仕様書が編集中であったとしても、オペレータは、コメントキーワードを変更しない範囲で、ソースコードを更新することができる。そして、仕様書作成装置は、更新されたソースコードへも、仕様書の編集による変更点を、反映させることができる。このため、オペレータの作業上の制約が少なくなり、開発効率が向上する。
【0107】
(付記1)入力装置及び表示装置に接続されるとともにプログラムに従った処理を実行する処理装置に対して、ソースコード中のコメント文が配置されるべき位置に、一意的に識別可能なコメントキーワードを含んだコメント文を配置させ、前記コメントキーワードを含んだコメント文を抽出して仕様書データを作成させ、前記仕様書データを前記表示装置に表示させ、前記入力装置を介して当該表示内容を変更する旨の指示がなされた場合には、この指示に従って、前記仕様書データ中のコメント文の内容を変更させ、前記ソースコード中のコメント文を、前記仕様書データ中のコメント文のうちのコメントキーワードが一致するもので置き換えさせる仕様書作成プログラムを格納したコンピュータ可読媒体。
【0108】
(付記2)前記仕様書作成プログラムは、前記処理装置に対して、ソースコード中の処理手続を有する集合体内に記載されるべきコメント文を、処理対象とさせることを特徴とする付記1記載のコンピュータ可読媒体。
【0109】
(付記3)前記仕様書作成プログラムは、前記処理装置に対して、既にソースコード中に含まれたコメント文中に、コメントキーワードを挿入させることを特徴とする付記1又は2記載のコンピュータ可読媒体。
【0110】
(付記4)前記仕様書作成プログラムは、前記処理装置に対して、ソースコード中の連続する順次文のうちの先頭のもの,連続しない順次文,繰返し文,判定文,及び分岐文から選択された文の近傍の位置を、コメント文が配置されるべき位置とさせることを特徴とする付記1〜3のいずれかに記載のコンピュータ可読媒体。
【0111】
(付記5)入力装置及び表示装置に接続されるとともにプログラムに従った処理を実行する処理装置に対して、ソースコード中のコメント文が配置されるべき位置に、一意的に識別可能なコメントキーワードを含んだコメント文を配置させ、前記コメントキーワードを含んだコメント文を抽出して仕様書データを作成させ、前記仕様書データを前記表示装置に表示させ、前記入力装置を介して当該表示内容を変更する旨の指示がなされた場合には、この指示に従って、前記仕様書データ中のコメント文の内容を変更させ、前記ソースコード中のコメント文を、前記仕様書データ中のコメント文のうちのコメントキーワードが一致するもので置き換えさせる仕様書作成方法。
【0112】
(付記6)所定のプログラミング言語により記述されたソースコード中のコメント文を抽出して仕様書データを作成する仕様書作成装置であって、入力装置と、情報を表示する表示装置と、プログラムを読み込むことによって、このプログラムに従った処理を実行する処理装置と、前記処理装置に対して、ソースコード中のコメント文が配置されるべき位置に、一意的に識別可能なコメントキーワードを含んだコメント文を配置させ、前記コメントキーワードを含んだコメント文を抽出して仕様書データを作成させ、前記仕様書データを前記表示装置に表示させ、前記入力装置を介して当該表示内容を変更する旨の指示がなされた場合には、この指示に従って、前記仕様書データ中のコメント文の内容を変更させ、前記ソースコード中のコメント文を、前記仕様書データ中のコメント文のうちのコメントキーワードが一致するもので置き換えさせる仕様書作成プログラムを格納した記憶媒体とを備えたことを特徴とする仕様書作成装置。
【0113】
【発明の効果】
以上のように構成された本発明の仕様書作成プログラム及び仕様書作成プログラムを格納したコンピュータ可読媒体によれば、ソースコードのコメント文は、コメントキーワードにより管理される。このため、ソースコードのコメント文を含んだ仕様書データが編集により変更されたとしても、ソースコードのコメント文には、このコメントキーワードに基づいて、当該変更点が反映される。このため、ソースコード中における処理手続を有する集合体内に記載されるコメント文が処理対象であったとしても、このコメント文には、仕様書の編集による変更点が反映される。
【図面の簡単な説明】
【図1】 仕様書作成装置のハードウェア構成図
【図2】 ソースコード例を示す図
【図3】 仕様書作成処理を示すフローチャート
【図4】 コメントデータベースの内容を模式的に示す図
【図5】 コメントキーワード形式設定画面例を示す図
【図6】 コメントキーワード挿入位置設定画面例を示す図
【図7】 ソースコード例を示す図
【図8】 コメントキーワード挿入位置設定画面例を示す図
【図9】 ソースコード例を示す図
【図10】 コメントキーワード挿入位置設定画面例を示す図
【図11】 ソースコード例を示す図
【図12】 ソースコード例を示す図
【図13】 ソースコード例を示す図
【図14】 コメントデータベースの内容を模式的に示す図
【図15】 編集画面例を示す図
【図16】 編集画面例を示す図
【図17】 コメントデータベースの内容を模式的に示す図
【図18】 ソースコード例を示す図
【図19】 図3におけるS4の処理を示すフローチャート
【図20】 構文テーブルの内容を模式的に示す図
【図21】 構文テーブルの内容を模式的に示す図
【図22】 ソースコード例を示す図
【図23】 構文テーブルの内容を模式的に示す図
【図24】 図3におけるS5の処理を示すフローチャート
【図25】 図3におけるS9の処理を示すフローチャート
【符号の説明】
11 CPU
12 RAM
13 HDD
15 ディスプレイ
16 キーボード
17 マウス
18 プリンタ
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a specification creation program for creating specification data based on source code described in various programming languages, and a computer-readable medium storing the specification creation program.
[0002]
[Prior art]
In general, in a source code written in C ++ or another programming language, a comment sentence that is not converted into an object code even if it is compiled is included. In general, the comment text includes a description of the processing contents of the program. For this reason, when the comment sentence is extracted from the source code, an explanation about the processing content of the program is obtained.
[0003]
Therefore, a specification creation apparatus that automatically creates a specification for the program by extracting a comment sentence from the source code is used. In addition to the function to extract the comment text from the source code and create the specification, this specification creation device has a function that allows the operator to edit the created specification and the contents of the edited specification It has a function to reflect on.
[0004]
Usually, the source code includes a plurality of “aggregates”. For example, when the source code is described in C ++, classes, member functions, external functions, external variables, and the like correspond to the aggregate. In particular, functions (member functions and external functions) of these aggregates are referred to as “aggregates having processing procedures” because the processing procedures are described therein.
[0005]
Note that the comment text includes a comment text (first type comment text) described immediately before the aggregate and a comment text (second type comment) described in the processing procedure in the aggregate having a processing procedure. Sentence). A conventional specification creation device automatically creates a specification by extracting the first type comment text from the source code. Then, the operator edits the created specification by operating this specification creation device. That is, the operator inputs an incomplete point or changes an inappropriate description to the automatically created specification.
[0006]
Further, the specification creation device reflects the changed points in the changed specification in the original source code. That is, the specification creation device converts the content of the updated specification into a comment text format, and places the converted comment text (first type comment text) immediately before the aggregate corresponding to the comment text. By replacing the old comment text before the change, the changes made by editing are reflected in the source code.
[0007]
[Problems to be solved by the invention]
The above-described prior art specification creation apparatus does not process the second type comment text. If it is assumed that the specification creating apparatus also handles the second type of comment text, there are the following problems. That is, this specification creation device extracts the first type comment text and the second type comment text from the source code and creates the specification text. There is a problem that it is not possible to reflect in the original source code what corresponds to the second type comment text. This is because this specification creation device cannot recognize where in the assembly (function) having the processing procedure the change regarding the second type comment text should be inserted.
[0008]
In order for the changes in the specifications related to this type 2 comment statement to be reflected in the source code, the specification creation device makes the change based on the absolute position of the description line number in the source code. It is also conceivable to insert points into the function. However, in this case, the source code must not be changed at all after the specification is automatically created and before the edited specification changes are reflected in the source code. That is, during this period, the operator cannot correct the source code. For this reason, development efficiency will fall.
[0009]
Therefore, the conventional specification creation apparatus has processed only the first type comment text. That is, the conventional specification creation apparatus has extracted the first type comment text from the source code and created the specification.
[0010]
However, the specification created based only on the first type comment text does not have enough description. Accordingly, it is an object of the present invention to provide a specification creation device, a specification creation program, and a computer readable medium storing the specification creation program that can handle the second type comment text as a processing target. To do.
[0011]
[Means for Solving the Problems]
In order to solve the above problems, the present invention employs the following configuration.
[0012]
That is, the specification creation device of the present invention includes an input device, a display device, a processing device that executes processing according to a program, and a storage medium that stores the specification creation program, and is a source to be processed. Extract comment text from the code and create specification data.
[0013]
This specification creation program places a comment sentence including a unique comment keyword at the position where the comment sentence in the source code is to be placed on the processing device, extracts the comment sentence, and stores the specification data. If the instruction to change the display contents is given via the input device, the contents of the comment text in the specification data are in accordance with this instruction. And the comment text in the source code is replaced with the one that matches the comment keyword in the comment text in the specification data.
[0014]
If comprised in this way, the comment sentence in a source code will contain the comment keyword which can be identified uniquely. Each of these comment sentences is individually managed by the comment keyword. For this reason, when each of these comment texts is extracted to create specification data, and this specification data is edited by the operator, the changes in the specification data are based on the comment keyword in the source code. It is reflected in the comment sentence of.
[0015]
The comment text in the source code is classified into those described immediately before the aggregate (first type comment) and those described in the aggregate having a processing procedure (second type comment). . Then, only the second type comment may be managed by the comment keyword. However, the present invention is not limited to this, and the first type comments may be managed by comment keywords.
[0016]
The source code is described in C ++, C, BASIC, Java (trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries), FORTRAN, PASCAL, COBOL, or other programming languages.
[0017]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, a specification creation apparatus according to an embodiment of the present invention will be described with reference to the drawings. The specification creation apparatus may be configured by installing software for executing processing to be described later on a computer such as a personal computer or a workstation.
[0018]
FIG. 1 is a hardware configuration diagram of the specification creation apparatus. As shown in FIG. 1, the specification creation apparatus includes a CPU 11, a RAM 12, an HDD 13, a CD-ROM drive 14, a display 15, a keyboard 16, a mouse 17, and the like connected to each other via a bus and an interface (not shown). And a printer 18.
[0019]
The CPU 11 is a processing device that performs predetermined processing by executing various programs. The RAM 12 can store data. Then, the CPU 11 develops various programs and various tables on the RAM 12.
[0020]
An HDD (Hard Disk Drive) 13 includes a plurality of disks that can hold information magnetically, and a magnetic head that reads and writes data from and to each disk. The CPU 11 controls the HDD 13 to read / write data from / to each disk. The HDD 13 corresponds to a storage medium and a computer readable medium.
[0021]
The CD-ROM drive 14 has a slot for detachably loading a CD-ROM and an optical head for reading data from the CD-ROM. Then, the CPU 11 reads the data in the loaded CD-ROM by controlling the CD-ROM drive 4.
[0022]
The display 15 is composed of a CRT, LCD, or the like, and displays image data and character data on the screen. Then, the CPU 11 controls the display 15 to display the image data and the character data on the screen. The display 15 corresponds to a display device.
[0023]
The keyboard 16 is used for allowing an operator to input a character code. The mouse 17 is a pointing device that allows the operator to specify a position in the virtual space corresponding to a predetermined area on the display 15. The CPU 11 acquires inputs from the keyboard 16 and the mouse 17. The keyboard 16 and the mouse 17 correspond to input devices.
[0024]
The printer 18 is a device that prints characters and images on various media such as paper. The CPU 11 prints these data by transmitting character data and image data to the printer 18.
[0025]
The HDD 13 is preinstalled with software such as an operating system and application programs. This software may be distributed in a state written in a CD-ROM. In this case, this software is installed in the HDD 13 via the CD-ROM drive 14.
[0026]
The operating system includes a kernel for system management and a window system that provides a GUI. The CPU 11 operates according to the code of the operating system in a state where at least a part of the operating system is expanded on the RAM 12.
[0027]
The application program is a program that realizes predetermined processing by calling a function of the operating system via an API provided by the operating system. Then, the CPU 11 executes this application program while the operating system is operating. More specifically, this application program includes a software development environment having an editor and a compiler, and a specification creation program.
[0028]
The operator develops software by describing the source code using an editor. The described source code is stored in the HDD 13. FIG. 2 is a diagram illustrating an example of source code described in the C ++ language.
[0029]
In FIG. 2, the line beginning with “//” is a comment sentence. This comment sentence includes the first type comment sentence described immediately before the “aggregate” and the second type of comment described in the “procedure having the process procedure” (function). It is classified as a comment sentence.
[0030]
In the example of FIG. 2, since “int getline ()” and subsequent lines on the seventh line are aggregates (functions), the first to sixth lines are the first type comment statements. That is, “// Summary”, “// Determine the number of lines in the file”, “// Return value”, “// Number of lines in the file”, “// Parameter description”, and “// None” The first type of comment text.
[0031]
The first type comment text is described according to a predetermined description method. According to this description method, when creating a function program (source code), the operator must always describe the description of each item of the “Summary”, “Return value”, and “Parameter description” for the function. It is stipulated to do. Further, it is stipulated that the description of each item is described immediately after each comment sentence of “// Summary”, “// Return value”, and “// Parameter description”.
[0032]
In FIG. 2, the ninth, twelfth, and sixteenth lines are the second type comment text because they are described in the function. In other words, “// variable initialization”, “// count the number of lines until the end of the file is detected”, and “// display the number of lines on the screen” are the second type of comment text. is there.
[0033]
The specification creation program is a program for creating a specification corresponding to the source code based on such source code. Hereinafter, the processing of the CPU 11 that executes this specification creation program will be outlined with reference to the flowchart of FIG. In the first S1 after the start of the flowchart of FIG. 3, the CPU 11 extracts the first type comment sentence from the source code and creates the comment database shown below.
[0034]
FIG. 4 is a diagram schematically showing the contents of the comment database for the aggregate (getline function) in the source code of FIG. In this comment database, “Summary”, “Return value”, “Parameter description”, and “Function description” are set as comment items. In the comment database, a plurality of comment fields (“comment” column in FIG. 4) corresponding to the respective comment items are set. The comment database corresponds to specification data.
[0035]
As shown in FIG. 4, “// the number of lines in the file” next to “// summary” in the first type comment text in the source code of FIG. Stored in the comment field. Similarly, “// number of lines in file” next to “// return value” is stored in the comment field as a comment sentence corresponding to the return value. Similarly, “// none” next to “// parameter description” is stored in the comment field as a comment text corresponding to the parameter description. Note that the comment field corresponding to the function description is extracted from the second type comment text in the process described later, and is blank at this point.
[0036]
In the next S2, the CPU 11 displays the comment keyword format setting screen 20 shown in FIG. The operator inputs a comment keyword format to be described later via the keyboard 16 in the first keyword column 21 of the comment keyword format setting screen 20. In the example of FIG. 5, “*. *)” Is input as the comment keyword format. In this state, the operator clicks the button 22 with the mouse 17 to set the comment keyword format to “*. *)”.
[0037]
This “*. *)” Schematically indicates a format prescribed in advance in the specification program. More specifically, “*. *)” Means an item number that can be expressed hierarchically, such as “1”, “1.2”, “2.3.5”, and the like. As will be described later, the specification program manages each comment sentence by assigning a comment keyword uniquely associated with the comment sentence to each of the second type comment sentences.
[0038]
In the next S3, the CPU 11 displays the comment keyword insertion position setting screen 30 shown in FIG. The operator determines the comment keyword setting position while viewing the comment keyword insertion position setting screen 30. The comment keyword insertion position setting screen 30 includes a pair of check boxes 31 and 32. FIG. 6 shows a state where the operator operates the mouse 17 and checks only the first check box 31. When the first check box 31 is checked, a comment keyword is inserted in the processing described later in the second type comment sentence already described in the source code. The setting shown in FIG. 6 is made when processing a source code in which all necessary comment sentences are described as shown in FIG.
[0039]
On the other hand, FIG. 8 shows a state in which the operator operates only the second check box 32 by operating the mouse 17. When the second check box 32 is checked, a comment keyword is inserted at a predetermined designated position in the function in the processing described later. The setting shown in FIG. 8 is performed when a source code in which no second type comment is described as shown in FIG. 9 is to be processed.
[0040]
As shown in FIG. 8, when the second check box 32 is checked, three check boxes 33, 34, and 35 are newly displayed. Each of these check boxes 33, 34, and 35 is for specifying a designated portion.
[0041]
When the third check box 33 is checked, a sequential sentence is specified as a designated place (however, when sequential sentences are consecutive, only the first sequential sentence is specified as a designated place. ). That is, the beginning of a continuous sequential sentence and a non-continuous sequential sentence (single sequential sentence) are specified as designated portions. When the fourth check box 34 is checked, a repetitive sentence and a judgment sentence such as for, do, while, and if are specified as the designated portion. When the fifth check box 35 is checked, a branch sentence such as return, goto, and continue is specified as the designated portion.
[0042]
FIG. 10 shows a state in which the operator operates the mouse 17 to check the first check box 31 and the second check box 32. As shown in FIG. 10, the operator can check both of these check boxes 31 and 32. In this case, the comment keyword is inserted in both the comment sentence already described in the source code and the designated portion. Note that, as shown in FIG. 2, although some second type comment statements are described, if the description is insufficient, the setting shown in FIG. 10 is made.
[0043]
Then, the operator operates the mouse 17 and clicks the button 36 on the comment keyword insertion position setting screen 30 shown in FIG. 6, FIG. 8, or FIG. Determine the set contents.
[0044]
In next S4, the CPU 11 inserts a comment keyword into the source code. This comment keyword is inserted at the position set in S3. If the setting is made as shown in FIG. 6 in S3, the comment keyword is inserted in the comment sentence already described in the source code in S4. That is, the source code of FIG. 7 is converted as shown in FIG.
[0045]
On the other hand, if the setting is made as shown in FIG. 8 (S3), the comment keyword is inserted at the designated location in S4. That is, the source code of FIG. 9 is converted as shown in FIG. As shown in FIG. 12, the comment keyword is inserted at a position where no comment sentence exists in FIG.
[0046]
If the setting is made as shown in FIG. 10 (S3), then in S4, the comment keyword is inserted into both the comment sentence already described in the source code and the designated portion. That is, the source code of FIG. 2 is converted as shown in FIG. The process of S4 will be described in detail later.
[0047]
In the next S5, the CPU 11 extracts the second type comment from the source code and stores it in the comment database. For example, from the source code of FIG. 13, “// 1) initialize variables”, “// 2) count the number of lines until the end of the file is detected”, “//2.1)”, “//2.1.1)”, “// 3) Display the number of lines on the screen”, and “// 4)” are extracted. Each of these comment texts includes the comment keyword inserted in S4. Each extracted comment sentence is stored in the comment field corresponding to the function description of the comment database (FIG. 4). FIG. 14 is a diagram schematically showing the contents of the comment database in a state where these comment sentences are stored. The process of S5 will be described later in detail.
[0048]
In the next S6, the CPU 11 displays the editing screen 40 shown in FIG. The operator edits the contents of the specification by operating the keyboard 16 while viewing the editing screen 40. Further, the CPU 11 reflects the contents of the edited specification in the comment database.
[0049]
As shown in FIG. 15, the editing screen 40 includes four editing fields 41 to 44. In each of these edit fields 41 to 44, the contents of the comment database shown in FIG. 14 are displayed.
[0050]
In the first editing field 41, the content of the comment field corresponding to the comment database summary “determining the number of lines in the file” is displayed. In the second edit field 42, the content of the comment field corresponding to the return value of the comment database “number of lines in the file” is displayed. In the third edit field 43, the content “none” of the comment field corresponding to the parameter description of the comment database is displayed. The contents displayed in the first to third edit fields 41 to 43 are extracted from the first type comment text.
[0051]
In the fourth edit field 44, the content of the comment field corresponding to the function description of the comment database is displayed. That is, “1) Initialize variables”, “2) Count the number of lines until the end of the file is detected”, “2.1)”, “2.1.1)”, “3) Number of lines Are displayed on the screen ", and" 4) "are displayed. The content displayed in the fourth edit field 44 is extracted from the second type comment text.
[0052]
The operator can change the contents of the edit fields 41 to 44 by moving the cursor to the edit fields 41 to 44 and operating the keyboard 16. In the example of FIG. 15, the fourth edit field 44 has an insufficient part of the description, so the operator compensates for the insufficient part. That is, the operator adds an explanatory note to the portions “2.1)”, “2, 1, 1)” and “4)”.
[0053]
FIG. 16 is an example of a screen showing the editing screen 40 after editing. As shown in FIG. 16, "2.1)", "2, 1, 1)" and "4)" in FIG. 15 are "2.1) Check for line feed character", " 2,1,1) In the case of a line feed character, it is changed to “count the number of lines” and “4) return the number of lines to the caller”.
[0054]
After the editing is completed, the CPU 11 stores the contents of the editing fields 41 to 44 in the comment database, thereby reflecting the change in the comment database. FIG. 17 is a diagram schematically showing the contents of the comment database in which the changed points are reflected.
[0055]
As shown in FIG. 17, the content of the first edit field 41 in the edit screen 40 of FIG. 16 is stored in the comment field corresponding to the outline of the comment database. Similarly, the contents of the second edit field 42 are stored in the comment field corresponding to the return value. Similarly, the contents of the third edit field 43 are stored in the comment field corresponding to the parameter description. Similarly, the content of the fourth edit field 44 is stored in the comment field corresponding to the function description.
[0056]
In the next S7, the CPU 11 causes the printer 18 to print the specification. That is, the CPU 11 causes the printer 18 to print the specifications as a specification in correspondence with the content of the comment database processed in S6 in a predetermined format. This specification may be printed in, for example, substantially the same format as the screen of FIG. Note that the content of the comment database may be converted into an HTML format, a file format of various word processing software, or a file format of various spreadsheet software, and stored in the HDD 13.
[0057]
In the next S8, the CPU 11 reflects the part related to the first type comment text in the contents of the comment database processed in S6 in the source code. In S6, when the editing screen 40 of FIG. 15 is changed as shown in FIG. 16, the contents of the first to third editing fields 41 to 43 corresponding to the first type comment are as follows. It has not been updated. In this case, since the part in the comment database does not change, the part of the first comment sentence in the source code also does not change.
[0058]
In the next S9, the CPU 11 reflects the part related to the second type comment sentence in the contents of the comment database processed in S6 in the source code. FIG. 18 is a diagram illustrating the updated source code. As shown in FIG. 18, “2.1)”, “2, 1, 1)”, and “4)” in FIG. “2, 1, 1) In the case of a line feed character, it is changed to“ count the number of lines ”and“ 4) return the number of lines to the caller ”. The process of S9 will be described later in detail.
[0059]
Hereinafter, the process of S4 in the flowchart of FIG. 3 will be further described with reference to FIG. The flowchart of FIG. 19 starts after the CPU 11 opens the source code stored in the HDD 13 and performs a process of reading up to the start of the function.
[0060]
In the first step S401 after the start of the flowchart of FIG. 19, the CPU 11 reads and analyzes the source code up to the last part of the function to be processed, and creates a syntax table. That is, the CPU 11 determines the type of sentence for each line of the source code and also determines the depth of nesting in the logical structure of the programming language. The depth of this nest is represented by a nest number (natural number). In this nest number, 1 corresponds to the shallowest nest. The nest number increases by 1 as the nest deepens step by step. A syntax table creation area is secured in the RAM 12 or the HDD 13.
[0061]
Further, the CPU 11 secures a comment keyword management item number table in the RAM 12 or the HDD 13. This item number table includes a plurality of fields capable of storing 0 or a natural number. The number of fields in this item number table matches the maximum nesting number in the source code to be processed. In the item number table, each field is set to 0 in the initial state. Hereinafter, for the sake of brevity, the number of fields in this item number table is three. In this case, the value in the initial state of the item number table is “0; 0; 0”. The first field of this item number table corresponds to nest number 1, and the next field corresponds to nest number 2. Hereinafter, similarly, each field of the item number table corresponds to each nest number.
[0062]
FIG. 20 is a schematic diagram of a syntax table based on the source code of FIG. This syntax table includes, for each line of the source code, the kind of sentence, the nesting number, and the sentence itself described in the line. That is, each record of the syntax table includes a “sentence type” field, a “nesting number” field, and a “sentence” field. Each record in the syntax table is arranged in accordance with the order in which sentences are written in the source code. FIG. 21 shows a syntax table obtained when the processing after S402 described later is performed on the syntax table of FIG.
[0063]
In FIG. 20, the first record including the sentence “// variable initialization” has the sentence type as a comment sentence and the nest number is determined to be 1. In “int c, nl;” and “nl = 0;”, it is determined that the types of sentences are sequential sentences and the nest number is 1, respectively. The next record including the sentence “count the number of lines until the end of the file is detected” has a sentence type of comment and a nesting number of 1.
[0064]
The record including the next “while ((c = getchar ())! = EOF)” statement has a statement type of a repeated statement and a nest number of 2 is determined. In other words, the CPU 11 determines that the nest has been deepened by one level according to the C ++ language structure. The record including the next sentence “if (c == '\ n')” has the sentence type determined as a determination sentence, and the nest number is determined to be 3. That is, the CPU 11 determines that the nesting is further advanced by one level according to the language structure of C ++.
[0065]
The next record including the sentence “++ nl;” has a sentence type of sequential sentence and a nesting number of 3. The next record including the sentence “// display the number of lines on the screen” has the sentence type as a comment sentence and the nest number is determined to be 1. That is, the CPU 11 determines that the nesting has become shallower by two levels according to the C ++ language structure. The next record including the sentence “printf (“% d \ n ”, nl);” has a sentence type of sequential sentence and a nest number of 1 is determined. In the record including the next “return nl;” statement, the type of the statement is a branch statement and the nest number is determined to be 1.
[0066]
In the subsequent processing, the CPU 11 sequentially processes the syntax table one record at a time from the top record. However, at this stage, all the records in the syntax table are unprocessed, and there are no processed records yet.
[0067]
In S402, the CPU 11 determines whether there is an unprocessed record in the syntax table. Then, the CPU 11 advances the process to S403 if there is an unprocessed record, and ends the process if there is no unprocessed record.
[0068]
In S403, the CPU 11 takes out the first one of the unprocessed records in the syntax table as a process target record.
[0069]
In next step S404, the CPU 11 determines whether or not the type of sentence in the processing target record is a comment sentence. Then, if the type of this sentence is a comment sentence, the CPU 11 advances the process to S405, and otherwise advances the process to S409.
[0070]
In S405, the CPU 11 determines whether the sentence (comment sentence) of the processing target record includes a comment keyword. If the comment keyword is included, the CPU 11 advances the process to S406. If the comment keyword is not included, the CPU 11 advances the process to S407. Note that each sentence in the syntax table of FIG. 20 does not include a comment keyword. For this reason, when the syntax table of FIG. 20 is processed, the process of S406 is never performed. The process of S406 will be described later using another example of the syntax table.
[0071]
In S407, the CPU 11 determines whether or not the setting for inserting the comment keyword into the comment sentence is made. As shown in FIG. 6 or FIG. 10, when the first check box 31 of the comment keyword insertion position setting screen 30 is checked, the CPU 11 determines that the comment keyword is to be inserted, and performs processing. To S408. On the other hand, as shown in FIG. 8, when the first check box 31 on the comment keyword insertion position setting screen 30 is not checked, the CPU 11 determines that no comment keyword is inserted and performs processing. To S402.
[0072]
In S408, the CPU 11 updates the item number table, generates a comment keyword, and inserts it in the comment sentence. The item number table is updated based on the nest number. That is, the CPU 11 refers to the nest number of the processing target record and increments the value of the field corresponding to this nest number by one. For this reason, when the first record in the syntax table of FIG. 20 is a process target record, since the nest number of this record is 1, the first field in the item number table is incremented. That is, in this case, the value of the item number table is updated from “0; 0; 0” to “1; 0; 0”.
[0073]
Note that fields after the updated field are reset to zero. For example, when the value of the item number table before update is “2; 1; 1” and the nesting number of the record to be processed is 1, the value of this item number table is “3; 0; 0”. Is updated.
[0074]
In addition, the CPU 11 generates a comment keyword from the updated item number table value. For example, if the value of the item number table is “2; 1; 1”, the comment keyword is generated as “2.1.1)”. However, the comment keyword is generated based on only the field whose value is not 0 among the fields of the item number table. Therefore, if the value of the item number table is “1; 0; 0”, the comment keyword is generated as “1)”.
[0075]
Further, the CPU 11 inserts the generated comment keyword immediately after “//” in the comment text of the record to be processed. For example, the sentence of the first record in the syntax table of FIG. 20 changes from “// initialize variable” to “// 1) initialize variable”.
[0076]
On the other hand, S409 is processing when the type of sentence of the processing target record is other than a comment sentence (S404; No). Therefore, the type of sentence is a sequential sentence, a repeated sentence, a judgment sentence, or a branch sentence.
[0077]
In S409, the CPU 11 determines whether or not the comment sentence corresponding to the sentence of the record to be processed is insufficient. That is, if the type of sentence in the record immediately before the record to be processed is a comment sentence, the CPU 11 determines that the comment sentence is not insufficient, and returns the process to S402. Note that even when the types of sentences in the record to be processed and the immediately preceding record are both sequential sentences, the CPU 11 determines that the comment sentence is not insufficient and returns the process to S402. On the other hand, in other cases, the CPU 11 determines that the comment text is insufficient, and advances the processing to S410.
[0078]
In S410, the CPU 11 determines whether or not the setting for inserting the comment keyword at the designated location is made. As shown in FIG. 6, if the second check box 32 on the comment keyword insertion position setting screen 30 is not checked, the CPU 11 determines that no comment keyword is inserted, and returns the process to S402. On the other hand, as shown in FIG. 8 or 10, when the second check box 32 of the comment keyword insertion position setting screen 30 is checked, the CPU 11 determines that the comment keyword is to be inserted. , The process proceeds to S411.
[0079]
However, even if the second check box 32 of the comment keyword insertion position setting screen 30 is checked, the CPU 11 returns the process to S402 in the following three cases. First, the third check box 33 is not checked when the type of sentence in the processing target record is a sequential sentence. Second, the fourth check box 34 is not checked when the type of sentence in the processing target record is a repeated sentence or a judgment sentence. Third, the fifth check box 35 is not checked when the type of statement in the processing target record is a branch statement.
[0080]
In S411, the CPU 11 adds a new record between the processing target record in the syntax table and the record immediately before the processing target record. The type of sentence is set as a comment sentence for the added record. Further, this added record has its nest number set to the same value as the nest number of the record immediately before the record to be processed. Moreover, only “//” is set as an empty comment sentence with no content in the sentence of the record to be added. Then, the CPU 11 sets the added new record as a processing target record instead of the processing target record.
[0081]
For example, in the syntax table of FIG. 20, if the processing target record is a record including a statement “if (c == '\ n')”, this record and “while ((c = getchar ())) A new record is added between the records containing the statement! = EOF) ”. The added record becomes a process target record.
[0082]
In the next S412, the CPU 11 updates the item number table, generates a comment keyword, and inserts it in the comment sentence, as in S408. Since the processing target record is a new record added in S411, the comment text includes only “//” as an empty comment text with no content. Therefore, for example, if the generated comment keyword is “2.1)”, the comment sentence is changed from “//” to “//2.1)”. Then, the CPU 11 returns the process to S402.
[0083]
When the processing of the flowchart of FIG. 19 is performed and the syntax table of FIG. 20 is obtained by the processing of S401, the syntax table of FIG. 21 is obtained by the processing after S402. In the above example, the source code includes only one function. On the other hand, when a plurality of functions are included in the source code, the CPU 11 may repeat the processing according to the flowchart of FIG. 19 corresponding to each function.
[0084]
Hereinafter, with reference to the source code of FIG. 22, the process of S406, which is not described in the flowchart of FIG. 19, will be described. The source code of FIG. 22 is processed once according to the flowchart of FIG. 3 and then further modified by the operator. For this reason, the source code of FIG. 22 includes the comment keyword in an incomplete state. That is, the comment keywords are partially lacking, and the number system of the assigned comment keywords is disturbed.
[0085]
When the process of S401 is performed on the source code of FIG. 22, the syntax table shown in FIG. 23 is created. In the first S402 immediately after S401, since there is an unprocessed record in the syntax table, the process proceeds to S403. In S403, the first record including the sentence “// 2) Perform variable initialization” is acquired as the processing target record. In the next step S404, since the type of sentence in the processing target record is a comment sentence, the process proceeds to step S405. In S405, since the comment keyword is included in the sentence of the processing target record, the process proceeds to S406.
[0086]
In S406, the CPU 11 updates the item number table, generates a comment keyword, and renumbers the comment keyword already set in the comment sentence. Since the item number table in the initial state is “0; 0; 0” and the nesting number of the record to be processed is 1, this item number table is updated to “1; 0; 0”. . Therefore, the generated comment keyword is “1)”. Then, the CPU 11 replaces the generated comment keyword “1)” with the part “2)” in the comment sentence “// 2) initialize variable” of the processing target record, thereby changing the comment keyword. Renumber. The comment text of the record to be processed after renumbering is “// 1) Initialize variables”.
[0087]
Similarly, in S406, if the processing target record is a record including a sentence “// 3) count the number of lines until the end of the file is detected”, this sentence is converted into “ // 2) Count the number of lines until the end of the file is detected. Similarly, when the record to be processed is a record including a sentence “// 6) display the number of lines on the screen”, this sentence is converted into “// 3) the number of lines on the screen by the process of S406. “Display”.
[0088]
Therefore, even when the syntax table of FIG. 23 is obtained in S401, the syntax table of FIG. 21 is obtained by the processing after S402. In the flowchart of FIG. 19, even if the original source code includes an inappropriate comment keyword, the CPU 11 can obtain a syntax table with a correct comment keyword by renumbering the comment keyword. it can.
[0089]
Hereinafter, the process of S5 in the flowchart of FIG. 3 described above will be further described with reference to the flowchart of FIG. In FIG. 24, the CPU 11 sequentially processes the syntax table one record at a time from the top record. However, in the state before the start of the flowchart of FIG. 24, all the records in the syntax table (FIG. 21) updated in S4 of FIG. 3 are unprocessed, and there are no processed records yet.
[0090]
In the first step S501 after the start of the flowchart of FIG. 24, the CPU 11 determines whether there is an unprocessed record in the syntax table. If there is an unprocessed record, the CPU 11 advances the process to S502, and if there is no unprocessed record, the CPU 11 ends the process.
[0091]
In S <b> 502, the CPU 11 extracts the first record of unprocessed records in the syntax table as a process target record.
[0092]
In next step S503, the CPU 11 determines whether or not the type of sentence in the processing target record is a comment sentence. Then, if the type of this sentence is a comment sentence, the CPU 11 advances the process to S504, and otherwise returns the process to S501.
[0093]
In S504, the CPU 11 determines whether the sentence (comment sentence) of the processing target record includes a comment keyword. If the comment keyword is included, the CPU 11 advances the process to S505. If the comment keyword is not included, the CPU 11 returns the process to S501. Each comment sentence in the syntax table of FIG. 21 includes a comment keyword.
[0094]
In S505, the CPU 11 stores the sentence (comment sentence) of the processing target record in the comment database. In the comment database created in S1 of the flowchart of FIG. 3, the comment field corresponding to the function description is blank as shown in FIG. In S505, the CPU 11 stores the comment text of the processing target record in the comment field corresponding to the function description of the comment database. Then, the CPU 11 returns the process to S501.
[0095]
When the processing of the flowchart of FIG. 24 (S5 of FIG. 3) is completed, the comment database of FIG. 4 is updated to the state shown in FIG. In S6 of FIG. 3, the comment database of FIG. 14 is further updated to the state shown in FIG.
[0096]
Hereinafter, the process of S9 in the flowchart of FIG. 3 will be further described with reference to the flowchart of FIG. In the flowchart of FIG. 25, the CPU 11 sequentially processes the syntax table (FIG. 21) one by one from the top record. However, in the state before the start of the flowchart of FIG. 25, all the records in the syntax table are unprocessed, and there are no processed records yet.
[0097]
In the first step S901 after the start of the flowchart of FIG. 25, the CPU 11 determines whether there is an unprocessed record in the syntax table. If there is an unprocessed record, the CPU 11 advances the process to step S902. If there is no unprocessed record, the CPU 11 ends the process.
[0098]
In step S902, the CPU 11 extracts the first record of unprocessed records in the syntax table as a process target record.
[0099]
In next step S903, the CPU 11 determines whether or not the type of sentence in the processing target record is a comment sentence. Then, if the type of this sentence is a comment sentence, the CPU 11 advances the process to S904, and otherwise returns the process to S901.
[0100]
In S904, the CPU 11 determines whether the sentence (comment sentence) of the processing target record includes a comment keyword. If the comment keyword is included, the CPU 11 advances the process to step S905. If the comment keyword is not included, the CPU 11 returns the process to step S901. Each comment sentence in the syntax table of FIG. 21 includes a comment keyword.
[0101]
In S905, the CPU 11 determines whether or not the comment keyword included in the comment text of the processing target record is included in the comment field corresponding to the function description of the comment database (FIG. 17) processed in S6. If the comment keyword is included, the CPU 11 advances the processing to step S906 using the comment keyword as a processing target comment keyword. On the other hand, if the comment keyword is not included, the CPU 11 returns the process to S901.
[0102]
In S906, the CPU 11 updates the source code based on the comment database. First, the CPU 11 extracts a sentence including the processing target comment keyword from the comment sentences stored in the comment feed corresponding to the function description of the comment database (FIG. 17). Then, the CPU 11 specifies a comment including a processing target comment keyword among the comment sentences of the source code (FIG. 13). In addition, the CPU 11 replaces the specified comment sentence in the source code with a comment sentence extracted from the comment database.
[0103]
25, the content of the comment field corresponding to the functional description of the comment database (FIG. 17) processed in S6 of FIG. 3 is reflected in the source code. That is, the source code of FIG. 13 is converted into the source code of FIG. 18 based on the comment database of FIG.
[0104]
The specification creation apparatus according to the above-described embodiment can automatically create a specification by extracting not only the first type comment text but also the second type comment text from the source code. Since the automatically created specification has more detailed description than the specification containing only the first type comment text, the editing work by the operator is saved.
[0105]
Further, the specification creation device can reflect changes in the specification editing work in the source code. That is, not only the changes related to the first type comment text but also the changes related to the second type comment text are reflected in the source code.
[0106]
The reflection of the second type comment text in the source code is performed based on the comment keyword. For this reason, even if the automatically created specification is being edited, the operator can update the source code without changing the comment keyword. Then, the specification creation device can reflect the changes made by editing the specification in the updated source code. For this reason, restrictions on the work of the operator are reduced, and development efficiency is improved.
[0107]
(Supplementary Note 1) A comment keyword that is uniquely identifiable at a position where a comment sentence in the source code is to be placed with respect to a processing device that is connected to the input device and the display device and executes processing according to the program. The comment text including the comment keyword is arranged, the comment text including the comment keyword is extracted to create the specification data, the specification data is displayed on the display device, and the display content is displayed via the input device. When an instruction to change is made, in accordance with this instruction, the content of the comment text in the specification data is changed, and the comment text in the source code is changed from the comment text in the specification data. A computer-readable medium that stores a specification creation program to be replaced with one that matches a comment keyword.
[0108]
(Additional remark 2) The said specification preparation program makes the said processing apparatus make the comment sentence which should be described in the aggregate | assembly which has the process procedure in a source code be a process target. Computer readable medium.
[0109]
(Supplementary note 3) The computer-readable medium according to supplementary note 1 or 2, wherein the specification creation program causes the processing device to insert a comment keyword into a comment sentence already included in the source code.
[0110]
(Additional remark 4) The said specification preparation program is selected with respect to the said processing apparatus from the head thing of the continuous sequential sentences in a source code, a discontinuous sequential sentence, a repetition sentence, a judgment sentence, and a branch sentence. The computer-readable medium according to any one of appendices 1 to 3, wherein a position in the vicinity of the sentence is a position where the comment sentence is to be arranged.
[0111]
(Supplementary Note 5) A comment keyword that is uniquely identifiable at a position where a comment sentence in the source code is to be placed with respect to a processing device that is connected to the input device and the display device and executes processing according to the program The comment text including the comment keyword is arranged, the comment text including the comment keyword is extracted to create the specification data, the specification data is displayed on the display device, and the display content is displayed via the input device. When an instruction to change is made, in accordance with this instruction, the content of the comment text in the specification data is changed, and the comment text in the source code is changed from the comment text in the specification data. A specification creation method that replaces a comment keyword with a matching one.
[0112]
(Additional remark 6) It is the specification preparation apparatus which extracts the comment sentence in the source code described by the predetermined programming language, and produces specification data, Comprising: An input device, the display apparatus which displays information, and a program A processing device that executes processing according to this program by reading, and a comment including a comment keyword that can be uniquely identified at a position where a comment sentence in the source code is to be placed with respect to the processing device A sentence is arranged, a comment sentence including the comment keyword is extracted to create specification data, the specification data is displayed on the display device, and the display content is changed via the input device. When instructed, the content of the comment text in the specification data is changed according to this instruction, and the comment in the source code is changed. The door statement specification creation apparatus characterized by comprising a storage medium which stores a replacement makes specification creation program in what comment keyword matches of the comment sentence in the specification data.
[0113]
【The invention's effect】
According to the specification creation program of the present invention configured as described above and the computer-readable medium storing the specification creation program, the comment text of the source code is managed by the comment keyword. For this reason, even if the specification data including the comment text of the source code is changed by editing, the change point is reflected in the comment text of the source code based on the comment keyword. For this reason, even if a comment sentence described in an assembly having a processing procedure in the source code is a processing target, a change made by editing the specification is reflected in the comment sentence.
[Brief description of the drawings]
1 is a hardware configuration diagram of a specification creation device.
FIG. 2 is a diagram showing an example of source code
FIG. 3 is a flowchart showing a specification creation process.
FIG. 4 is a diagram schematically showing the contents of a comment database.
FIG. 5 shows an example of a comment keyword format setting screen.
FIG. 6 shows an example of a comment keyword insertion position setting screen.
FIG. 7 is a diagram showing an example of source code
FIG. 8 shows an example of a comment keyword insertion position setting screen.
FIG. 9 is a diagram showing an example of source code
FIG. 10 shows an example of a comment keyword insertion position setting screen.
FIG. 11 is a diagram showing an example of source code
FIG. 12 shows an example of source code
FIG. 13 shows an example of source code.
FIG. 14 is a diagram schematically showing the contents of a comment database.
FIG. 15 is a diagram showing an example of an edit screen
FIG. 16 is a diagram showing an example of an edit screen
FIG. 17 is a diagram schematically showing the contents of a comment database.
FIG. 18 shows an example of source code
FIG. 19 is a flowchart showing the process of S4 in FIG.
FIG. 20 is a diagram schematically showing the contents of a syntax table.
FIG. 21 is a diagram schematically showing the contents of a syntax table.
FIG. 22 shows an example of source code.
FIG. 23 is a diagram schematically showing the contents of a syntax table.
FIG. 24 is a flowchart showing the process of S5 in FIG.
FIG. 25 is a flowchart showing the process of S9 in FIG.
[Explanation of symbols]
11 CPU
12 RAM
13 HDD
15 display
16 keyboard
17 mouse
18 Printer

Claims (4)

入力装置及び表示装置に接続されるとともにプログラムに従った処理を実行するコンピュータを、
ソースコードを記憶する記憶手段,
前記記憶手段に記憶されたソースコード中のコメント文が配置されるべき位置に、一意的に識別可能なコメントキーワードを含んだコメント文を配置するコメント配置手段と、 前記記憶手段に記憶されたソースコードから、前記コメントキーワードを含んだコメント文を抽出して仕様書データを作成して前記記憶手段に記憶する仕様書データ作成手段と、
前記記憶手段に記憶された前記仕様書データを前記表示装置に表示させる表示手段と、
前記入力装置を介して当該表示装置に表示された仕様書データの表示内容を変更する旨の指示がなされた場合には、この指示に従って、前記記憶手段に記憶された前記仕様書データ中のコメント文の内容を変更する仕様書データ変更手段と、
前記記憶手段に記憶された前記ソースコード中のコメント文を、前記記憶手段に記憶された前記仕様書データ中のコメント文のうちのコメントキーワードが一致するもので置き換える置換手段として
機能させる仕様書作成プログラム
を格納したコンピュータ読み取り可能な記録媒体。
A computer that is connected to the input device and the display device and executes processing according to the program,
Storage means for storing source code;
Comment placement means for placing a comment sentence including a uniquely identifiable comment keyword at a position where a comment sentence in the source code stored in the storage means is to be placed; and a source stored in the storage means From the code , the comment text including the comment keyword is extracted , the specification data creating means for creating the specification data and storing it in the storage means,
Display means for causing the display device to display the specification data stored in the storage means ;
When an instruction to change the display contents of the specification data displayed on the display device is given via the input device, the comment in the specification data stored in the storage means is in accordance with this instruction. A specification data changing means for changing the content of the sentence ;
The comments in the source code stored in the storage means, as a replacement unit for comment keyword Ru replaced with a match of the comment sentence in the specification data stored in said storage means
A computer- readable recording medium that stores a specification creation program to function .
前記仕様書データ作成手段は、ソースコード中の処理手続を有する関数内に記載されコメント文を、抽出する
ことを特徴とする請求項1記載のコンピュータ読み取り可能な記録媒体。
The computer- readable recording medium according to claim 1, wherein the specification data creating means extracts a comment sentence described in a function having a processing procedure in a source code.
前記コメント配置手段は、既にソースコード中に含まれたコメント文中に、コメントキーワードを挿入する
ことを特徴とする請求項1又は2記載のコンピュータ読み取り可能な記録媒体。
The computer- readable recording medium according to claim 1 or 2 , wherein the comment placement unit inserts a comment keyword into a comment sentence already included in the source code.
入力装置及び表示装置に接続されるとともにプログラムに従った処理を実行するコンピュータを、
ソースコードを記憶する記憶手段,
前記記憶手段に記憶されたソースコード中のコメント文が配置されるべき位置に、一意的に識別可能なコメントキーワードを含んだコメント文を配置するコメント配置手段と、 前記記憶手段に記憶されたソースコードから、前記コメントキーワードを含んだコメント文を抽出して仕様書データを作成して前記記憶手段に記憶する仕様書データ作成手段と、
前記記憶手段に記憶された前記仕様書データを前記表示装置に表示させる表示手段と、
前記入力装置を介して当該表示装置に表示された仕様書データの表示内容を変更する旨の指示がなされた場合には、この指示に従って、前記記憶手段に記憶された前記仕様書データ中のコメント文の内容を変更する仕様書データ変更手段と、
前記記憶手段に記憶された前記ソースコード中のコメント文を、前記記憶手段に記憶された前記仕様書データ中のコメント文のうちのコメントキーワードが一致するもので置き換える置換手段として
機能させる仕様書作成プログラム。
A computer that is connected to the input device and the display device and executes processing according to the program,
Storage means for storing source code;
Comment placement means for placing a comment sentence including a uniquely identifiable comment keyword at a position where a comment sentence in the source code stored in the storage means is to be placed; and a source stored in the storage means From the code , the comment text including the comment keyword is extracted , the specification data creating means for creating the specification data and storing it in the storage means,
Display means for causing the display device to display the specification data stored in the storage means ;
When an instruction to change the display contents of the specification data displayed on the display device is given via the input device, the comment in the specification data stored in the storage means is in accordance with this instruction. A specification data changing means for changing the content of the sentence ;
The comments in the source code stored in the storage means, as a replacement unit for comment keyword Ru replaced with a match of the comment sentence in the specification data stored in said storage means
Specification creation program to function .
JP2001214929A 2000-09-19 2001-07-16 Specification creation program and computer-readable medium storing specification creation program Expired - Fee Related JP3933892B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2001214929A JP3933892B2 (en) 2000-09-19 2001-07-16 Specification creation program and computer-readable medium storing specification creation program

Applications Claiming Priority (3)

Application Number Priority Date Filing Date Title
JP2000-283109 2000-09-19
JP2000283109 2000-09-19
JP2001214929A JP3933892B2 (en) 2000-09-19 2001-07-16 Specification creation program and computer-readable medium storing specification creation program

Publications (2)

Publication Number Publication Date
JP2002169692A JP2002169692A (en) 2002-06-14
JP3933892B2 true JP3933892B2 (en) 2007-06-20

Family

ID=26600192

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2001214929A Expired - Fee Related JP3933892B2 (en) 2000-09-19 2001-07-16 Specification creation program and computer-readable medium storing specification creation program

Country Status (1)

Country Link
JP (1) JP3933892B2 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4972866B2 (en) 2005-03-10 2012-07-11 富士通株式会社 Conversion program
JP4579281B2 (en) * 2005-07-11 2010-11-10 有限会社アイ・アール・ディー Application document information creation apparatus, application document information creation method, and program
JP4558680B2 (en) * 2005-07-11 2010-10-06 有限会社アイ・アール・ディー Application document information creation device, explanation information extraction device, application document information creation method, explanation information extraction method
JP2009223843A (en) * 2008-03-19 2009-10-01 Nomura Research Institute Ltd Device and method for automatically generating source code of computer program
JP6519137B2 (en) * 2014-09-30 2019-05-29 富士通株式会社 Estimation program, estimation apparatus and estimation method

Also Published As

Publication number Publication date
JP2002169692A (en) 2002-06-14

Similar Documents

Publication Publication Date Title
US6951010B2 (en) Program specification generating system
US5689718A (en) System and method for processing document information using password protected icons that represent document content
US7716574B2 (en) Methods and systems for providing direct style sheet editing
US20040041818A1 (en) Design system for website text graphics
JPH0612541B2 (en) How to delete the marked part
JPH04229364A (en) Method and system for changing emphasizing characteristic
JP3933892B2 (en) Specification creation program and computer-readable medium storing specification creation program
JP3892626B2 (en) Document processing apparatus and storage medium
JP4724387B2 (en) Program conversion program, program conversion apparatus, and program conversion method
JPH08221417A (en) New/old comparing editing device for structured document
JP6121126B2 (en) Form output device, form output method, and program
US7613709B2 (en) System and method for editing operations of a text object model
JP2010157155A (en) Program creation support method, program and program creation support device
JPS63109578A (en) Processing system for logic diagram outline display
JP3417318B2 (en) Document creation management method and apparatus, and machine-readable recording medium recording program
JP2659092B2 (en) Cursor display control method in logic diagram creation processor
JP3674905B2 (en) Document editing device
JPH0612542B2 (en) How to copy the mark part of structured document
JPH05324289A (en) Device for automatically generating programming specification
JPH0954688A (en) Gui design supporting method
Arnold et al. The StatRep system for reproducible research
JP2002366880A (en) Device and method for frame editing and storage medium stored with computer-readable program
JPH0553785A (en) Linking and editing method for graphic editor and text editor
JP2021170199A (en) Information processing device, information processing system, control method thereof, and program
JPH0644237A (en) Document shaping device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20040423

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20061011

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20061107

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20070105

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: 20070313

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20070314

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

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

Free format text: PAYMENT UNTIL: 20100330

Year of fee payment: 3

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

Free format text: PAYMENT UNTIL: 20110330

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20110330

Year of fee payment: 4

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

Free format text: PAYMENT UNTIL: 20120330

Year of fee payment: 5

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

Free format text: PAYMENT UNTIL: 20130330

Year of fee payment: 6

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

Free format text: PAYMENT UNTIL: 20140330

Year of fee payment: 7

LAPS Cancellation because of no payment of annual fees