JP2008198103A - State transition diagram preparing device and state transition diagram preparing method - Google Patents

State transition diagram preparing device and state transition diagram preparing method Download PDF

Info

Publication number
JP2008198103A
JP2008198103A JP2007035113A JP2007035113A JP2008198103A JP 2008198103 A JP2008198103 A JP 2008198103A JP 2007035113 A JP2007035113 A JP 2007035113A JP 2007035113 A JP2007035113 A JP 2007035113A JP 2008198103 A JP2008198103 A JP 2008198103A
Authority
JP
Japan
Prior art keywords
state
control block
transition
list
control
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2007035113A
Other languages
Japanese (ja)
Other versions
JP4835859B2 (en
Inventor
Junichi Fukumoto
純一 福本
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NEC Corp
Original Assignee
NEC Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NEC Corp filed Critical NEC Corp
Priority to JP2007035113A priority Critical patent/JP4835859B2/en
Publication of JP2008198103A publication Critical patent/JP2008198103A/en
Application granted granted Critical
Publication of JP4835859B2 publication Critical patent/JP4835859B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To provide a state transition diagram preparing device and a state transition diagram preparing method for automatically preparing a state machine diagram from source codes. <P>SOLUTION: A list preparing means 5 analyzes the source codes A, specifies a corresponding relationship between code lines, and prepares a transition list D in which a state before transition is associated with a state after transition based on the correspondence, state declaration annotation and condition declaration annotation. The state declaration annotation indicates the state after change and is applied to a state change code line. The condition declaration annotation indicates the state before change by control and is applied to a control code line. A state machine diagram plotting means 4 prepares a state machine diagram (a state transition diagram) E based on the transition list D. <P>COPYRIGHT: (C)2008,JPO&INPIT

Description

本発明は、状態遷移図作成装置および状態遷移図作成方法に関し、特には、ソースコードから状態遷移図(ステートマシン図)を作成する状態遷移図作成装置および状態遷移図作成方法に関する。   The present invention relates to a state transition diagram creation device and a state transition diagram creation method, and more particularly to a state transition diagram creation device and a state transition diagram creation method for creating a state transition diagram (state machine diagram) from source code.

従来、ソースコードの開発の多くは、ステートマシン図を利用して行われる。「ステートマシン図」は、ステートチャート(図)および状態遷移図と同義である。   Conventionally, much source code development is performed using state machine diagrams. The “state machine diagram” is synonymous with a state chart (FIG.) And a state transition diagram.

開発者の意図(設計情報)が正確に反映されていないステートマシン図に基づいて、ソースコードが作成されると、そのソースコードに基づく処理は、設計情報と乖離し、状態遷移に不整合が生じる。開発者は、状態遷移に生じる不整合を、ソースコードを一目で見て分からない。   When source code is created based on a state machine diagram that does not accurately reflect the developer's intention (design information), the processing based on the source code deviates from the design information, and the state transition is inconsistent. Arise. Developers do not know at a glance the inconsistency that occurs in state transitions.

この問題を解決する1つの方法は、ソースコードからステートマシン図をリバースし、そのステートマシン図に基づいて仕様の誤りをチェックする方法である。「リバース」とは、開発プロセス上で、前工程の成果から後工程の成果を作る通常の作業に対して、後工程の成果から前工程の成果を作ることを表わす。   One way to solve this problem is to reverse the state machine diagram from the source code and check for specification errors based on the state machine diagram. “Reverse” means that, in the development process, the result of the previous process is created from the result of the subsequent process with respect to the normal work of creating the result of the subsequent process from the result of the previous process.

なお、特許文献1には、イベントシーケンスからステートマシン図をリバースする手順が記述されている。   Note that Patent Document 1 describes a procedure for reversing a state machine diagram from an event sequence.

また、市販されているBorland社の「Together」やチェンジビジョン社の「JUDE」といったUML(Unified Modeling Language)記法のモデル記述ツールには、ソースコードからUML記法のモデルへリバースする機能が備わっている。
特開平11−24900号公報
Also, UML (Unified Modeling Language) model description tools such as Borland's “Togetther” and ChangeVision's “JUDE” have a function of reversing the source code to the UML notation model. .
Japanese Patent Laid-Open No. 11-24900

特許文献1には、ソースコードからステートマシン図をリバースして生成するための方式や装置に関する記載はない。   Patent Document 1 does not describe a method or apparatus for generating a state machine diagram by reversing from a source code.

また、Borland社の「Together」やチェンジビジョン社の「JUDE」といったUML記法のモデル記述ツールにおいても、生成できるモデルの種類は、プログラムを構成するクラスとその関係を表わすクラス図や、できても処理の流れを表わすシーケンス図、コミュニケーション図に限られており、ソースコードから状態遷移を表わすステートマシン図をリバースするツールは存在しなかった。   In addition, in the model description tools of UML notation such as “Togetther” of Borland and “JUDE” of Change Vision, the types of models that can be generated are class diagrams that represent the classes that make up the program and their relationships. It is limited to sequence diagrams and communication diagrams representing the flow of processing, and there is no tool for reversing state machine diagrams representing state transitions from source code.

このため、開発者は、手作業で、ソースコードや設計書を解析してステートマシン図を描画するしかなく、ミスが発生したり、時間がかかるといった欠点もあった。   For this reason, the developer has to manually analyze the source code and the design document and draw the state machine diagram, and has a drawback that a mistake occurs and takes time.

本発明の目的は、ソースコードからステートマシン図(状態遷移図)を自動的に作成可能な状態遷移図作成装置および状態遷移図作成方法を提供することである。   An object of the present invention is to provide a state transition diagram creating apparatus and a state transition diagram creating method capable of automatically creating a state machine diagram (state transition diagram) from source code.

上記目的を達成するために、本発明の状態遷移図作成装置は、状態を変数として用いる処理を規定する複数のコード行と、前記複数のコード行のうち、状態の変化を表す状態変化コード行に付与された、前記変化の後の状態を表す状態宣言アノテーションと、前記複数のコード行のうち、状態に対する制御を表す制御コード行に付与された、前記制御による変化前の状態を表す条件宣言アノテーションと、を有するソースコードから、状態遷移図を作成する状態遷移図作成装置であって、前記ソースコードを解析して前記コード行の間の対応関係を特定し、前記対応関係と、前記状態宣言アノテーションと、前記条件宣言アノテーションと、に基づいて、遷移前の状態と遷移後の状態とを対応させた遷移リストを作成するリスト作成手段と、前記遷移リストに基づいて、前記状態遷移図を作成する状態遷移図作成手段と、を含む。   In order to achieve the above object, a state transition diagram creating apparatus of the present invention includes a plurality of code lines that define processing using a state as a variable, and a state change code line that represents a change in state among the plurality of code lines. And a state declaration annotation that represents the state after the change, and a condition declaration that represents the state before the change by the control, which is assigned to a control code line that represents control over the state among the plurality of code lines. A state transition diagram creation device for creating a state transition diagram from source code having annotations, wherein the source code is analyzed to identify a correspondence relationship between the code lines, and the correspondence relationship and the state A list creation means for creating a transition list in which a state before transition and a state after transition are associated with each other based on the declaration annotation and the condition declaration annotation; Based on the serial transition list, including a state transition diagram creating means for creating the state transition diagram.

また、本発明の状態遷移図作成方法は、状態を変数として用いる処理を規定する複数のコード行と、前記複数のコード行のうち、状態の変化を表す状態変化コード行に付与された、前記変化の後の状態を表す状態宣言アノテーションと、前記複数のコード行のうち、状態に対する制御を表す制御コード行に付与された、前記制御による変化前の状態を表す条件宣言アノテーションと、を有するソースコードから、状態遷移図を作成する状態遷移図作成装置が行う状態遷移図作成方法であって、前記ソースコードを解析して前記コード行の間の対応関係を特定し、前記対応関係と、前記状態宣言アノテーションと、前記条件宣言アノテーションと、に基づいて、遷移前の状態と遷移後の状態とを対応させた遷移リストを作成するリスト作成ステップと、前記遷移リストに基づいて、前記状態遷移図を作成する状態遷移図作成ステップと、を含む。   Further, the state transition diagram creating method of the present invention is provided with a plurality of code lines that define processing using a state as a variable, and a state change code line representing a change in state among the plurality of code lines, A source having a state declaration annotation representing a state after a change, and a condition declaration annotation representing a state before the change by the control, which is given to a control code line representing a control for the state among the plurality of code lines A state transition diagram creation method performed by a state transition diagram creation device that creates a state transition diagram from code, wherein the source code is analyzed to identify a correspondence between the code lines, and the correspondence Based on the state declaration annotation and the condition declaration annotation, a list creation step for creating a transition list that associates the state before transition with the state after transition. Including a flop, on the basis of the transition list, and the state transition diagram generating step of generating the state transition diagram, the.

状態宣言アノテーションは、変化の後の状態を表し、状態の変化を表す状態変化コード行に付与されている。条件宣言アノテーションは、制御による変化前の状態を表し、状態に対する制御を表す制御コード行に付与されている。   The state declaration annotation represents the state after the change, and is attached to the state change code line indicating the state change. The condition declaration annotation represents the state before the change by the control, and is given to the control code line representing the control for the state.

コード行の間の対応関係から、複数のコード行に応じた状態変化処理を行なった際の処理の流れを特定することが可能であり、その際の状態の変化を、状態宣言アノテーションと条件宣言アノテーションを用いて特定することが可能となる。   From the correspondence between code lines, it is possible to specify the flow of processing when state change processing corresponding to multiple code lines is performed, and the state change at that time is determined by state declaration annotations and condition declarations It is possible to specify using annotation.

このため、上記発明によれば、コード行の間の対応関係と、状態宣言アノテーションと、条件宣言アノテーションとに基づいて、複数のコード行に応じた処理を行なった際の状態の変化の変遷を特定することが可能になる。よって、遷移前の状態と遷移後の状態を対応させた遷移リストを作成可能になり、その遷移リストに基づいて、状態遷移図を作成することが可能になる。   For this reason, according to the above-described invention, based on the correspondence between the code lines, the state declaration annotation, and the condition declaration annotation, the transition of the state change when processing according to a plurality of code lines is performed. It becomes possible to specify. Therefore, it is possible to create a transition list that associates the state before transition with the state after transition, and it is possible to create a state transition diagram based on the transition list.

したがって、状態宣言アノテーションおよび条件宣言アノテーションが付与されたソースコードから状態遷移図を作成することが可能になる。   Therefore, it is possible to create a state transition diagram from the source code to which the state declaration annotation and the condition declaration annotation are added.

このため、ユーザは、ソースコードから作成された状態遷移図と設計情報とを比較することによって、ソースコードの実装の正しさを検証することが可能になる。   Therefore, the user can verify the correctness of the implementation of the source code by comparing the state transition diagram created from the source code with the design information.

また、ソースコードから状態遷移図を自動作成できるので、人為的なミスを防止でき、短時間で状態遷移図を作成することが可能となる。   Further, since the state transition diagram can be automatically created from the source code, an artificial mistake can be prevented, and the state transition diagram can be created in a short time.

なお、前記リスト作成手段は、前記ソースコードを解析して、前記ソースコードにおけるコード行の入れ子構造および前記制御コード行を特定し、前記入れ子構造および前記制御コード行に基づいて、前記ソースコードから、複数の制御ブロックと、前記制御ブロックに入るための条件と、を抽出し、前記入れ子構造に基づいて、前記制御ブロックに関する制御ブロック木構造を特定し、前記条件を、前記制御ブロック木構造内の当該条件に対応する制御ブロックに付加する制御構造解析手段と、前記状態宣言アノテーション、前記条件宣言アノテーションおよび前記制御ブロック木構造に基づいて、前記制御ブロックごとに、当該制御ブロックがとり得る前の状態を表すイン状態リストと、当該制御ブロックがとり得る後の状態を表すアウト状態リストと、を生成し、前記制御ブロック木構造内の各制御ブロックに、対応する前記イン状態リストおよび前記アウト状態リストを付加して、イン/アウト状態付制御ブロック木構造を作成する状態解析手段と、前記状態宣言アノテーションを有する制御ブロックについて、当該制御ブロックの、イン状態リスト、アウト状態リスト、および、条件宣言アノテーションに基づいて、前記遷移リストを作成する遷移解析手段と、を含むことが望ましい。   The list creation means analyzes the source code to identify a code line nesting structure and the control code line in the source code, and from the source code based on the nesting structure and the control code line Extracting a plurality of control blocks and a condition for entering the control block, identifying a control block tree structure for the control block based on the nested structure, and specifying the condition in the control block tree structure Before the control block can be taken for each control block based on the control structure analysis means to be added to the control block corresponding to the condition, and the state declaration annotation, the condition declaration annotation, and the control block tree structure An in-state list representing the state and an out-state representing a later state that the control block can take. A state analysis, and adding a corresponding in-state list and out-state list to each control block in the control block tree structure to create a control block tree structure with in / out states And a transition analysis unit that creates the transition list based on the control block having the state declaration annotation based on the in-state list, the out-state list, and the condition declaration annotation of the control block. desirable.

上記発明によれば、高い確度で、状態遷移図を作成することが可能になる。   According to the above invention, it is possible to create a state transition diagram with high accuracy.

本発明によれば、ソースコードから状態遷移図を自動的に作成することが可能になる。   According to the present invention, it is possible to automatically create a state transition diagram from source code.

以下、本発明の実施例を図面を参照して説明する。   Embodiments of the present invention will be described below with reference to the drawings.

図1は、本発明の一実施例であるステートマシン図リバース装置100を示したブロック図である。   FIG. 1 is a block diagram showing a state machine diagram reverse device 100 according to an embodiment of the present invention.

ステートマシン図リバース装置100は、状態遷移図作成装置の一例であり、アノテーション付きのソースコードAを入力としてステートマシン図Eを生成する。   The state machine diagram reverse device 100 is an example of a state transition diagram creation device, and generates a state machine diagram E with the source code A with annotations as an input.

ステートマシン図リバース装置100は、制御構造解析手段1、状態解析手段2、遷移解析手段3、および、ステートマシン図描画手段4を含み、中間生成物として、制御ブロック木構造B、in/out状態付き制御ブロック木構造C、および、遷移リストDを生成する。なお、制御構造解析手段1と、状態解析手段2と、遷移解析手段3とで、リスト作成手段5を構成する。   The state machine diagram reverse device 100 includes a control structure analysis unit 1, a state analysis unit 2, a transition analysis unit 3, and a state machine diagram drawing unit 4. As an intermediate product, a control block tree structure B, an in / out state The attached control block tree structure C and the transition list D are generated. The control structure analyzing means 1, the state analyzing means 2, and the transition analyzing means 3 constitute a list creating means 5.

図2は、アノテーション付きのソースコードAの一例を示した説明図である。   FIG. 2 is an explanatory diagram showing an example of source code A with annotation.

ソースコードAは、アノテーション付きのプログラム、または、アノテーション付きのプログラムの一部である。   The source code A is an annotated program or a part of an annotated program.

ソースコードAは、3つの要素、具体的には、状態宣言アノテーションと、条件宣言アノテーションと、業務ロジックが記述されたコード部(上記の2種類アノテーションに該当しないコード部)と、から成り立っている。   The source code A is composed of three elements, specifically, a state declaration annotation, a condition declaration annotation, and a code part in which business logic is described (a code part not corresponding to the above two types of annotations). .

コード部は、状態を変数として用いる処理を規定する複数のコード行からなる。   The code part is composed of a plurality of code lines that define processing using a state as a variable.

状態の変化を表す状態変化コード行「state=・・・」には、変化の後の状態を表す状態宣言アノテーション「//@state=・・・」が付与されている。   A state declaration annotation “// @ state =...” Representing the state after the change is given to the state change code line “state =...” Representing the state change.

具体的には、状態変化コード行「int state=0」には、状態宣言アノテーション「//@state=initial」が付与されている。また、状態変化コード行「state=prepare()」には状態宣言アノテーション「//@state=prepare」が、状態変化コード行「state=go()」には状態宣言アノテーション「//@state=go.first」が、状態変化コード行「state=next()」には状態宣言アノテーション「//@state=go.second」が、状態変化コード行「state=end()」には状態宣言アノテーション「//@state=end」が付与されている。   Specifically, a state declaration annotation “// @ state = initial” is given to the state change code line “int state = 0”. In addition, the state change annotation “// @ state = prepare” is displayed in the state change code line “state = prepare ()”, and the state declaration annotation “// @ state =” is displayed in the state change code line “state = go ()”. go.first ”is the state declaration annotation“ //@state=go.second ”in the state change code line“ state = next () ”, and the state declaration annotation is in the state change code line“ state = end () ”. “// @ state = end” is assigned.

状態に対する制御を表す制御コード行「例えば、if(state==・・・)」には、制御による変化前の状態を表す条件宣言アノテーション「//@condition=・・・」が付与されている。   The control code line “for example, if (state ==...)” Indicating the control for the state is given the condition declaration annotation “// @ condition =...” Indicating the state before the change by the control. .

例えば、制御コード行「if(state==1)」には、条件宣言アノテーション「//@condition=prepare」が付与されている。   For example, the condition declaration annotation “// @ condition = prepare” is given to the control code line “if (state == 1)”.

制御構造解析手段1は、ソースコードAを解析して、ソースコードA内の制御部(具体的には、条件分岐(if文、)と繰返し(while文、for文))および入れ子構造を特定する。なお、制御部は、状態に対する制御を表す制御コード行を含む。   The control structure analysis means 1 analyzes the source code A, and specifies a control unit (specifically, conditional branch (if statement) and repetition (while statement, for statement)) and nested structure in the source code A To do. Note that the control unit includes a control code line representing control over the state.

制御構造解析手段1は、ソースコードA内の制御部および入れ子構造に基づいて、ソースコードAから複数の制御ブロックを抽出する。制御ブロックは、制御部および入れ子構造に基づいてソースコードAから分割されたプログラムの断片である。   The control structure analyzing unit 1 extracts a plurality of control blocks from the source code A based on the control unit and the nested structure in the source code A. The control block is a program fragment divided from the source code A based on the control unit and the nested structure.

なお、プログラム言語により、else節(if文のどの条件にもあてはまらない場合に実行されるブロック)の表記が省略される場合があるため、制御構造解析手段1は、省略されたelse節に関しても、何も処理を伴わない制御ブロックとして定義する。   Note that the notation of the else clause (a block that is executed when none of the conditions of the if statement are satisfied) may be omitted depending on the programming language, and therefore the control structure analyzing unit 1 also relates to the omitted else clause. Define a control block that does not involve any processing.

図3は、制御構造解析手段1によって複数の制御ブロックに分割されたソースコードAの例を示した説明図である。   FIG. 3 is an explanatory diagram showing an example of the source code A divided into a plurality of control blocks by the control structure analyzing means 1.

制御構造解析手段1は、個々の制御ブロックの入れ子構造を解析して、制御ブロックの木構造を構成し、その木構造を、制御ブロック木構造Bとする処理を行なう。   The control structure analyzing unit 1 analyzes the nested structure of each control block, constructs a tree structure of the control block, and performs a process of setting the tree structure as a control block tree structure B.

制御構造解析手段1は、親の制御ブロックと子の制御ブロックをつなぐ線をエッジとし、エッジには、種別(「排他」または「繰返し」またはNULLのいずれか)と、子の制御ブロックに制御が移るための条件を表わすラベルとを、属性として持たせる。   The control structure analyzing means 1 uses a line connecting the parent control block and the child control block as an edge, and the edge is classified into one of “exclusive”, “repetition”, or NULL, and the child control block. A label indicating a condition for moving is provided as an attribute.

なお、制御構造解析手段1は、子の制御ブロックに制御が移るための条件を、入れ子構造および制御コード行に基づいて、ソースコードAから抽出する。   The control structure analyzing unit 1 extracts a condition for transferring control to the child control block from the source code A based on the nested structure and the control code line.

図4は、制御構造解析手段1が図3で示したソースコードAの各制御ブロックについて作成した制御ブロック木構造Bの例を示した説明図である。   FIG. 4 is an explanatory diagram showing an example of the control block tree structure B created by the control structure analyzing means 1 for each control block of the source code A shown in FIG.

状態解析手段2は、ソースコードAを順にたどることによって制御ブロック木構造Bを深さ優先で探索し、それぞれの制御ブロックに対して、木構造上の位置、状態宣言アノテーション、および、条件宣言アノテーションを基に、in(イン)状態リストおよびout(アウト)状態リストを作成する。   The state analysis means 2 searches the control block tree structure B in depth-first order by sequentially tracing the source code A, and for each control block, the position on the tree structure, the state declaration annotation, and the condition declaration annotation Based on the above, an in state list and an out state list are created.

状態解析手段2は、in状態リストおよびout状態リストを、それらリストに対応する各制御ブロックに付加して、in/out状態付き制御ブロック木構造Cを作成する処理を行なう。   The state analysis means 2 performs processing for adding the in state list and the out state list to each control block corresponding to the lists and creating a control block tree structure C with in / out states.

in状態リストとは、そのリストに対応する制御ブロックに制御が入る際にとりうる状態を表したリストのことであり、out状態リストとは、そのリストに対応する制御ブロックから制御が出る際にとりうる状態を表したリストのことである。   The in-state list is a list showing the states that can be taken when control enters the control block corresponding to the list, and the out-state list can be taken when control is output from the control block corresponding to the list. It is a list showing the state.

図5は、状態解析手段2が図4で示した制御ブロック木構造Bについて作成したin/out状態付き制御ブロック木構造Cの例を示した説明図である。   FIG. 5 is an explanatory diagram showing an example of a control block tree structure C with in / out states created by the state analysis unit 2 for the control block tree structure B shown in FIG.

遷移解析手段3は、状態宣言アノテーションを有するそれぞれの制御ブロックに対して、制御ブロック内のコード、イン状態リスト、アウト状態リスト、および、条件宣言アノテーションに基づいて、イベント、条件、遷移前の状態、遷移後の状態を特定して、遷移リストDを作成する。   For each control block having a state declaration annotation, the transition analysis means 3 determines the event, the condition, the state before the transition based on the code in the control block, the in-state list, the out-state list, and the condition declaration annotation. The state after the transition is specified, and the transition list D is created.

図7は、遷移解析手段3が図5で示したin/out状態付き制御ブロック木構造Cについて作成した遷移リストDの例を示した説明図である。   FIG. 7 is an explanatory diagram showing an example of the transition list D created by the transition analysis means 3 for the control block tree structure C with in / out states shown in FIG.

図7に示したように、遷移リストDは、遷移番号、イベント、条件、遷移前の状態、遷移後の状態から構成される。   As shown in FIG. 7, the transition list D includes a transition number, an event, a condition, a state before transition, and a state after transition.

ステートマシン図描画手段4は、状態遷移図作成手段の一例であり、遷移リストDに基づいて、ステートマシン図を作成する。具体的には、ステートマシン図描画手段4は、遷移リストD内の各状態、開始状態、終了状態をステートマシン図に描画し、また、遷移リストD内のそれぞれの遷移に対して、遷移前の状態から遷移後の状態への遷移を描画する処理を行なう。   The state machine diagram drawing unit 4 is an example of a state transition diagram creation unit, and creates a state machine diagram based on the transition list D. Specifically, the state machine diagram drawing unit 4 draws each state, start state, and end state in the transition list D on the state machine diagram, and for each transition in the transition list D, before the transition. The process of drawing the transition from the state to the state after the transition is performed.

図8は、ステートマシン図描画手段4が図7で示した遷移リストDについて作成したステートマシン図Eの例を示した説明図である。   FIG. 8 is an explanatory diagram showing an example of a state machine diagram E created by the state machine diagram drawing means 4 for the transition list D shown in FIG.

リスト作成手段5は、ソースコードAを解析してコード行の間の対応関係(例えば、コード行における親子関係)を特定し、その対応関係と、状態宣言アノテーションと、条件宣言アノテーションと、に基づいて、遷移前の状態と遷移後の状態とを対応させた遷移リストDを作成する。   The list creation means 5 analyzes the source code A to identify the correspondence between code lines (for example, the parent-child relationship in the code line), and based on the correspondence, the state declaration annotation, and the condition declaration annotation Thus, a transition list D is created in which the state before transition and the state after transition are associated with each other.

次に、動作を説明する。   Next, the operation will be described.

図9は、ステートマシン図リバース装置100の動作を説明するためのフローチャートである。以下、図9のフローチャートを参照して、本実施例の全体の動作について詳細に説明する。   FIG. 9 is a flowchart for explaining the operation of the state machine diagram reverse apparatus 100. Hereinafter, the overall operation of this embodiment will be described in detail with reference to the flowchart of FIG.

なお、以下の説明では、図2に示したソースコードAからステートマシン図を作成する動作を説明するが、ソースコードは、図2に示したものに限らず適宜変更可能である。   In the following description, an operation for creating a state machine diagram from the source code A shown in FIG. 2 will be described. However, the source code is not limited to that shown in FIG.

制御構造解析手段1は、ソースコードAを構文解析し、まず、ソースコードAの入れ子構造に基づいて、ソースコードAから複数の制御ブロックを抽出し、その後、それら制御ブロックを、条件分岐(if文)および繰返し(while文、for文)等の制御部の直前と直後で分割する。   The control structure analysis means 1 parses the source code A, first extracts a plurality of control blocks from the source code A based on the nested structure of the source code A, and then converts these control blocks into conditional branches (if Sentence) and repetition (while sentence, for sentence), etc.

具体的には、制御構造解析手段1は、まず、入れ子構造に基づいて、ソースコードAから、制御ブロックaと、制御ブロックb1〜b3をまとめた制御ブロックと、を抽出し、その後、制御部に基づいて、制御ブロックb1〜b3をまとめた制御ブロックを、制御ブロックb1、制御ブロックb2(制御部)、制御ブロックb3に分割して、制御ブロックb1〜b3を抽出する。   Specifically, the control structure analyzing means 1 first extracts the control block a and the control block in which the control blocks b1 to b3 are combined from the source code A based on the nested structure, and then the control unit Based on the control block, the control block including the control blocks b1 to b3 is divided into the control block b1, the control block b2 (control unit), and the control block b3, and the control blocks b1 to b3 are extracted.

続いて、制御構造解析手段1は、制御部(制御ブロックb2)内部に関しても、入れ子構造に基づいて、複数の制御ブロック(制御ブロックb2−1、制御ブロックb2−2、制御ブロックc1、制御ブロックc2、制御ブロックc3、制御ブロックc4、制御ブロックe1、制御ブロックe2、制御ブロックe3)に分割して、それらを抽出する(ステップa)。   Subsequently, the control structure analyzing means 1 also includes a plurality of control blocks (control block b2-1, control block b2-2, control block c1, control block) based on the nested structure in the control unit (control block b2). c2, control block c3, control block c4, control block e1, control block e2, and control block e3) and extract them (step a).

ここまでの動作で、図3に示した複数の制御ブロックが抽出される。   With the operation so far, the plurality of control blocks shown in FIG. 3 are extracted.

続いて、制御構造解析手段1は、個々の制御ブロックの入れ子構造を解析して木構造を構成し、その木構造を制御ブロック木構造Bとする。   Subsequently, the control structure analyzing unit 1 analyzes the nested structure of each control block to form a tree structure, and sets the tree structure as a control block tree structure B.

その際に、制御ブロックが制御部で始まる場合、制御構造解析手段1は、子の制御ブロックに制御が移るための条件を、親の制御ブロックと子の制御ブロックとの関係として、木構造のエッジのラベルに記述し、エッジの種別も排他と繰返しに応じて変えておく。   At that time, when the control block starts at the control unit, the control structure analyzing means 1 sets the condition for the control to be transferred to the child control block as the relationship between the parent control block and the child control block. It is described in the edge label, and the edge type is also changed according to exclusion and repetition.

また、その条件に条件宣言アノテーションが記述されている場合、制御構造解析手段1は、その条件宣言アノテーションの内容も、ラベルに”and”でつないで記述する(ステップb)。   If a condition declaration annotation is described in the condition, the control structure analyzing unit 1 also describes the contents of the condition declaration annotation by connecting “and” to the label (step b).

ここまでの動作で、図4に示した制御ブロック木構造Bが作成される。   With the operation so far, the control block tree structure B shown in FIG. 4 is created.

続いて、状態解析手段2は、対象ブロックを一番親の制御ブロック(制御ブロックa)とし、また、空の前out状態リストを作成する(ステップc)。   Subsequently, the state analysis unit 2 sets the target block as the parent control block (control block a) and creates an empty previous out state list (step c).

状態解析手段2は、対象ブロックを探索し、in状態リストおよびout状態リストを作成する。状態解析手段2は、制御ブロック木構造Bを全て探索して、in状態リストおよびout状態リストを、制御ブロック木構造B内の全ての制御ブロックについて付与したものを、in/out状態付き制御ブロック木構造Cとする(ステップd)
図10は、in状態リストおよびout状態リストを作成するための処理を説明するためのフローチャートである。
The state analysis means 2 searches the target block and creates an in state list and an out state list. The state analysis means 2 searches all the control block tree structure B, and assigns the in state list and the out state list to all the control blocks in the control block tree structure B. Tree structure C (step d)
FIG. 10 is a flowchart for explaining processing for creating an in state list and an out state list.

以下、図10を参照して、in状態リストおよびout状態リストの方法を説明する。   Hereinafter, the method of the in state list and the out state list will be described with reference to FIG.

まず、状態解析手段2は、対象ブロックである制御ブロックのin状態リストおよびout状態リストがなければ、空のin状態リストとout状態リストを作成する(ステップd1)。   First, if there is no in state list and out state list of the control block that is the target block, the state analyzing unit 2 creates an empty in state list and out state list (step d1).

続いて、状態解析手段2は、前out状態リストの値を、対象ブロックである制御ブロックのin状態リストに追加登録する(ステップd3)。   Subsequently, the state analysis unit 2 additionally registers the value of the previous out state list in the in state list of the control block that is the target block (step d3).

続いて、状態解析手段2は、対象ブロックに対応する変数iおよびjを0にし(ステップd101)、対象ブロックとなっている制御ブロックに対応するソースコードAの断片を最初から最後まで順に走査していき(ステップd102A〜ステップd102B)、その走査中に以下の処理を行なう。   Subsequently, the state analysis means 2 sets the variables i and j corresponding to the target block to 0 (step d101), and sequentially scans the fragments of the source code A corresponding to the control block that is the target block from the beginning to the end. (Steps d102A to d102B) and the following processing is performed during the scanning.

状態宣言アノテーションに到達した場合(ステップd103)(例えば図5の制御ブロックe1)、状態解析手段2は、状態遷移と判断して、状態宣言アノテーションの値ひとつをout状態リストに登録する。複数の状態宣言アノテーションがあった場合は、状態解析手段2は、その都度out状態リストの値を、新たな状態宣言アノテーションの値に置換していく(ステップd4)。その後、状態解析手段2は、対象ブロックに対応する変数iに1を加算する(ステップd104)。   When the state declaration annotation is reached (step d103) (for example, the control block e1 in FIG. 5), the state analysis unit 2 determines that the state transition is made and registers one value of the state declaration annotation in the out state list. When there are a plurality of state declaration annotations, the state analysis unit 2 replaces the value of the out state list with the value of a new state declaration annotation each time (step d4). Thereafter, the state analysis means 2 adds 1 to the variable i corresponding to the target block (step d104).

状態宣言アノテーションに到達せずに子の制御ブロックに到達した場合(ステップd103、d105)(例えば図5の制御ブロックc4)、状態解析手段2は、対象ブロックに対応する変数jに1を加算し(ステップd106)、その後、子の制御ブロックを対象ブロックとして(ステップd107)、ステップdの処理を行なう。探索した制御ブロックと子の制御ブロックとの関係が繰返しの場合、状態解析手段2は、最後の子のout状態リストが変わらなくなるまで、子の制御ブロックの探索を順番に繰返し行なう(ステップd’)。   When the child control block is reached without reaching the state declaration annotation (steps d103 and d105) (for example, the control block c4 in FIG. 5), the state analysis unit 2 adds 1 to the variable j corresponding to the target block. (Step d106), then, the child control block is set as the target block (Step d107), and the process of Step d is performed. When the relationship between the searched control block and the child control block is repeated, the state analyzing means 2 sequentially repeats the search for the child control block until the out state list of the last child does not change (step d ′). ).

一方、状態宣言アノテーションが見つからなかった場合(ステップd103)、状態解析手段2は、変数i=0を保持しながら、以下の処理を行なう。   On the other hand, when the state declaration annotation is not found (step d103), the state analysis unit 2 performs the following process while holding the variable i = 0.

当該制御ブロックが子の制御ブロックを持たない場合(ステップd105)(例えば図5の制御ブロックe3)、j=0も保持され、状態解析手段2は、ステップd108およびd109を通り、in状態リストの値をそのままout状態リストに登録する(ステップd5)。   If the control block has no child control block (step d105) (for example, control block e3 in FIG. 5), j = 0 is also held, and the state analysis means 2 passes through steps d108 and d109, The value is registered as it is in the out state list (step d5).

子の制御ブロックを持ち(この場合、j≠0となる。)、子の制御ブロックとの間のエッジの種別が排他の場合(例えば図5の制御ブロックc4)、状態解析手段2は、ステップd108、d109およびd110を通り、子の制御ブロックのout状態リストの各状態(値)を高々ひとつずつ当該制御ブロックのout状態リストに追加する(ステップd6)。   When having a child control block (in this case, j ≠ 0) and the type of edge with the child control block is exclusive (for example, control block c4 in FIG. 5), the state analysis means 2 performs step Through d108, d109 and d110, each state (value) in the out state list of the child control block is added to the out state list of the control block one at a time (step d6).

子の制御ブロックを持ち(この場合、j≠0となる。)、子の制御ブロックとの間のエッジの種別が繰返しの場合(例えば図5の制御ブロックc2)、状態解析手段2は、ステップd108、d109、d110およびd111を通り、当該制御ブロックのin状態リストの各状態と子の制御ブロックのout状態リストの各状態を高々ひとつずつ合わせて当該制御ブロックのout状態リストに登録する(ステップd10)。   If there is a child control block (in this case, j ≠ 0), and the type of edge with the child control block is repetitive (for example, control block c2 in FIG. 5), the state analysis means 2 Through d108, d109, d110, and d111, each state of the in-state list of the control block and each state of the out-state list of the child control block are combined one by one and registered in the out-state list of the control block (step d10).

子の制御ブロックを持ち(この場合、j≠0となる。)、その間のエッジの種別が排他でも繰返しでもない場合(例えば図5の制御ブロックa)、状態解析手段2は、ステップd108、d109、d110およびd111を通り、最後の子の制御ブロックのout状態リストの値を当該制御ブロックのout状態リストに登録する(ステップd7)。   If there is a child control block (in this case, j.noteq.0) and the edge type between them is neither exclusive nor repeated (for example, control block a in FIG. 5), the state analysis means 2 performs steps d108 and d109. , D110 and d111, the value of the out state list of the last child control block is registered in the out state list of the control block (step d7).

また、探索した制御ブロックとその親の制御ブロックとの間のエッジの種別が排他の場合(ステップd112)(例えば図5の制御ブロックe3)、状態解析手段2は、当該制御ブロックのin状態リストの値を前out状態リストにコピーする(ステップd8)。   When the type of edge between the searched control block and its parent control block is exclusive (step d112) (for example, control block e3 in FIG. 5), the state analysis means 2 displays the in-state list of the control block. Is copied to the previous out state list (step d8).

また、探索した制御ブロックとその親の制御ブロックとのエッジの種別が排他でない場合(ステップd112)(例えば図5の制御ブロックc3)、状態解析手段2は、当該制御ブロックのout状態リストの値を前out状態リストにコピーする(ステップd9)。   If the type of edge between the searched control block and its parent control block is not exclusive (step d112) (for example, control block c3 in FIG. 5), the state analysis means 2 determines the value of the out state list of the control block. Is copied to the previous out state list (step d9).

ここまでの動作で、図5に示したin/out状態付き制御ブロック木構造Cが作成される。   The control block tree structure C with in / out states shown in FIG. 5 is created by the operations so far.

図11は、各制御ブロックに対して、図10に示したフローチャートの処理が適用される流れを示した説明図である。   FIG. 11 is an explanatory diagram showing a flow in which the process of the flowchart shown in FIG. 10 is applied to each control block.

遷移解析手段3は、遷移リストDを初期化して空のリストとしておく。   The transition analysis means 3 initializes the transition list D and keeps it as an empty list.

遷移解析手段3は、遷移番号として、遷移リストDに遷移が追加される順に連番をふることとする。   The transition analysis unit 3 assigns serial numbers as transition numbers in the order in which transitions are added to the transition list D.

遷移解析手段3は、各制御ブロックに対して、対応するソースコードAの断片を走査して状態宣言アノテーションを見つけた場合、その制御ブロックのin状態リストの各状態を遷移前の状態とし、状態宣言アノテーションで記述された状態を遷移後の状態とする遷移を遷移リストDに加え、そのin状態リストを状態宣言アノテーションで記述された状態に更新する。   When the transition analysis means 3 scans the corresponding source code A fragment for each control block and finds the state declaration annotation, the transition analysis means 3 sets each state in the in-state list of the control block as the state before transition, A transition having the state described by the declaration annotation as the state after the transition is added to the transition list D, and the in-state list is updated to the state described by the state declaration annotation.

遷移解析手段3は、対応するソースコードAの断片が終了するまで走査を続ける。   The transition analysis means 3 continues scanning until the corresponding fragment of the source code A ends.

なお、遷移解析手段3は、遷移のイベントには、状態宣言アノテーションが記述された行に記述された操作名(関数名:具体的には、prepare、go、next、end)を記述する。   The transition analysis unit 3 describes the operation name (function name: specifically, prepare, go, next, end) described in the line in which the state declaration annotation is described in the transition event.

また、遷移解析手段3は、当該制御ブロックの最初の状態の遷移を遷移リストDに追加する場合、遷移の条件として、木構造の親を全てたどってエッジに記述されたラベルを全て”and”でつないだものを記述する。   Further, when adding the transition of the first state of the control block to the transition list D, the transition analysis unit 3 traces all the parents of the tree structure and sets all the labels described in the edges as “and” as a transition condition. Describe what is connected.

次に、遷移解析手段3は、遷移リストD内で、条件に状態が記述されている状況で、その状態が遷移前の条件(条件宣言アノテーションに表された状態)と合致しない場合(例えば図7の遷移番号4)、当該遷移を遷移リストDから削除する(ステップe)。   Next, the transition analysis unit 3 is a situation where a state is described in the condition in the transition list D, and the state does not match the condition before the transition (the state shown in the condition declaration annotation) (for example, FIG. 7), the transition is deleted from the transition list D (step e).

図6は、遷移解析手段3が、図5のin/out状態付き制御ブロック木構造Cに対して、ステップeを実行した後の状態のin/out状態付き制御ブロック木構造Cを示した説明図である。   FIG. 6 is a diagram illustrating the control block tree structure C with in / out state after the transition analysis unit 3 executes step e on the control block tree structure C with in / out state of FIG. FIG.

ステートマシン図描画手段4は、開始状態と、遷移リストD内の各遷移の遷移前の状態に記述された状態と遷移後の状態に記述された状態を高々ひとつずつ、および、終了状態を順番に、例えば縦一列または横一列に、配置する。   The state machine diagram drawing means 4 sequentially orders the start state, the state described in the state before the transition of each transition in the transition list D, the state described in the state after the transition, and the end state in order. For example, they are arranged in one vertical row or one horizontal row.

ただし、ステートマシン図描画手段4は、状態がピリオドで区切られている場合は、コンポジット状態と判断して、入れ子にして状態を記述する。   However, if the state is divided by periods, the state machine diagram drawing means 4 determines that the state is a composite state and describes the state in a nested manner.

ステートマシン図描画手段4は、コンポジット状態にも開始状態と終了状態をひとつずつ配置する(ステップf)。   The state machine diagram drawing means 4 arranges the start state and the end state one by one in the composite state (step f).

次に、ステートマシン図描画手段4は、遷移リスト内のそれぞれの遷移に関して、イベントや条件を、UMLで決められた書式のラベルとして、遷移前の状態から遷移後の状態への結線を行なう。   Next, the state machine diagram drawing unit 4 performs connection from the state before the transition to the state after the transition, with the event and the condition as a label in a format determined by UML, for each transition in the transition list.

状態前の遷移がNULLの場合、ステートマシン図描画手段4は、開始状態からの遷移とする。   When the transition before the state is NULL, the state machine diagram drawing unit 4 sets the transition from the start state.

また、状態後の遷移がNULLの場合、ステートマシン図描画手段4は、終了状態への遷移とする。   When the transition after the state is NULL, the state machine diagram drawing unit 4 sets the transition to the end state.

コンポジット状態の外から内への遷移の場合、ステートマシン図描画手段4は、コンポジット状態への遷移を記述し、またコンポジット状態内の開始状態から遷移後の状態への遷移も記述する。   In the case of transition from the outside to the inside of the composite state, the state machine diagram drawing means 4 describes the transition to the composite state, and also describes the transition from the start state to the state after the transition in the composite state.

ステートマシン図描画手段4は、条件を、前者の遷移のラベルとして描画する。   The state machine diagram drawing means 4 draws the condition as a label of the former transition.

コンポジット状態の内から外への遷移の場合、ステートマシン図描画手段4は、遷移前の状態からコンポジット状態内の終了状態への遷移を記述し、またコンポジット状態から遷移後の状態への遷移も記述する。   In the case of the transition from the inside of the composite state to the outside, the state machine diagram drawing means 4 describes the transition from the state before the transition to the end state within the composite state, and also the transition from the composite state to the state after the transition. Describe.

ステートマシン図描画手段4は、条件を、後者の遷移のラベルとして描画する(ステップg)。   The state machine diagram drawing means 4 draws the condition as a label for the latter transition (step g).

本実施例によれば、コード行の間の対応関係と、状態宣言アノテーションと、条件宣言アノテーションとに基づいて、複数のコード行に応じた処理を行なった際の状態の変化の変遷を特定することが可能になる。よって、遷移前の状態と遷移後の状態を対応させた遷移リストを作成可能になり、その遷移リストに基づいて、状態遷移図を作成することが可能になる。   According to the present embodiment, based on the correspondence between code lines, the state declaration annotation, and the condition declaration annotation, the transition of the state change when processing corresponding to a plurality of code lines is specified. It becomes possible. Therefore, it is possible to create a transition list that associates the state before transition with the state after transition, and it is possible to create a state transition diagram based on the transition list.

本実施例によれば、以下の効果を奏する。   According to the present embodiment, the following effects can be obtained.

第1の効果は、ソースコードが設計通りに実装されているか検証を行なうことができる点にある。   The first effect is that it is possible to verify whether the source code is implemented as designed.

その理由は、ソースコード上では人間が容易に状態遷移を把握することが困難であったが、本実施例によりリバースしたステートマシン図により人間が設計情報を比較して実装の正しさを判断できるためである。   The reason is that it is difficult for humans to easily grasp the state transition on the source code, but humans can judge the correctness of implementation by comparing design information with the state machine diagram reversed by this embodiment. Because.

第2の効果は、ステートマシン図の作成に関する正確性や開発生産性が向上する点にある。   The second effect is that the accuracy and development productivity relating to the creation of the state machine diagram are improved.

その理由は、ソースコードから状態遷移図を手作業で書くのは、ミスが発生したり、時間がかかっていたが、本発明によりソースコードからステートマシン図を自動作成できるので、工数が削減できるためである。   The reason is that manually writing the state transition diagram from the source code caused mistakes and took time, but the present invention can automatically create a state machine diagram from the source code, reducing man-hours. Because.

なお、以上説明した実施例において、図示した構成は単なる一例であって、本発明はその構成に限定されるものではない。   In the embodiment described above, the illustrated configuration is merely an example, and the present invention is not limited to the configuration.

例えば、プログラミング言語の仕様により、繰返し処理においては、
(1)図3で示したように繰返しループに入らない可能性がある場合(while文など)
(2)必ず一度は繰返しループに入る場合(do〜while文など)
(3)繰返しの回数が決まっている場合(for文で繰返し数が定数の場合など)
などの記法があるため、これを区別するようなアノテーションを定義して、リスト作成部5が、そのアノテーションを解析する。
For example, according to the programming language specifications,
(1) When there is a possibility that the loop does not enter repeatedly as shown in FIG. 3 (while statement, etc.)
(2) Be sure to enter the loop once (such as do-while statement)
(3) When the number of repetitions is fixed (for example, when the number of repetitions is a constant in a for statement)
Therefore, the list creating unit 5 analyzes the annotation.

例えば、リスト作成部5(状態解析手段2)は、(2)の場合、ステップd10でなくステップd7を通るような処理フローを実行し、(3)の場合、ステップd’の繰返し数を決めてステップd’をその数だけ繰り返すことによって、正確なステートマシン図を得ることが可能になる。   For example, in the case of (2), the list creation unit 5 (state analysis unit 2) executes a processing flow that passes through step d7 instead of step d10, and in the case of (3), determines the number of repetitions of step d ′. By repeating step d ′ by that number, an accurate state machine diagram can be obtained.

また、ステートマシン図リバース装置100が、プログラムにしたがって動作するコンピュータによって実現されてもよい。   Moreover, the state machine diagram reverse device 100 may be realized by a computer that operates according to a program.

この場合、制御構造解析手段1、状態解析手段2、遷移解析手段3、および、ステートマシン図描画手段4は、ステートマシン図リバース装置100の動作を規定するプログラムを読み取り実行するコンピュータによって実現される。
(発明の利用が考えられる分野)
本発明を利用すれば、実装まで開発を行なったソフトウェアのソースコードに対して、状態に関するアノテーションを記述しさえすれば、リバースしてステートマシン図を自動で生成して、状態遷移の検証に利用するといった用途に適用することが可能である。
In this case, the control structure analysis unit 1, the state analysis unit 2, the transition analysis unit 3, and the state machine diagram drawing unit 4 are realized by a computer that reads and executes a program that defines the operation of the state machine diagram reverse device 100. .
(Fields where the invention can be used)
If the present invention is used, the state machine diagram is automatically generated and used for verification of the state transition as long as the annotation about the state is described in the source code of the software developed until implementation. It is possible to apply to usages such as.

本発明の一実施例であるステートマシン図リバース装置100を示したブロック図である。1 is a block diagram showing a state machine diagram reverse apparatus 100 according to an embodiment of the present invention. アノテーション付きのソースコードAの一例を示した説明図である。It is explanatory drawing which showed an example of the source code A with an annotation. 複数の制御ブロックに分割されたソースコードAの例を示した説明図である。It is explanatory drawing which showed the example of the source code A divided | segmented into the some control block. 制御ブロック木構造Bの例を示した説明図である。It is explanatory drawing which showed the example of the control block tree structure B. FIG. in/out状態付き制御ブロック木構造Cの例を示した説明図である。It is explanatory drawing which showed the example of the control block tree structure C with an in / out state. 修正されたin/out状態付き制御ブロック木構造Cの例を示した説明図である。It is explanatory drawing which showed the example of the control block tree structure C with the corrected in / out state. 遷移リストDの例を示した説明図である。6 is an explanatory diagram showing an example of a transition list D. FIG. ステートマシン図Eの例を示した説明図である。It is explanatory drawing which showed the example of state machine figure E. FIG. ステートマシン図リバース装置100の動作を説明するためのフローチャートである。FIG. 10 is a flowchart for explaining the operation of the state machine diagram reverse apparatus 100. FIG. ステートマシン図リバース装置100の動作を説明するためのフローチャートである。FIG. 10 is a flowchart for explaining the operation of the state machine diagram reverse apparatus 100. FIG. ステートマシン図リバース装置100の動作を説明するための説明図である。FIG. 7 is an explanatory diagram for explaining the operation of the state machine diagram reverse device 100.

符号の説明Explanation of symbols

1 制御構造解析手段
2 状態解析手段
3 遷移解析手段
4 ステートマシン図描画手段
5 リスト作成手段
100 ステートマシン図リバース装置
DESCRIPTION OF SYMBOLS 1 Control structure analysis means 2 State analysis means 3 Transition analysis means 4 State machine diagram drawing means 5 List creation means 100 State machine diagram reverse apparatus

Claims (4)

状態を変数として用いる処理を規定する複数のコード行と、前記複数のコード行のうち、状態の変化を表す状態変化コード行に付与された、前記変化の後の状態を表す状態宣言アノテーションと、前記複数のコード行のうち、状態に対する制御を表す制御コード行に付与された、前記制御による変化前の状態を表す条件宣言アノテーションと、を有するソースコードから、状態遷移図を作成する状態遷移図作成装置であって、
前記ソースコードを解析して前記コード行の間の対応関係を特定し、前記対応関係と、前記状態宣言アノテーションと、前記条件宣言アノテーションと、に基づいて、遷移前の状態と遷移後の状態とを対応させた遷移リストを作成するリスト作成手段と、
前記遷移リストに基づいて、前記状態遷移図を作成する状態遷移図作成手段と、を含む状態遷移図作成装置。
A plurality of code lines that define processing using a state as a variable, and a state declaration annotation that represents a state after the change, given to a state change code line that represents a change in the state among the plurality of code lines; A state transition diagram for creating a state transition diagram from a source code having a condition declaration annotation representing a state before the change by the control, which is given to a control code line representing a control for a state among the plurality of code lines. A creation device,
Analyzing the source code to identify the correspondence between the code lines, and based on the correspondence, the state declaration annotation, and the condition declaration annotation, the state before transition and the state after transition A list creation means for creating a transition list corresponding to
A state transition diagram creating device including state transition diagram creating means for creating the state transition diagram based on the transition list.
請求項1に記載の状態遷移図作成装置において、
前記リスト作成手段は、
前記ソースコードを解析して、前記ソースコードにおけるコード行の入れ子構造および前記制御コード行を特定し、前記入れ子構造および前記制御コード行に基づいて、前記ソースコードから、複数の制御ブロックと、前記制御ブロックに入るための条件と、を抽出し、前記入れ子構造に基づいて、前記制御ブロックに関する制御ブロック木構造を特定し、前記条件を、前記制御ブロック木構造内の当該条件に対応する制御ブロックに付加する制御構造解析手段と、
前記状態宣言アノテーション、前記条件宣言アノテーションおよび前記制御ブロック木構造に基づいて、前記制御ブロックごとに、当該制御ブロックがとり得る前の状態を表すイン状態リストと、当該制御ブロックがとり得る後の状態を表すアウト状態リストと、を生成し、前記制御ブロック木構造内の各制御ブロックに、対応する前記イン状態リストおよび前記アウト状態リストを付加して、イン/アウト状態付制御ブロック木構造を作成する状態解析手段と、
前記状態宣言アノテーションを有する制御ブロックについて、当該制御ブロックの、イン状態リスト、アウト状態リスト、および、条件宣言アノテーションに基づいて、前記遷移リストを作成する遷移解析手段と、を含む、状態遷移図作成装置。
In the state transition diagram creation device according to claim 1,
The list creation means includes:
Analyzing the source code to identify a code line nesting structure and the control code line in the source code, and based on the nesting structure and the control code line, from the source code, a plurality of control blocks; and And a condition for entering the control block is extracted, a control block tree structure related to the control block is specified based on the nested structure, and the condition is a control block corresponding to the condition in the control block tree structure. Control structure analysis means to be added to,
Based on the state declaration annotation, the condition declaration annotation, and the control block tree structure, for each control block, an in-state list representing a state before the control block can take, and a state after the control block can take And a control block tree structure with an in / out state is created by adding the corresponding in state list and the out state list to each control block in the control block tree structure. State analysis means to perform,
A state transition diagram creation for the control block having the state declaration annotation, including transition analysis means for creating the transition list based on the in-state list, the out-state list, and the condition declaration annotation of the control block apparatus.
状態を変数として用いる処理を規定する複数のコード行と、前記複数のコード行のうち、状態の変化を表す状態変化コード行に付与された、前記変化の後の状態を表す状態宣言アノテーションと、前記複数のコード行のうち、状態に対する制御を表す制御コード行に付与された、前記制御による変化前の状態を表す条件宣言アノテーションと、を有するソースコードから、状態遷移図を作成する状態遷移図作成装置が行う状態遷移図作成方法であって、
前記ソースコードを解析して前記コード行の間の対応関係を特定し、前記対応関係と、前記状態宣言アノテーションと、前記条件宣言アノテーションと、に基づいて、遷移前の状態と遷移後の状態とを対応させた遷移リストを作成するリスト作成ステップと、
前記遷移リストに基づいて、前記状態遷移図を作成する状態遷移図作成ステップと、を含む状態遷移図作成方法。
A plurality of code lines that define processing using a state as a variable, and a state declaration annotation that represents a state after the change, given to a state change code line that represents a change in the state among the plurality of code lines; A state transition diagram for creating a state transition diagram from a source code having a condition declaration annotation representing a state before the change by the control, which is given to a control code line representing a control for a state among the plurality of code lines. A state transition diagram creation method performed by a creation device,
Analyzing the source code to identify the correspondence between the code lines, and based on the correspondence, the state declaration annotation, and the condition declaration annotation, the state before transition and the state after transition A list creation step for creating a transition list corresponding to
A state transition diagram creating step for creating the state transition diagram based on the transition list;
請求項3に記載の状態遷移図作成方法において、
前記リスト作成ステップは、
前記ソースコードを解析して、前記ソースコードにおけるコード行の入れ子構造および前記制御コード行を特定し、前記入れ子構造および前記制御コード行に基づいて、前記ソースコードから、複数の制御ブロックと、前記制御ブロックに入るための条件と、を抽出し、前記入れ子構造に基づいて、前記制御ブロックに関する制御ブロック木構造を特定し、前記条件を、前記制御ブロック木構造内の当該条件に対応する制御ブロックに付加する制御構造解析ステップと、
前記状態宣言アノテーション、前記条件宣言アノテーションおよび前記制御ブロック木構造に基づいて、前記制御ブロックごとに、当該制御ブロックがとり得る前の状態を表すイン状態リストと、当該制御ブロックがとり得る後の状態を表すアウト状態リストと、を生成し、前記制御ブロック木構造内の各制御ブロックに、対応する前記イン状態リストおよび前記アウト状態リストを付加して、イン/アウト状態付制御ブロック木構造を作成する状態解析ステップと、
前記状態宣言アノテーションを有する制御ブロックについて、当該制御ブロックの、イン状態リスト、アウト状態リスト、および、条件宣言アノテーションに基づいて、前記遷移リストを作成する遷移解析ステップと、を含む、状態遷移図作成方法。
In the state transition diagram creation method according to claim 3,
The list creation step includes:
Analyzing the source code to identify a code line nesting structure and the control code line in the source code, and based on the nesting structure and the control code line, from the source code, a plurality of control blocks; and And a condition for entering the control block is extracted, a control block tree structure related to the control block is specified based on the nested structure, and the condition is a control block corresponding to the condition in the control block tree structure. Control structure analysis step to be added to,
Based on the state declaration annotation, the condition declaration annotation, and the control block tree structure, for each control block, an in-state list representing a state before the control block can take, and a state after the control block can take And a control block tree structure with an in / out state is created by adding the corresponding in state list and the out state list to each control block in the control block tree structure. A state analysis step to perform,
Creating a state transition diagram for a control block having the state declaration annotation, including a transition analysis step for creating the transition list based on an in-state list, an out-state list, and a condition declaration annotation of the control block Method.
JP2007035113A 2007-02-15 2007-02-15 State transition diagram creation device and state transition diagram creation method Expired - Fee Related JP4835859B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2007035113A JP4835859B2 (en) 2007-02-15 2007-02-15 State transition diagram creation device and state transition diagram creation method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2007035113A JP4835859B2 (en) 2007-02-15 2007-02-15 State transition diagram creation device and state transition diagram creation method

Publications (2)

Publication Number Publication Date
JP2008198103A true JP2008198103A (en) 2008-08-28
JP4835859B2 JP4835859B2 (en) 2011-12-14

Family

ID=39756961

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2007035113A Expired - Fee Related JP4835859B2 (en) 2007-02-15 2007-02-15 State transition diagram creation device and state transition diagram creation method

Country Status (1)

Country Link
JP (1) JP4835859B2 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012226398A (en) * 2011-04-14 2012-11-15 Fuji Electric Co Ltd Model diagram creation device, model diagram creation method, model diagram creation program, and data structure of state event table for model diagram creation
JP2013171458A (en) * 2012-02-21 2013-09-02 Fuji Electric Co Ltd Device, method and program for creating model diagram, and data structure of state event table for creating model diagram
WO2013190644A1 (en) * 2012-06-20 2013-12-27 株式会社 日立製作所 Design assistance device for control software
JP2015210735A (en) * 2014-04-28 2015-11-24 東芝ソリューション株式会社 Specification extraction device, specification extraction method and program
CN110209389A (en) * 2019-06-05 2019-09-06 卡斯柯信号(成都)有限公司 A kind of data generating tool development system based on XML

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05324289A (en) * 1992-05-20 1993-12-07 Toshiba Corp Device for automatically generating programming specification
JPH06215066A (en) * 1993-01-19 1994-08-05 Fujitsu Ltd Method and device for state transition chart
JPH1124900A (en) * 1997-06-30 1999-01-29 Canon Inc State transition diagram production device and method, and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05324289A (en) * 1992-05-20 1993-12-07 Toshiba Corp Device for automatically generating programming specification
JPH06215066A (en) * 1993-01-19 1994-08-05 Fujitsu Ltd Method and device for state transition chart
JPH1124900A (en) * 1997-06-30 1999-01-29 Canon Inc State transition diagram production device and method, and storage medium

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2012226398A (en) * 2011-04-14 2012-11-15 Fuji Electric Co Ltd Model diagram creation device, model diagram creation method, model diagram creation program, and data structure of state event table for model diagram creation
JP2013171458A (en) * 2012-02-21 2013-09-02 Fuji Electric Co Ltd Device, method and program for creating model diagram, and data structure of state event table for creating model diagram
WO2013190644A1 (en) * 2012-06-20 2013-12-27 株式会社 日立製作所 Design assistance device for control software
JPWO2013190644A1 (en) * 2012-06-20 2016-02-08 株式会社日立製作所 Design support device for control software
JP2015210735A (en) * 2014-04-28 2015-11-24 東芝ソリューション株式会社 Specification extraction device, specification extraction method and program
CN110209389A (en) * 2019-06-05 2019-09-06 卡斯柯信号(成都)有限公司 A kind of data generating tool development system based on XML

Also Published As

Publication number Publication date
JP4835859B2 (en) 2011-12-14

Similar Documents

Publication Publication Date Title
US8630824B1 (en) Comprehending waveforms of a circuit design
US9747079B2 (en) Method and system of software specification modeling
EP1749264A2 (en) An analytical software design system
US10459829B2 (en) Overall test tool migration pipeline
JP4835859B2 (en) State transition diagram creation device and state transition diagram creation method
Wille et al. Custom-tailored variability mining for block-based languages
Ferreira et al. TaRGeT: a model based product line testing tool
CN109522005A (en) Cross-platform GRAPHICAL PROGRAMMING method
Masci et al. An integrated development environment for the prototype verification system
JP2007011605A (en) Model inspection support device for software operation specification, model inspection system provided with the same, and model inspection support program
CN109062819B (en) Method and device for generating software test case
Kehrer et al. Propagation of software model changes in the context of industrial plant automation
US20160062738A1 (en) Methods and Apparatuses for Interactive Computer Programming
CN103049504A (en) Semi-automatic instrumentation method based on source code inquiring
Rahman et al. A DSL for importing models in a requirements management system
Zadahmad et al. Domain-specific model differencing in visual concrete syntax
Alsarraj et al. Designing and implementing a tool to transform source code to UML diagrams
Di Rocco et al. Bridging state-based differencing and co-evolution
Kosower et al. Flowgen: Flowchart-based documentation framework for c++
Bouaziz et al. SysML model-driven approach to verify blocks compatibility
Anjorin et al. A framework for bidirectional model-to-platform transformations
US20150199183A1 (en) Program analysis apparatus and program analysis method
JP2011165039A (en) Model debugging device and model debugging method
EP4261678A1 (en) Generation of a technical instruction
Adedjouma et al. Model-based computer-aided monitoring for ISO26262 compliant systems

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20110328

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20110622

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20110809

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

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20110913

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

Free format text: PAYMENT UNTIL: 20141007

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

LAPS Cancellation because of no payment of annual fees