JPH0628165A - Automatic code diagnostic device based upon coding rule - Google Patents

Automatic code diagnostic device based upon coding rule

Info

Publication number
JPH0628165A
JPH0628165A JP4179948A JP17994892A JPH0628165A JP H0628165 A JPH0628165 A JP H0628165A JP 4179948 A JP4179948 A JP 4179948A JP 17994892 A JP17994892 A JP 17994892A JP H0628165 A JPH0628165 A JP H0628165A
Authority
JP
Japan
Prior art keywords
rule
pattern
code
information
checking
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.)
Pending
Application number
JP4179948A
Other languages
Japanese (ja)
Inventor
Masamichi Takeuchi
正道 竹内
Yoshiaki Sasaki
良彰 佐々木
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.)
Toray Systems Center Inc
Original Assignee
Toray Systems Center Inc
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 Toray Systems Center Inc filed Critical Toray Systems Center Inc
Priority to JP4179948A priority Critical patent/JPH0628165A/en
Publication of JPH0628165A publication Critical patent/JPH0628165A/en
Pending legal-status Critical Current

Links

Abstract

PURPOSE:To provide the general device which automatically diagnoses code to be inputted to a computer after coding according to a specific grammar based on the separately defined coding rule. CONSTITUTION:This device is provided with a means 108 which decides specific conditions to be diagnosed by the specification of rule information, a means 110 which processes information to be diagnosed by the specification of the rule information, a means 111 which checks conditions that the object of diagnosis should satisfy by the specification of the rule information, and a rule control means 107 which calls the three means 108, 110, and 111 independently of one another according to the rule information. Further, this device includes a pattern check means which checks whether or not the codes satisfy rules regarding coding patterns by checking whether the codes and coding patterns match each other while comparing the rules regarding them with each other, character by character.

Description

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

【0001】[0001]

【産業上の利用分野】本発明は、ある文法に従ってコー
ディングされたプログラムソースやJCL(ジョブ制御
言語)ソースなどの、計算機に入力される命令(以下コ
ードと呼ぶ)を、別に定義したコーディング規則に基づ
いて自動的に診断する装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention makes a command (hereinafter referred to as a code) input to a computer such as a program source or a JCL (Job Control Language) source coded according to a certain grammar into a separately defined coding rule. The present invention relates to a device that automatically diagnoses based on the above.

【0002】[0002]

【従来の技術】プログラムは、コンパイラ又はアセンブ
ラによる基本的な文法上のチェックの他に、デバッグの
効率化や資源の有効利用を目的として、実際に実機にて
実行する前に、さらに論理性や保守性等の高度な観点か
らチェックしておくことが有効である。プログラムの保
守性を良くするためには、コーディングの標準化を計る
必要があり、作成されたプログラムに関し、コーディン
グスタイルをチェックしておくことが重要である。
2. Description of the Related Art In addition to basic grammatical checks by a compiler or assembler, a program is designed to be more logical and effective before it is actually executed on a real machine for the purpose of efficient debugging and effective use of resources. It is effective to check from a high point of view such as maintainability. In order to improve the maintainability of programs, it is necessary to standardize coding, and it is important to check the coding style of created programs.

【0003】このようなチェックを人間の手作業により
実施することは、見落としが発生しやすく、また多くの
時間がかかる。そのため、自動的に診断する装置がいく
つか提案されている。例えば、特開昭63−12027
号公報、特開昭63−263545号公報、特開昭63
−280344号公報、特開平3−5837号公報及び
特開平3−288226号公報に開示されたものであ
る。これらの装置は、外部に格納されたルール(コーデ
ィング規則を診断装置が解釈できる形に表現したもの)
に基づいてプログラム等のコードの記述形式を自動的に
診断するものであり、ルールを自由に書き替えられるよ
うに外部記憶方式としている。さらに、ルールの表現と
しては、簡単に変更可能とするために、簡易言語を用い
て定義することも提案されている。
Performing such a check manually by a human is easy to overlook and takes a lot of time. Therefore, some automatic diagnosis devices have been proposed. For example, JP-A-63-12027
JP-A-63-263545, JP-A-63
No. 280344, JP-A-3-5837 and JP-A-3-288226. These devices are externally stored rules (coding rules expressed in a form that the diagnostic device can interpret).
Based on the above, the description format of the code of the program etc. is automatically diagnosed, and the rules are externally stored so that the rules can be freely rewritten. Further, it has been proposed to define the rule expression by using a simple language so that it can be easily changed.

【0004】[0004]

【発明が解決しようとする課題】しかしながら、上記し
た従来技術の装置は、汎用性を高めるためにルールを外
部に登録しておき、チェック処理時に入力してくる手段
を有してはいるものの、そのルールを如何に表現するか
について深く考究したものではない。すなわち、複雑な
コーディング規則をチェックするための仕組みが用意さ
れていなかったため、ユーザがチェックしたいルールの
全てについて、コード自動診断装置を作り直すことなく
チェックできるようになった訳ではなく、限られた範囲
の中でマイナーなルールの変更や拡張が出来たに過ぎな
い。この問題は、実用上重要であり、ルールを表現する
ために設けられた機能が十分でないと、必要なルールを
表現できず、結果としてベテラン・プログラマのノウハ
ウを完全に記述しきれない。このように、ルールの変更
・拡張能力の低いコード自動診断装置は、実際の業務の
中で必要なコーディング規則を表現できないため、十分
に利用されていなかった。
However, although the above-mentioned prior art device has means for registering rules externally in order to increase versatility and inputting them at the time of check processing, It is not a deep study of how to express that rule. In other words, since there was no mechanism for checking complicated coding rules, it was not possible for the user to check all the rules that he would like to check without recreating the code automatic diagnosis device, but within a limited range. Only minor changes and extensions to the rules have been made. This problem is practically important, and if the function provided for expressing the rules is not sufficient, the necessary rules cannot be expressed, and as a result, the know-how of the experienced programmer cannot be completely described. As described above, the code automatic diagnosis device having a low rule changing / expanding ability cannot express the coding rules necessary in the actual work, and thus has not been fully utilized.

【0005】また、従来技術では、コーディングパター
ン(記述されたコードの字面)のチェックとして、字下
げ・字下げ戻しや一行に複数命令を記述した場合のチェ
ックについての機能はあったが、コード自動診断装置を
変更・拡張せずにコーディングパターンを厳密にチェッ
クできるものではなかった。従来のコード自動診断装置
では、字下げのカラム数や関数における引数定義の形
式、コメントの書き方などのコーディングパターンをそ
の書かれるカラム位置や字数に至るまで厳密に規定する
ようなルールに基づくチェックは、装置を拡張せずに実
施することはできなかった。
Further, in the prior art, as a check of the coding pattern (character face of the code described), there is a function for indentation / indentation return and a check in the case where a plurality of instructions are described in one line. It was not possible to strictly check the coding pattern without changing or expanding the diagnostic device. In the conventional code automatic diagnosis device, it is not possible to perform checks based on rules that strictly define the coding pattern such as the number of columns for indentation, the format of argument definitions in functions, and how to write comments up to the column position and the number of characters at which they are written. , Could not be implemented without expanding the device.

【0006】上記問題点を解決するためにパターンをチ
ェックする手段をコード自動診断装置に取り込むことが
考えられる。そして、パターンのチェックにおいては従
来技術として、正規表現を用いた文字列のパターンマッ
チング法があった。しかし、正規表現には、パターンの
中の特定の文字の位置を指定する方法として、行の先頭
と行の最後を表す「^」および「$」という特殊文字が
用意されているだけであった。それらの特殊文字は行の
中の最初と最後を表すだけであり、行の中の任意のカラ
ム位置を表すことができない。また、その行が何行目に
当たるかも指定できない。さらに、「^」および「$」
の使用に当たっては、「^」は正規表現の先頭、「$」
は正規表現の最後にしか使えないという制限があった。
このため例えば、「行の25カラム目から”abc”と
いう文字が並ぶ」と言うパターンは正規表現では、 /^........................abc/ と書かなければならず非常に煩わしいものであった。ま
た、例えば、「最初の行にこの記述が来るべき」といっ
た絶対的な行位置を指定するルールを表現することがで
きなかった。
In order to solve the above problems, it is conceivable to incorporate means for checking a pattern in the code automatic diagnosis device. As a conventional technique for checking patterns, there is a pattern matching method for character strings using regular expressions. However, the regular expression only provided special characters such as "^" and "$" that represent the beginning and end of a line as a method of specifying the position of a specific character in a pattern. . These special characters only represent the beginning and end of a line, and cannot represent any column position in the line. Also, it is not possible to specify which line the line hits. In addition, "^" and "$"
When using, "^" is the beginning of the regular expression, "$"
There was a restriction that could only be used at the end of a regular expression.
Therefore, for example, the pattern "the characters" abc "are arranged from the 25th column of the line" is a regular expression: / ^. . . . . . . . . . . . . . . . . . . . . . . . It had to be written as abc /, which was very annoying. In addition, for example, a rule that specifies an absolute line position such as "this description should come in the first line" could not be expressed.

【0007】また、正規表現では、文字列のパターンの
二次元的な広がりを意識して、つまりコードをプリント
アウトしたり画面表示したときのイメージのままで、そ
のパターンを表現することができなかった。例えば、 if△ . . . △△a△= . . . と言うコーディングパターンがあった場合、従来の正規
表現では、 /if△ .¥n△*a△= .*/ と一行で記述することになる。(”/”は正規表現の最
初と最後を表し、”¥n”は改行を表す。”△”又は”
_”は空白を表し、”.”は任意一文字、”*”は直前
の文字の0個以上の繰り返しを表す。)これでは、コー
ディングパターンの二次元的な広がりのイメージは全く
無くなり正規表現はただ読みにくいだけである。ま
た、”a”と言う文字が”if”の”i”から相対的に
2カラム下がった位置にあることも表現できない。この
ように、従来の正規表現では文字列のパターンの二次元
的な広がりを表すことができなかったし、無理やり一行
で表現すると相対的な字下げが表現できなくなるという
問題があった。
In addition, in the regular expression, the pattern cannot be expressed in consideration of the two-dimensional spread of the pattern of the character string, that is, the image as it is when the code is printed out or displayed on the screen. It was For example, if there is a coding pattern such as if △ ... △△ a △ = ..., in the conventional regular expression, write /if△.\n△*a△=.*/ in one line. become. ("/" Represents the beginning and end of the regular expression, and "\ n" represents a line break. "△" or "
"_" Represents a blank space, and ". "" Represents an arbitrary character and "*" represents 0 or more repetitions of the preceding character.) With this, the image of the two-dimensional spread of the coding pattern disappears at all, and the regular expression is just hard to read. It cannot be expressed that the character "a" is located two columns lower than the "i" in "if." As described above, the conventional regular expression can be used to expand the two-dimensional spread of the character string pattern. There was a problem that it was not possible to express it, and if it was forcibly expressed in one line, the relative indentation could not be expressed.

【0008】また、従来の正規表現では、「対となる記
述」のチェックができなかった。例えば、 {_a_{x}_,_b{y}_}_{_c_} −−−−−−−−−−−−−−−− というコーディングパターンにおいて、”{”、”}”
は対として用いられており、また入れ子にすることもで
きる。ここで、このコーディングパターンの下線部をマ
ッチングさせるため正規表現で、 /{_a.*}/ と記述した場合、 {_a_{x} とか {_a_{x}_,_b{y}_}_{_c_} といった対とならない括弧にマッチングしてしまうこと
があった。このように、従来の正規表現では、「対とな
る記述」とマッチさせようとして書いた記述が「対でな
い記述」とマッチングしてしまうということが度々おこ
った。このためチェックしようとしていたルールをチェ
ックすることができず、誤診断が多発するという事態が
発生した。そしてその誤診断を人間が目視でチェックを
行わなければならなかった。これは大変時間のかかる作
業であった。
Further, in the conventional regular expressions, the "paired description" cannot be checked. For example, in the coding pattern of {_a_ {x} _, _b {y} _} _ {_ c_} -------------, in the coding pattern of "{", "}"
Are used as a pair and can also be nested. Here, in order to match the underlined part of this coding pattern, a regular expression is used: / {_ a. When written as *} /, there was a case where it was matched with unpaired parentheses such as {_a_ {x} or {_a_ {x} _, _b {y} _} _ {_ c_}. As described above, in the conventional regular expressions, the description written to match the "paired description" often matches the "unpaired description". For this reason, the rule that was going to be checked could not be checked, and a situation in which misdiagnosis frequently occurred. And the human had to visually check the misdiagnosis. This was a very time-consuming task.

【0009】また、従来の正規表現では、別に定義した
パターンを正規表現のなかで再利用することができなか
った。このため同じコーディングパターンを何度もルー
ルに記述しなければならず効率が悪かった。
Further, in the conventional regular expression, it is not possible to reuse the separately defined pattern in the regular expression. Therefore, the same coding pattern had to be described in the rule many times, which was inefficient.

【0010】係る実情に鑑み、本発明の第1の目的は、
ユーザがチェックしたいルールを、コード自動診断装置
を作り直したり、そのコーディング規則をチェックする
手段を付け加えたりすることなくチェックできるような
汎用的なコード自動診断装置を提供することにある。
In view of such circumstances, the first object of the present invention is to
It is an object of the present invention to provide a general-purpose code automatic diagnosis device that allows a user to check a rule to be checked without recreating the code automatic diagnosis device or adding a means for checking the coding rule.

【0011】また、本発明の第2の目的は、「字下げの
形式」や「関数における引数定義の形式」、「コメント
の形式」などのコーディングパターンをそれらの記述さ
れるカラム位置や字数に至るまで厳密に規定するような
ルールをユーザがチェックしたいと考えた時、コード自
動診断装置を作り直したり、そのコーディング規則をチ
ェックする手段を付け加えたりすることなくチェックで
きるような汎用的なコード自動診断装置を提供すること
にある。
A second object of the present invention is to set coding patterns such as "indentation format", "argument definition format in function", and "comment format" to the column positions and the number of characters described therein. When a user wants to check a rule that strictly defines everything, a general-purpose code automatic diagnosis that can be checked without recreating the code automatic diagnosis device or adding a means for checking the coding rule To provide a device.

【0012】また、本発明の第3の目的は、コーディン
グパターンのチェックにおいて、パターンの中の特定の
文字の絶対位置を指定したパターンルールを処理するこ
とにより、パターンルールを簡潔に記述できるコード自
動診断装置を提供することにある。
A third object of the present invention is to automatically code a pattern rule by simply processing the pattern rule by designating the absolute position of a specific character in the pattern in checking the coding pattern. To provide a diagnostic device.

【0013】また、本発明の第4の目的は、コーディン
グパターンのチェックにおいて、文字列のパターンの二
次元的な広がりを意識して、書き易く読み易いパターン
ルールを記述できるコード自動診断装置を提供すること
にある。
A fourth object of the present invention is to provide an automatic code diagnosing device capable of describing a pattern rule which is easy to write and easy to read, while paying attention to the two-dimensional spread of a character string pattern in checking a coding pattern. To do.

【0014】また、本発明の第5の目的は、コーディン
グパターンのチェックにおいて、「対となる記述」のチ
ェックをすることにより、チェックしようとしていたル
ールを簡単にチェックできかつ誤診断の少ないコード自
動診断装置を提供することにある。
The fifth object of the present invention is to automatically check the rule to be checked by checking the "paired description" in checking the coding pattern, and to automatically check the code automatically. To provide a diagnostic device.

【0015】さらに、本発明の第6の目的は、コーディ
ングパターンのチェックにおいて、別に定義したパター
ンを再利用することにより、ルール記述の効率性を高め
ることのできるコード自動診断装置を提供することにあ
る。
Further, a sixth object of the present invention is to provide an automatic code diagnosing apparatus which can improve the efficiency of rule description by reusing a separately defined pattern in checking a coding pattern. is there.

【0016】[0016]

【課題を解決するための手段】上記第1の目的を達成す
るために、本発明によれば、所定の文法に従ってコーデ
ィングされて計算機に入力されるコードを、別に定義し
たコーディング規則に基づいて自動的に診断する装置に
おいて、係るコード自動診断装置を以下のように構成す
る。すなわち、本発明のコード自動診断装置は、該コー
ディング規則を該装置が解釈可能な形に表現したルール
を入力してルール情報をルールDBに格納するルール入
力手段と、該コードを解析してコード情報をコード情報
DBに格納するコード解析手段と、該ルール情報に指定
された診断対象を特定するための条件である診断対象特
定条件を該コードの特定位置が満たすかどうかを判定す
る「診断対象特定条件を判定する手段」と、該ルール情
報に指定された「診断対象情報の加工処理」を実行する
「診断対象情報を加工する手段」と、該ルール情報に指
定された「診断対象が満たすべき条件」をチェックする
「診断対象が満たすべき条件をチェックする手段」と、
該ルール情報に従って、前記「診断対象特定条件を判定
する手段」、「診断対象情報を加工する手段」及び「診
断対象が満たすべき条件をチェックする手段」をそれぞ
れ独立に呼び出すルール制御手段と、前記「診断対象特
定条件を判定する手段」、「診断対象情報を加工する手
段」及び「診断対象が満たすべき条件をチェックする手
段」が処理過程における情報を書き出し及び参照するた
めの記憶手段と、前記「診断対象が満たすべき条件」が
満たされないときに前記ルール制御手段によって呼び出
され、該ルール情報に従って診断メッセージを出力する
「診断メッセージの出力手段」と、を具備する。
To achieve the first object, according to the present invention, a code coded according to a predetermined grammar and input to a computer is automatically generated based on a separately defined coding rule. In the apparatus for diagnosing automatically, the code automatic diagnosing apparatus is configured as follows. That is, the code automatic diagnosis device of the present invention includes a rule input means for inputting a rule expressing the coding rule in a form interpretable by the device and storing rule information in a rule DB, and analyzing the code to generate a code. Code analysis means for storing information in the code information DB, and a "diagnosis target" for determining whether or not a specific position of the code satisfies a diagnosis target specifying condition that is a condition for specifying the diagnosis target specified in the rule information. "Means for determining specific conditions", "Means for processing diagnosis target information" for executing "processing of diagnosis target information" specified by the rule information, and "Satisfaction target for diagnosis specified by the rule information""Means to check the conditions that must be satisfied by the diagnosis target"
Rule control means for independently calling the "means for determining a diagnosis target specific condition", "means for processing diagnosis target information", and "means for checking conditions to be satisfied by the diagnosis target" according to the rule information; A storage unit for writing and referring to information in a processing process is provided by the "means for determining a diagnosis target specific condition", "means for processing diagnosis target information" and "means for checking conditions to be satisfied by a diagnosis target", and And a "diagnosis message output means" which is called by the rule control means when the "condition to be satisfied by the diagnosis target" is not satisfied and which outputs a diagnosis message according to the rule information.

【0017】上記第2の目的を達成するために、本発明
によれば、所定の文法に従ってコーディングされて計算
機に入力されるコードを、別に定義したコーディング規
則に基づいて自動的に診断する装置において、コードと
コーディングパターンについてのルールとを一文字ずつ
比較しながら一致するかどうかをチェックすることによ
り、コードがコーディングパターンについてのルールを
満たしているかどうかをチェックする「パターンのチェ
ック手段」を含むことを特徴とする装置が提供される。
In order to achieve the second object, according to the present invention, there is provided an apparatus for automatically diagnosing a code coded according to a predetermined grammar and input to a computer based on a separately defined coding rule. , Including a "pattern checking means" for checking whether the code satisfies the rule for the coding pattern by checking whether the code matches the rule for the coding pattern character by character. A featured device is provided.

【0018】上記第3の目的を達成するために、本発明
のコード自動診断装置は、前記「パターンのチェック手
段」が「絶対位置のチェック手段」を含む構成とする。
該「絶対位置のチェック手段」は、コーディングパター
ンのルールの中に含まれる文字や記述が、コード上のあ
る絶対位置に置かれているかどうかをチェックする手段
である。
In order to achieve the third object, the code automatic diagnosis device of the present invention is configured such that the "pattern checking means" includes "absolute position checking means".
The "absolute position checking means" is a means for checking whether or not a character or a description included in a rule of a coding pattern is placed at a certain absolute position on a code.

【0019】上記第4の目的を達成するために、本発明
のコード自動診断装置は、前記「パターンのチェック手
段」が、「二次元に広がるコーディングパターンルール
を制御する手段」を含む構成とする。該「二次元に広が
るコーディングパターンルールを制御する手段」は、二
次元的に広がるコーディングパターンルールを一行ずつ
に分解して、前の行からの相対位置の補正を行いながら
パターンル−ルのチェックを行う手段である。
In order to achieve the fourth object, the code automatic diagnosis apparatus of the present invention is configured such that the "pattern checking means" includes "means for controlling a coding pattern rule spread in two dimensions". . The "means for controlling a two-dimensionally spread coding pattern rule" is a method of checking a pattern rule while decomposing a two-dimensionally spread coding pattern rule line by line and correcting the relative position from the previous line. Is a means of performing.

【0020】上記第5の目的を達成するために、本発明
のコード自動診断装置は、前記「パターンのチェック手
段」が「対となる記述のチェック手段」を含む構成とす
る。該「対となる記述のチェック手段」は、パターンル
ールの中に対となる記述があるときに呼び出され、コー
ド上の対となる記述とルール上の対となる記述がそれぞ
れ対応していることをチェックする手段である。
In order to achieve the above fifth object, the code automatic diagnosis apparatus of the present invention is configured such that the "pattern checking means" includes "paired description checking means". The "paired description checking means" is called when there is a paired description in the pattern rule, and the paired description on the code and the paired description on the rule correspond to each other. Is a means of checking.

【0021】上記第6の目的を達成するために、本発明
のコード自動診断装置は、前記「パターンのチェック手
段」が「別のパターンルールの参照手段」を含む構成と
する。「別のパターンルールの参照手段」は、パターン
ルールの中に「別のパターンルールの参照記述」がある
ときに呼び出され、ルールDBから別のパターンルール
を取り出してきて、それに従いパターンのチェックを行
わせるための手段である。
In order to achieve the sixth object, the code automatic diagnosis apparatus of the present invention is configured such that the "pattern checking means" includes "another pattern rule reference means". The "reference means of another pattern rule" is called when there is a "reference description of another pattern rule" in the pattern rule, fetches another pattern rule from the rule DB, and checks the pattern accordingly. It is a means for making it happen.

【0022】[0022]

【作用】上記のように構成されたコード自動診断装置に
おいては、「診断対象特定条件を判定する手段」、「診
断対象情報を加工する手段」及び「診断対象が満たすべ
き条件をチェックする手段」という三つの手段が分離さ
れ、それぞれが、ルール制御手段により独立に呼び出さ
れる構成となっているので、例えば、「診断対象の特定
処理」と「診断対象情報の加工処理」を多段に繰り返す
といったことができる。従って、複雑なコーディング規
則も、「診断対象特定条件」と「診断対象情報の加工処
理」と「診断対象が満たすべき条件」の組み合わせに分
解できるので、この仕組みにより、コード自動診断装置
を作り直したり、そのコーディング規則をチェックする
手段を付け加えることなくチェックできる。
In the automatic code diagnosing device configured as described above, "means for determining a diagnosis target specifying condition", "means for processing diagnosis target information" and "means for checking conditions to be satisfied by the diagnosis target". These three means are separated and each is independently called by the rule control means. For example, it is possible to repeat the "diagnosis target identification process" and the "diagnosis target information processing process" in multiple stages. You can Therefore, even complicated coding rules can be decomposed into a combination of "diagnosis target specific conditions", "processing of diagnosis target information", and "conditions that must be satisfied by the diagnosis target". , You can check it without adding any means to check the coding rules.

【0023】また、「パターンのチェック手段」を含ん
でいるので、カラム位置や字数に至るまで厳密に規定す
るようなコーディングパターンルールを、コード自動診
断装置を作り直したり、そのコーディング規則をチェッ
クする手段を付け加えることなくチェックできる。
Further, since the "pattern checking means" is included, a means for recreating the code automatic diagnosis device or checking the coding rules for the coding pattern rules that strictly define the column position and the number of characters. You can check without adding.

【0024】さらに、「パターンのチェック手段」が
「絶対位置のチェック手段」を含んでおり、パターンの
中の特定の文字の絶対位置を指定したパターンルールを
処理することができる。従って、パターンルールを簡潔
に記述できる。また、従来記述できなかった、記述の絶
対的な行位置を指定するコーディング規則を記述でき
る。
Further, the "pattern checking means" includes "absolute position checking means", and it is possible to process the pattern rule designating the absolute position of a specific character in the pattern. Therefore, the pattern rule can be simply described. Further, it is possible to describe a coding rule that specifies an absolute line position of the description, which could not be described conventionally.

【0025】さらに、「パターンのチェック手段」が
「二次元に広がるコーディングパターンルールを制御す
る手段」を含んでおり、二次元に広がるパターンルール
を解析するので、パターンルールを一行に記述せずに、
コードをプリントアウトしたり画面表示したときのイメ
ージのままで表現することができる。従って、パターン
ルールが書き易く読み易いため、コーディング規則の記
述ミスが少なくなり、修正も簡単になる。
Further, the "pattern checking means" includes "means for controlling the coding pattern rule spread in two dimensions" and analyzes the pattern rule spread in two dimensions, so that the pattern rules are not described in one line. ,
It is possible to express the code as it is when it is printed out or displayed on the screen. Therefore, since the pattern rule is easy to write and easy to read, the description error of the coding rule is reduced and the correction is easy.

【0026】さらに、「パターンのチェック手段」が
「対となる記述のチェック手段」を含んでおり、対でな
い記述がパターンマッチするのを防ぐので、対でない記
述がパターンマッチすることによって発生する誤診断を
無くすことができる。従って、誤診断チェックのために
費やしていた多くの時間を節約することができる。
Further, the "pattern checking means" includes "paired description checking means" to prevent unmatched description from pattern matching. Therefore, an error caused by unmatched description pattern matching is prevented. The diagnosis can be eliminated. Therefore, a lot of time spent for the erroneous diagnosis check can be saved.

【0027】さらに、「パターンのチェック手段」が
「別のパターンルールの参照手段」を含んでおり、コー
ディングパターンのチェックにおいて、別に定義したパ
ターンを再利用することができる。従って、ルール記述
の効率性を高めることができ、修正も簡単にできるよう
になる。
Further, the "pattern check means" includes "another pattern rule reference means", and the separately defined pattern can be reused in the coding pattern check. Therefore, the efficiency of rule description can be improved and correction can be easily performed.

【0028】[0028]

【実施例】以下、添付図面を参照して本発明の実施例を
詳細に説明する。本発明の一実施例に係るコード自動診
断装置は、図17に示すようなマイクロコンピュータ・
システムとその上で走行するソフトウェアとで具体化さ
れる。以下の説明において、記憶手段は図17に示す主
記憶装置602で具現され、また診断メッセージの出力
手段はプリンタ出力装置604で具現される。さらにル
ール入力手段及びコード解析手段の入力機能は、入出力
端末装置603により具現され、その解析機能は、CP
U601上で走行するソフトウェアにより具現される。
また、ルールDB及びコード情報DBは、外部記憶装置
605に作成される。その他の各手段は、その機能を実
現する、CPU601上で走行するソフトウェアによっ
て具現される。
Embodiments of the present invention will now be described in detail with reference to the accompanying drawings. An automatic code diagnosis apparatus according to an embodiment of the present invention is a microcomputer / computer as shown in FIG.
It is embodied in a system and software running on it. In the following description, the storage means is implemented by the main storage device 602 shown in FIG. 17, and the diagnostic message output means is implemented by the printer output device 604. Further, the input function of the rule input means and the code analysis means is embodied by the input / output terminal device 603, and the analysis function is the CP function.
It is embodied by software running on U601.
Further, the rule DB and the code information DB are created in the external storage device 605. Each of the other means is realized by software that runs on the CPU 601 and that realizes its function.

【0029】最初に、図1に関して説明する。図1は、
本発明のコード自動診断装置の構成を示す図である。図
1において、ルール101は、予めルール入力手段10
3から入力されてルールDB104に格納される。ま
た、コード102は、コード解析手段105によって解
析されてその情報(コード情報)がコード情報DB10
6に格納される。ここでのコード解析手段105は、構
文解析手段及び文節解析手段を含んでいる。
First, description will be made with reference to FIG. Figure 1
It is a figure which shows the structure of the code automatic diagnosis apparatus of this invention. In FIG. 1, the rule 101 is the rule input means 10 in advance.
3 is input and stored in the rule DB 104. Further, the code 102 is analyzed by the code analysis means 105, and its information (code information) is code information DB10.
6 is stored. The code analysis means 105 here includes a syntax analysis means and a clause analysis means.

【0030】次に、ルール制御手段107は、ルールD
B104からルール情報を読み込む。次いで、ルール制
御手段107は、ルール情報に従って、診断対象特定条
件を判定する手段108、診断対象情報を加工する手段
110、診断対象が満たすべき条件をチェックする手段
111、をそれぞれ呼び出す。ここで、これら三つの手
段108、110、111は、コード102、コード情
報DB106、ルールDB104、という三つの情報を
参照しながら、それぞれの機能を果たす。さらに、記憶
手段109に情報を書出したり、それから情報を参照し
たりする。
Next, the rule control means 107 causes the rule D
The rule information is read from B104. Then, the rule control means 107 calls the means 108 for determining the diagnosis target specific condition, the means 110 for processing the diagnosis target information, and the means 111 for checking the conditions to be satisfied by the diagnosis target according to the rule information. Here, these three means 108, 110, 111 fulfill their respective functions with reference to the three pieces of information of the code 102, the code information DB 106, and the rule DB 104. Further, the information is written in the storage means 109, and then the information is referred to.

【0031】ルール制御手段107は、ルール情報の中
の診断対象特定条件と「コードの絶対位置」(コード上
の行、カラム位置を指定する情報)とを「診断対象特定
条件を判定する手段」108に渡す。「診断対象特定条
件を判定する手段」108は、指定された「コードの絶
対位置」から始まるコードの記述が診断対象特定条件を
満たすかどうかを判定する。満たす場合は、位置情報な
ど判定時に得た情報(「特定された診断対象情報」)を
記憶手段109に書出す。
The rule control means 107 uses the "diagnosis target specific condition" in the rule information and the "absolute position of the code" (information specifying the row and column position on the code) as "means for judging the diagnostic target specific condition". Hand it over to 108. The “means for determining the diagnosis target specifying condition” 108 determines whether the description of the code starting from the designated “absolute position of the code” satisfies the diagnosis target specifying condition. When the condition is satisfied, information such as position information obtained at the time of determination (“specified diagnosis target information”) is written in the storage unit 109.

【0032】ルール制御手段107は、ルール情報の中
の「診断対象情報の加工処理」を「診断対象情報を加工
する手段」110に渡す。「診断対象情報を加工する手
段」110は、「診断対象情報の加工処理」を実行し加
工した結果、発生した情報(診断対象加工情報)を記憶
手段109に書出す。
The rule control means 107 passes the "processing for processing the diagnosis target information" in the rule information to the "means for processing the diagnosis target information" 110. The “diagnosis target information processing unit” 110 writes the information (diagnosis target processing information) generated as a result of executing and processing the “diagnosis target information processing process” to the storage unit 109.

【0033】ルール制御手段107は、ルール情報の中
の「診断対象が満たすべき条件」を「診断対象が満たす
べき条件をチェックする手段」111に渡す。「診断対
象が満たすべき条件をチェックする手段」111は、特
定された診断対象情報、診断対象加工情報、コード情報
DB106の情報、コード102の情報、をもとに、
「診断対象が満たすべき条件」をチェックする。
The rule control means 107 passes the "condition to be satisfied by the diagnosis target" in the rule information to the "means for checking the condition to be satisfied by the diagnosis target" 111. The “means for checking conditions to be satisfied by the diagnosis target” 111 is based on the specified diagnosis target information, diagnosis target processing information, information of the code information DB 106, and information of the code 102.
Check the "conditions that the diagnostic target must meet".

【0034】そして、このチェックの結果、「診断対象
が満たすべき条件」が満たされない場合、ルール制御手
段107は、ルール情報の中の診断メッセージを「診断
メッセージの出力手段」112に渡す。「診断メッセー
ジの出力手段」112は、診断メッセージを受け取り、
記憶手段109の情報を編集して帳票や画面などに出力
する(113)。
If, as a result of this check, the "condition to be satisfied by the diagnosis target" is not satisfied, the rule control means 107 passes the diagnosis message in the rule information to the "diagnosis message output means" 112. The “diagnostic message output means” 112 receives the diagnostic message,
The information in the storage means 109 is edited and output on a form or screen (113).

【0035】図2は、図1の「診断対象特定条件を判定
する手段」108の内部構成を示す図である。図2にお
いて、外部の構成要素については、そのうちの重要な関
連の有るもののみ図示されている。省略されたからとい
って関連が無いわけではなく、特に記憶手段109と
は、図2の全ての手段と関連があるので省略されてい
る。
FIG. 2 is a diagram showing the internal structure of the "means for judging the diagnosis target specifying condition" 108 of FIG. In FIG. 2, as for the external components, only those importantly related to them are shown. It does not mean that there is no connection just because it is omitted, and in particular, the storage means 109 is omitted because it is related to all the means in FIG.

【0036】「診断対象特定条件を判定する手段」10
8が受け取った「診断対象特定条件」は、第1の論理判
定手段201によって、パターンルール、構文要素が満
たすべき属性条件、に分離され、それぞれ、パターンの
チェック手段501、構文要素が満たすべき属性条件の
チェック手段202、に渡される。パターンのチェック
手段501は、「コードの絶対位置」がパターンルール
を満たすかどうか判定する。以下、この処理をパターン
チェックと呼ぶ。また、パターンチェックによりパター
ンルールが満たされた状態をパターンがマッチした状態
と呼ぶ。パターンルールは、一般に構文情報を含んでい
るので、チェックにはコード情報DB106を参照する
必要がある。構文要素が満たすべき属性条件のチェック
手段202は、パターンがマッチした時のみ起動され、
パターンルールが含む構文要素が満たすべき属性条件を
チェックする。この時コード情報DB106を参照する
ことになる。
[Means for Determining Diagnostic Target Specific Condition] 10
The "diagnosis target specific condition" received by the 8 is separated into the pattern rule and the attribute condition that the syntax element should satisfy by the first logic determining means 201, and the pattern checking means 501 and the attribute that the syntax element should satisfy, respectively. It is passed to the condition checking means 202. The pattern checking unit 501 determines whether the “absolute position of the code” satisfies the pattern rule. Hereinafter, this process is called a pattern check. A state in which the pattern rules are satisfied by the pattern check is called a state in which the patterns match. Since the pattern rule generally includes syntax information, it is necessary to refer to the code information DB 106 for checking. The attribute condition check means 202 to be satisfied by the syntax element is activated only when the pattern matches,
Check the attribute conditions that must be satisfied by the syntax elements included in the pattern rule. At this time, the code information DB 106 is referred to.

【0037】このようにして、「パターンのチェック手
段」501と、「構文要素が満たすべき属性条件のチェ
ック手段」202と、によって、パターンルールと「構
文要素が満たすべき属性条件」についてチェックされた
結果が第1の論理判定手段201に返される。第1の論
理判定手段201は、パターンルールと「構文要素が満
たすべき属性条件」の真偽値をもとに診断対象特定条件
が真か偽かを判定し結果をルール制御手段107に返
す。
In this way, the pattern rule and the "attribute condition that the syntax element should meet" are checked by the "pattern checking means" 501 and the "attribute condition check means that the syntax element should meet" 202. The result is returned to the first logic judgment means 201. The first logic determining unit 201 determines whether the diagnostic target specific condition is true or false based on the pattern rule and the true / false value of the “attribute condition that the syntax element should satisfy”, and returns the result to the rule control unit 107.

【0038】図3は、図1の「診断対象情報を加工する
手段」110の内部構成を示す図である。図3におい
て、外部の構成要素については、そのうちの重要な関連
の有るもののみ図示されている。省略されたからといっ
て関連が無いわけではなく、特に記憶手段109とは、
図3の全ての手段と関連があるので省略されている。
FIG. 3 is a diagram showing the internal structure of the "means for processing the diagnosis object information" 110 of FIG. In FIG. 3, regarding the external components, only those importantly related to them are shown. The fact that it is omitted does not mean that there is no relation, and especially with the storage means 109,
It is omitted because it is related to all the means in FIG.

【0039】「診断対象情報を加工する手段」110が
受け取った「診断対象情報の加工処理」は、処理の振り
分け手段301によって、範囲情報の抽出処理、DB操
作処理、に分離され、それぞれ、範囲情報の抽出手段3
02、DB操作手段303、に渡される。範囲情報の抽
出手段302は、パターンルールが含む部分パターンの
範囲や、パターンルールを含む最も内側のネスト範囲、
といった範囲情報を抽出する手段である。ネスト範囲と
は、例えばC言語において対となる”{”、”}”に囲
まれた範囲である。あるネスト範囲が別のネスト範囲を
含むという多重の構造(階層構造といったほうが良いか
もしれない)になっている。構文要素に対する範囲情報
は、コード情報DB106に格納されており、これを参
照する必要がある。DB操作手段303は、コード情報
DB106に格納された情報(テーブルとして格納され
ている)を操作したり、DB操作により加工された情報
を新しいテーブルとして記憶手段109に格納する手段
である。
The "processing for processing the diagnosis target information" received by the "processing means for processing the diagnosis target information" 110 is separated into the range information extraction processing and the DB operation processing by the processing distribution means 301. Information extraction means 3
02, the DB operating means 303. The range information extracting unit 302 includes a range of partial patterns included in the pattern rule, an innermost nest range including the pattern rule,
Is a means for extracting range information. The nesting range is, for example, a range surrounded by “{” and “}” that form a pair in C language. It has a multi-layered structure (one hierarchy may be better) where one nesting scope contains another nesting scope. The range information for the syntax element is stored in the code information DB 106 and needs to be referred to. The DB operating means 303 is a means for operating the information (stored as a table) stored in the code information DB 106 and storing the information processed by the DB operation in the storage means 109 as a new table.

【0040】図4は、図1の「診断対象が満たすべき条
件をチェックする手段」111の内部構成を示す図であ
る。図4において、外部の構成要素については、そのう
ちの重要な関連の有るもののみ図示されている。省略さ
れたからといって関連が無いわけではなく、特に記憶手
段109とは、図4の全ての手段と関連があるので省略
されている。
FIG. 4 is a diagram showing the internal structure of the "means for checking the condition to be satisfied by the diagnosis target" 111 of FIG. In FIG. 4, as for the external components, only those importantly related to them are shown. It does not mean that there is no connection just because it is omitted, and in particular, the storage means 109 is omitted because it is related to all the means in FIG.

【0041】「診断対象が満たすべき条件をチェックす
る手段」111が受け取った「診断対象が満たすべき条
件」は、第2の論理判定手段404によって、パターン
ルール、比較条件、テーブル要素の配列条件、に分離さ
れ、それぞれ、パターンのチェック手段501、比較条
件のチェック手段402、テーブル要素の配列条件のチ
ェック手段403、に渡される。パターンのチェック手
段501には、診断対象特定条件により特定されたコー
ド上の位置(以下、パターンマッチ位置と呼ぶ。本実施
例では、パターンルールの第1文字がマッチした「コー
ドの絶対位置」をパターンマッチ位置としている)とパ
ターンルールとが渡され、診断対象がパターンルールを
満たすかどうか判定される。
The “condition to be satisfied by the diagnosis target” received by the “means for checking the condition to be satisfied by the diagnosis target” 111 is the pattern rule, the comparison condition, the arrangement condition of the table elements, And is passed to a pattern checking unit 501, a comparison condition checking unit 402, and a table element array condition checking unit 403, respectively. The pattern checking unit 501 indicates the position on the code specified by the diagnosis target specifying condition (hereinafter referred to as a pattern matching position. In the present embodiment, the “absolute position of the code” with which the first character of the pattern rule is matched). The pattern matching position) and the pattern rule are passed, and it is determined whether the diagnosis target satisfies the pattern rule.

【0042】比較条件のチェック手段402は、特定さ
れた診断対象情報、診断対象加工情報、コード情報DB
106の情報、コード102の情報、といった情報から
なる数値や文字列に関する比較条件式の判定を行う手段
である。特に、比較条件式の中に”NESTLEVE
L”という特殊変数が現れた場合、「ネストレベルを求
める手段」401を呼び出してパターンマッチ位置のネ
ストレベルを求める。ネストレベルとは、コード上のあ
る記述が、どの深さのネスト範囲に属するかを表すもの
で、どのネスト範囲にも属さない部分のネストレベルは
0と数える。テーブル要素の配列条件のチェック手段4
03は、テーブルのある要素(列データ)が昇順もしく
は降順に並んでいるかどうかをチェックする手段であ
る。
The comparison condition checking means 402 is provided with the specified diagnosis target information, diagnosis target processing information, and code information DB.
This is a means for determining a comparison conditional expression regarding a numerical value or a character string consisting of information such as 106 information and code 102 information. Especially, in the comparison conditional expression, "NESTLEVE
When the special variable "L" appears, the "nesting level finding means" 401 is called to find the nesting level at the pattern matching position. The nesting level represents to which depth the nesting range a certain description on the code belongs to, and the nesting level of a part which does not belong to any nesting range is counted as 0. Table element arrangement condition check means 4
Reference numeral 03 is a means for checking whether certain elements (column data) in the table are arranged in ascending or descending order.

【0043】このようにして、パターンのチェック手段
501、比較条件のチェック手段402、テーブル要素
の配列条件のチェック手段403、によって、パターン
ルール、比較条件、テーブル要素の配列条件、のチェッ
ク結果が第2の論理判定手段404に返される。第2の
論理判定手段404は、パターンルール、比較条件、テ
ーブル要素の配列条件、の真偽値をもとに「診断対象が
満たすべき条件」が真か偽かを判定し結果をルール制御
手段107に返す。
In this way, the pattern checking unit 501, the comparison condition checking unit 402, and the table element array condition checking unit 403 check the pattern rule, the comparison condition, and the table element array condition. No. 2 logic determination means 404. The second logic determination means 404 determines whether the “condition to be satisfied by the diagnosis target” is true or false based on the true / false values of the pattern rule, the comparison condition, the arrangement condition of the table elements, and the result is rule control means. Return to 107.

【0044】図5は、図2及び図4の構成要素であるパ
ターンのチェック手段501の内部構成を示す図であ
る。図5において、外部の構成要素については、そのう
ちの重要な関連の有るもののみ図示されている。省略さ
れたからといって関連が無いわけではなく、特に記憶手
段109とは、図5の全ての手段と関連があるので省略
されている。
FIG. 5 is a diagram showing the internal structure of the pattern checking means 501, which is a component of FIGS. 2 and 4. In FIG. 5, regarding the external components, only those that are importantly related are shown. It does not mean that there is no connection just because it is omitted, and in particular, the storage means 109 is omitted because it is related to all the means in FIG.

【0045】本実施例では、「二次元に広がるコーディ
ングパターンルールを制御する手段」は、「複数行のコ
ーディングパターンルールを一行に変換する手段」50
6と「相対位置のチェック手段」505を用いることに
よって実現されている。「複数行のコーディングパター
ンルールを一行に変換する手段」506は、二次元的に
広がるコーディングパターンルールを一行ずつに分解
し、行の間に前行からの相対位置を指定する特殊文字を
挿入して全てを繋ぎ合わせ一行のルールを作る手段であ
る。この「複数行のコーディングパターンルールを一行
に変換する手段」506は、「パターンのチェック手
段」501に含めることもできるしルール入力手段10
3に含めることもできる。「相対位置のチェック手段」
505は、コーディングパターンのルールの中に含まれ
る、相対位置を指定する特殊文字の次に来る文字や記述
が、コード上のパターンのチェックが始まったカラム位
置と同じカラム位置に置かれているかどうかをチェック
する(行位置は違ってよい)手段である。
In this embodiment, the "means for controlling the two-dimensionally spread coding pattern rule" is "means for converting a plurality of lines of coding pattern rules into one line".
6 and “relative position checking means” 505. "Means for converting a plurality of lines of coding pattern rules into one line" 506 decomposes a two-dimensionally spread coding pattern rule into lines, and inserts a special character that specifies a relative position from the previous line between the lines. It is a means to connect all of them together to make a single rule. This “means for converting a plurality of lines of coding pattern rules into one line” 506 can be included in the “pattern checking means” 501, and the rule input means 10
It can be included in 3. "Relative position checking means"
505 is whether the character or description following the special character that specifies the relative position included in the rule of the coding pattern is placed in the same column position as the column position where the pattern check on the code starts. Is a means of checking (row positions may be different).

【0046】先ず、「パターンのチェック手段」501
は、コードの絶対位置、パターンルール、の二つの情報
を受け取る。コードの絶対位置の情報は、記憶手段10
9に書き込まれる。この位置をパターンチェックの開始
位置と呼ぶ。パターンルールは、「複数行のコーディン
グパターンルールを一行に変換する手段」506に渡さ
れる。パターンルールを受け取った「複数行のコーディ
ングパターンルールを一行に変換する手段」506は、
パターンルールを一行に変換し、「パターンルールの制
御手段」502に渡す。一行に変換されたパターンルー
ルを受け取った「パターンルールの制御手段」502
は、一文字の一致のチェック手段503、対となる記述
のチェック手段507、絶対位置のチェック手段50
4、相対位置のチェック手段505、構文要素記述のチ
ェック手段509、別パターンルールの参照手段50
8、をそれぞれ呼び出しながらパターンルールとコード
とのマッチングのチェックを行う。一文字の一致のチェ
ック手段503は、パターンルールに含まれる一文字
(を表す記述)とコード上の文字の一文字が一致するか
どうかをチェックする手段である。構文要素記述のチェ
ック手段509は、パターンルールが”文”とか”条件
式”といった構文要素記述を含んでいる場合に呼ばれ、
チェック対象のコードの記述が、”文”とか”条件式”
といった構文要素に対応するかどうかをコード情報DB
を参照することによってチェックする手段である。
First, "pattern checking means" 501
Receives two pieces of information, the absolute position of the code and the pattern rule. Information on the absolute position of the code is stored in the storage means 10.
9 is written. This position is called the pattern check start position. The pattern rule is passed to the “means for converting a plurality of lines of coding pattern rule into one line” 506. The “means for converting a plurality of lines of coding pattern rules into one line” 506 that received the pattern rules is
The pattern rule is converted into one line and passed to the “pattern rule control means” 502. "Pattern rule control means" 502 that received the pattern rule converted into one line
Means checking means 503 for matching one character, checking means 507 for paired description, checking means 50 for absolute position
4, relative position check means 505, syntax element description check means 509, different pattern rule reference means 50
The matching of the pattern rule and the code is checked by calling 8 respectively. The one-character matching check means 503 is a means for checking whether one character (a description representing) included in the pattern rule and one character on the code match. The syntax element description checking unit 509 is called when the pattern rule includes a syntax element description such as a "sentence" or a "conditional expression".
The description of the code to be checked is "statement" or "conditional expression"
Whether or not it corresponds to syntax elements such as code information DB
It is a means of checking by referring to.

【0047】絶対位置のチェック手段504は、パター
ンルール中に”¥nn”(nnは、2桁の整数)という
特殊文字を見つけるとパターンルールのこの”¥nn”
の次の文字に対応するコード中の文字の位置が、nnカ
ラム目にあるかどうかをチェックする。また、パターン
ルール中に”¥!nnnn”(nnnnは、4桁の整
数)という特殊文字を見つけるとパターンルールのこ
の”¥!nnnn”を含む行がnnnn行目かどうかを
チェックする。例えば、「行の25カラム目から”ab
c”という文字が並ぶ」と言うパターンルールを、 /.*¥25abc/ と簡潔に記述することができる。従来技術の正規表現で
は、行頭と行末位置をチェックすることができたが、こ
れに比べ以下の利点がある。 ・行頭と行末だけでなく行中の位置を指定できる。 ・絶対的な行の位置を指定できる。 ・絶対位置の指定をパターンルールの最初と最後だけで
なくパターンルールのどこにでも指定できる。
When the special position checking means 504 finds a special character "\ nn" (nn is a two-digit integer) in the pattern rule, this "\ nn" of the pattern rule is detected.
Checks whether the position of the character in the code corresponding to the next character of is in the nnth column. When a special character "\! Nnnn" (nnnnn is a four-digit integer) is found in the pattern rule, it is checked whether the line including "\! Nnnn" in the pattern rule is the nnnn line. For example, "from the 25th column of the row" ab
The pattern rule saying "the characters" c "are lined up" is /. It can be simply written as * ¥ 25abc /. With the conventional regular expression, the line start and line end positions could be checked, but compared to this, there are the following advantages.・ You can specify not only the beginning and end of the line, but also the position within the line. -Absolute line position can be specified. -The absolute position can be specified not only at the beginning and end of the pattern rule but also anywhere in the pattern rule.

【0048】相対位置のチェック手段505は、パター
ンルール中に”¥#”という特殊文字を見つけるとパタ
ーンルールの中の”¥#”の次の文字に対応するコード
中の文字のカラム位置が、パターンチェックの開始位置
のカラム位置と同じであるかどうかをチェックする。
When the special character "\ #" is found in the pattern rule, the relative position checking means 505 determines that the column position of the character in the code corresponding to the character next to "\ #" in the pattern rule is Check whether it is the same as the column position of the pattern check start position.

【0049】対となる記述のチェック手段507は、C
言語の”{”,”}” および、”(”,”)” を対
となる記述と考え、これらの記述がパターンルール中に
現れるとパターンルールの制御手段502から呼ばれ
る。対となる記述を受け取った「対となる記述のチェッ
ク手段」507は、先ず、一文字の一致のチェック手段
503を呼び出しその対となる記述にコード中の記述が
一致するかどうかをチェックする。一致した場合は、一
致したものが、右側の記述か左側の記述かによって処理
が異なる。一致したものが、左側の記述の場
合(”{”,”(”の場合)、コード中の左側の記述と
パターンルール中の左側の記述を対応づけた情報を記憶
手段109に書き出しておく。一致したものが、右側の
記述の場合(”}”,”)”の場合) 、「コード中の右
側の記述と対になる左側の記述」と「パターンルール中
の右側の記述と対になる左側の記述」が対応付けられて
記憶手段109に書き出されているかどうかをチェック
する。これにより、対となる記述のみをパターンマッチ
させることができる。
The checking means 507 for the paired description is C
The language "{", "}" and "(", ")" are considered as paired descriptions, and when these descriptions appear in the pattern rule, they are called by the pattern rule control means 502. Upon receiving the paired description, the "paired description checking means" 507 first calls the one-character matching check means 503 to check whether the description in the code matches the paired description. If they match, the processing differs depending on whether the match is the description on the right side or the description on the left side. When the matched one is the description on the left side (in the case of "{", "("), the information in which the description on the left side in the code and the description on the left side in the pattern rule are associated with each other is written in the storage means 109. If the matched one is the description on the right side ("}", ")"), "the description on the left side that pairs with the description on the right side in the code" and "pairs the description on the right side in the pattern rule" It is checked whether the "description on the left side" is associated and written in the storage unit 109. As a result, it is possible to pattern match only the descriptions that form a pair.

【0050】ただし、「対となる記述のチェック手段」
の機能を、「コード上の対となる記述の対応を取る手
段」、「ルール上の対となる記述の対応を取る手段」、
及び、「コード上の対となる記述とルール上の対となる
記述がそれぞれ対応していることをチェックする手
段」、に分解すれば、「コード上の対となる記述の対応
を取る手段」及び「ルール上の対となる記述の対応を取
る手段」については、それぞれ、コード解析手段10
5、ルール入力手段103に含めることも可能である。
However, "means for checking paired description"
Function of "correspondence of paired description on code", "means of correspondence of paired description on rule",
And, if it is decomposed into "a means for checking that the paired description on the code and the paired description on the rule correspond to each other", "a means for making the paired description on the code correspond" And “means for taking correspondence of paired description on rule” with respect to the code analysis means 10 respectively.
5, it may be included in the rule input means 103.

【0051】別パターンルールの参照手段508は、パ
ターンルール中に別のルールが再利用されている場合
に、パターンルールの制御手段502より呼ばれる。別
パターンルールの参照手段508は、パターンルール中
に使われた別のルールをルールDB104から読み取
り、読み取ったルールの中の「『診断対象が満たすべき
条件』として記述されているパターンルール」(つま
り、ルールのCHECK部のパターンルール)が、そこ
に記述されているものとして、「パターンのチェック手
段」501を再帰的に呼び出すことによってチェックす
る。
The different pattern rule reference unit 508 is called by the pattern rule control unit 502 when another rule is reused in the pattern rule. The different pattern rule reference unit 508 reads another rule used in the pattern rule from the rule DB 104, and reads “the pattern rule described as the“ condition to be satisfied by the diagnosis target ”” in the read rule (that is, , The pattern rule of the CHECK part of the rule) is described therein and is checked by recursively calling the "pattern check means" 501.

【0052】図6は、本発明のコード自動診断装置が入
力するコードの例であって、C言語によるものである。
本コード例は、C言語によって、大きさ5のaという配
列を0で初期化する処理を2通り示したものである。C
言語では、例えば大きさ5のaという配列を次のように int a[5]; と宣言したとき、aは、a[0],a[1],…,a
[4]の5つの要素を持つ配列となる(a[5]までで
なくa[4]までである)。for文は繰り返しを記述
する構文である。ここで、for文によってこの全ての
要素を零に初期化するには、図6に示される2つのfo
r文の書き方(12から14行および16から18行)
がある。この時、配列を宣言するときは”a[5]”と
記述するのであるからfor文の終了条件も”i<5”
と同じく配列の大きさを用いて記述する方が分かり易い
と考えられる。つまり、12から14行の記述のほうが
分かり易く、16から18行の記述のほうが分かり難い
と考えられる。
FIG. 6 shows an example of a code input by the code automatic diagnosis apparatus of the present invention, which is in C language.
This code example shows two types of processing for initializing an array of size a with 0 in C language. C
In the language, for example, when an array a of size 5 is declared as int a [5]; as follows, a is a [0], a [1], ..., A
The array has five elements [4] (up to a [4] instead of up to a [5]). The for sentence is a syntax that describes repetition. Here, in order to initialize all these elements to zero by the for statement, two fo shown in FIG. 6 are used.
How to write r sentences (12 to 14 lines and 16 to 18 lines)
There is. At this time, when declaring the array, since it is described as "a [5]", the end condition of the for statement is also "i <5".
It is considered easier to describe by using the size of the array as in. In other words, the description in lines 12 to 14 is easier to understand, and the description in lines 16 to 18 is harder to understand.

【0053】図7は、本発明のコード自動診断装置が入
力するルールの例である。本ルールは、C言語の配列要
素の操作をするfor文の書き方に関するものであり、
図6の下の方のfor文の書き方(16から18行)を
禁止するというコーディング規約を記述したものであ
る。ルールは、ルール名、FIND部、PROC部、C
HECK部、MSG部、より構成されている。
FIG. 7 shows an example of rules entered by the code automatic diagnosis device of the present invention. This rule relates to how to write a for statement that operates array elements in C language,
This is a coding rule that prohibits the writing of the for statement (lines 16 to 18) in the lower part of FIG. The rules are rule name, FIND section, PROC section, C
It is composed of an HECK section and an MSG section.

【0054】1行目の部分は、ルール名である。2から
5行目と8、9行目の部分は、FIND部であり、診断
対象特定条件を指定する。6、7行目と10、11行目
の部分は、PROC部であり、診断対象情報の加工処理
を指定する。12、13行目の部分は、CHECK部で
あり、診断対象の満たすべき条件を指定する。14、1
5行目の部分は、MSG部であり、診断メッセージを指
定する。
The first line is the rule name. The portions from the 2nd to 5th rows and the 8th and 9th rows are the FIND section, and specify the diagnostic target specific condition. The 6th and 7th lines and the 10th and 11th lines are the PROC part, and specify the processing of the diagnosis target information. The 12th and 13th lines are the CHECK part, which specifies the condition to be satisfied by the diagnosis target. 14, 1
The part of the fifth line is the MSG part and specifies the diagnostic message.

【0055】3から5行目では、「0から整定数Nまで
の繰り返しを行うfor文」という診断対象特定条件が
指定されている。7行目では、「for文の繰り返し記
述に相当する複文Wの範囲をFIND範囲という特殊な
変数に代入する」という「診断対象情報の加工処理」が
指定されている。FIND範囲は、次のFIND部での
検索の範囲を指すもので、デフォルト値(既定値)はコ
ード全体である。9行目では、「for文の繰り返しの
ために用いた制御変数:I:を添え字に使っている配
列」という診断対象特定条件が指定されている。ここで
の探索範囲は、7行目で指定した、複文Wの範囲であ
る。
In the 3rd to 5th lines, the diagnostic target specific condition "for statement that repeats from 0 to integer constant N" is specified. In the 7th line, "processing of diagnostic target information" of "substituting the range of compound statement W corresponding to repeated description of for statement into a special variable called FIND range" is specified. The FIND range indicates the range of search in the next FIND section, and the default value (default value) is the entire code. In the 9th line, the diagnostic target specific condition "the array using the control variable: I: used for the repetition of the for statement as a subscript" is specified. The search range here is the range of the compound sentence W specified in the 7th line.

【0056】11行目では、「9行目で求めた配列Aの
大きさを変数Mに代入する」という「診断対象情報の加
工処理」が指定されている。13行目では、「変数Mか
ら1引いた値が、3行目にある整定数Nに一致しない」
という「診断対象の満たすべき条件」が指定されてい
る。一致した場合は、図6の16から18行の様な禁止
されるべき記述になっていると考えられるので、「診断
対象が満たすべき条件」にするためには、全体にNOT
を付けて否定する必要がある。15行目では、「診断対
象が満たすべき条件」が満たされない場合に出力される
診断メッセージを指定している。
In the 11th line, "processing of diagnostic target information" of "substituting the size of the array A obtained in the 9th line into the variable M" is specified. In the 13th line, "the value obtained by subtracting 1 from the variable M does not match the integer constant N in the 3rd line".
"Conditions to be met by the diagnosis target" are specified. If they match, it is considered that the description should be prohibited, such as lines 16 to 18 in FIG.
Need to be denied. The 15th line specifies a diagnostic message that is output when the “condition to be satisfied by the diagnosis target” is not satisfied.

【0057】図7の記述のなかで、 ・ ”/”で挟まれた記述は、パターンルールを表す記
述(以下パターン記述と呼ぶ)である。 ・ ルール中に現れる”:”で挟まれた記述には、構文
要素を表すもの、変数を表すもの、テーブルを表すも
の、別ルールを表すもの、の4種がある。このうち、構
文要素、変数、テーブルを表すものを総称して組込み記
述と呼ぶ。 ・ 組込み記述の中の”;”以降は、その記述に付けら
れた名前である。一度名前を付けられた組込み記述
は、”:名前:”という形式で参照できる。 ・ AREA( )という関数は、特定のパターン記述
のコード上での範囲を求める関数である。 ・ 構文要素を表す組込み記述は、”:構文要素名:.
属性名”という形式で書くことによりその構文要素の持
つ属性を参照できる(例:A:.大きさ)。 ・ 診断メッセージの中の%s,%dは、:I:、:
M:をそれぞれ文字列、整数として編集して表示するた
めの制御文字である。
In the description of FIG. 7, the description sandwiched between "/" is a description representing a pattern rule (hereinafter referred to as a pattern description). -There are four types of descriptions that appear between rules, which are sandwiched by ":": one that represents a syntax element, one that represents a variable, one that represents a table, and one that represents another rule. Of these, those that represent syntax elements, variables, and tables are collectively referred to as an embedded description. -The part after ";" in the embedded description is the name given to the description. Once named, the embedded description can be referenced in the form ": name:". The function AREA () is a function for obtaining the range on the code of a specific pattern description. -The built-in description representing a syntax element is ": syntax element name :.
By writing in the form of "attribute name", the attribute of the syntax element can be referenced (Example: A: .size).% S,% d in the diagnostic message are: I:,:
It is a control character for editing and displaying M: as a character string and an integer, respectively.

【0058】図8は、本発明のコード自動診断装置が出
力する診断メッセージの例であって、図6に示すコード
を図7に示すルールに基づいて診断した場合の診断メッ
セージである。ファイル名は、コードのファイル名を表
す。行番号は、コードの行番号でルールのマッチした位
置を表す。ルール番号は、チェックしたルールのルール
番号を表す。メッセージは、そのルールのMSG部が編
集されたものである。
FIG. 8 is an example of a diagnostic message output by the code automatic diagnostic apparatus of the present invention, which is a diagnostic message when the code shown in FIG. 6 is diagnosed based on the rule shown in FIG. The file name represents the file name of the code. The line number is the line number of the code and represents the matched position of the rule. The rule number represents the rule number of the checked rule. The message is a compilation of the MSG part of the rule.

【0059】図9は、本発明のコード自動診断装置にお
けるルール制御手段107の処理手順の例を表すもので
あって、図7に示すルールの場合の処理手順である。図
9の処理手順に沿って、図1から図5のコード自動診断
装置の構成と図6のコード、図7のルール、図8の診断
メッセージとの関係を説明する。
FIG. 9 shows an example of the processing procedure of the rule control means 107 in the code automatic diagnosis apparatus of the present invention, which is the processing procedure in the case of the rule shown in FIG. The relationship between the configuration of the code automatic diagnosis device of FIGS. 1 to 5 and the code of FIG. 6, the rule of FIG. 7, and the diagnostic message of FIG. 8 will be described along the processing procedure of FIG.

【0060】まず、ルール制御手段107は、図7のル
ールを読み取る。次に、ルール制御手段107は、ルー
ルのFIND部(図7の2から5行目) に指定された診
断対象特定条件を満たす部分を検索する(901、90
2、903)。
First, the rule control means 107 reads the rule shown in FIG. Next, the rule control means 107 searches for a portion satisfying the diagnosis target specifying condition designated in the FIND portion of the rule (lines 2 to 5 in FIG. 7) (901, 90).
2, 903).

【0061】手順の903では、ルール制御手段107
は、「診断対象特定条件を判定する手段」108を呼び
出してこの判断を行う。この時、「コードの絶対位置」
も渡される。そして、「診断対象特定条件を判定する手
段」108の中の第1の論理判定手段201が診断対象
特定条件を受け取る。ここで、診断対象特定条件は、パ
ターンルールのみからできているので、第1の論理判定
手段201は、パターンのチェック手段501にこのパ
ターンルールを渡す。パターンのチェック手段501
は、「コードの絶対位置」からのコードのコーディング
パターンがパターンルールに一致するかどうかを判定す
る。
In step 903, the rule control means 107
Calls the "means for determining the diagnostic target specific condition" 108 to make this determination. At this time, "absolute position of the code"
Is also passed. Then, the first logic judgment means 201 in the “means for judging the diagnosis target specifying condition” 108 receives the diagnosis target specifying condition. Here, since the diagnosis target specifying condition is made up of only the pattern rule, the first logic judging means 201 passes this pattern rule to the pattern checking means 501. Pattern checking means 501
Determines whether the coding pattern of the code from the "absolute position of the code" matches the pattern rule.

【0062】一致しない場合は、901、902のルー
プにより、「コードの絶対位置」が1カラムずつ移され
ながらチェックが行われる。「コードの絶対位置」が図
6の12行目の”for”の”f”の位置に来た時、パ
ターンルールと図6の12行目がマッチしかけるが、図
6のコードでは、for文の終了条件が”i<=5”で
なく”i<5”となっているため、マッチしない。
If they do not match, the loop of 901 and 902 is performed while shifting the "absolute position of the code" column by column. When the “absolute position of the code” comes to the position of “f” of “for” on the 12th line of FIG. 6, the pattern rule and the 12th line of FIG. 6 start to match, but in the code of FIG. Since the end condition of is "i <5" instead of "i <= 5", it does not match.

【0063】次に、「コードの絶対位置」が図6の16
行目の”for”の”f”の位置(5カラム目)に来た
時、パターンルールと図6の16から18行目がマッチ
する。そこで、「パターンマッチ位置」として16行の
5カラム目が記憶手段109に書き出される。パターン
ルール中の構文要素、 :整数;I: :整定数;N: :複文;W: は、それぞれコード(正確には、コード情報DB)中の i 4 a[i] = 0; にマッチし、この対応関係(パターンルール中での構文
要素に付けた名前とコード情報DB上の構文要素に関す
る情報との対応関係)が記憶手段109に書き出され
る。(以下、「構文要素の対応関係情報」と呼ぶ。)以
上の「パターンマッチ位置」と「構文要素の対応関係情
報」が「特定された診断対象情報」である。
Next, "absolute position of code" is 16 in FIG.
When it comes to the position of "f" (5th column) of "for" of the line, the pattern rule and the 16th to 18th lines of FIG. 6 match. Therefore, as the “pattern matching position”, the fifth column of 16 lines is written in the storage unit 109. The syntax elements in the pattern rule :: integer; I :: integer constant; N :: compound sentence; W: respectively match i 4 a [i] = 0; in the code (correctly, code information DB). This correspondence relationship (the correspondence relationship between the name given to the syntax element in the pattern rule and the information about the syntax element in the code information DB) is written in the storage means 109. (Hereinafter, referred to as “syntactic element correspondence information”.) The above “pattern matching position” and “syntax element correspondence information” are “specified diagnosis target information”.

【0064】次に、ルール制御手段107は、ルールの
PROC(図7の6、7行目)に指定された「診断対象
情報の加工処理」を、「診断対象情報を加工する手段」
110に渡して、「診断対象情報を加工する処理」90
4を行う。「診断対象情報を加工する手段」110で
は、「処理の振り分け手段」301が、「範囲情報の抽
出手段」302を呼び出し、図7の7行目の処理が実行
される。ここでは、:W:が表す図6のコードの17行
目の記述”a[i] = 0;”の範囲(17行目の9
カラムから17カラムまで)が「FIND範囲」という
特殊変数に代入される。
Next, the rule control means 107 changes the "processing of diagnosis target information" designated in the PROC (6th and 7th lines in FIG. 7) of the rule to "processing means for processing diagnosis target information".
It is passed to 110 and the "processing of processing the diagnosis target information" 90
Do 4. In the "means for processing diagnosis target information" 110, the "processing distribution means" 301 calls the "range information extraction means" 302, and the processing in the seventh line of FIG. 7 is executed. Here, the range of the description “a [i] = 0;” on the 17th line of the code in FIG. 6 represented by: W: (9 on the 17th line)
(Column to column 17) is assigned to a special variable called "FIND range".

【0065】次にまた、ルール制御手段107は、ルー
ルのFIND部(図7の8、9行目)に指定された診断
対象特定条件を満たす部分を検索する(905、90
6、907)。ここでの検索範囲は、905、906に
示すように特殊変数「FIND範囲」が示す領域とな
る。
Next, the rule control means 107 searches for a portion satisfying the diagnosis target specifying condition designated in the FIND portion of the rule (8th and 9th lines in FIG. 7) (905, 90).
6, 907). The search range here is an area indicated by the special variable “FIND range” as indicated by 905 and 906.

【0066】図7の9行目のルールは前と同じくパター
ンルールである。ここでは、前の検索で:I:と名前を
付けた構文要素つまりこの場合iを添え字として使って
いる配列が検索される。パターンのチェックの時、この
ように以前に出現した構文要素を参照する場合、「構文
要素記述のチェック手段」509が記憶手段109に書
き出されている「構文要素の対応関係情報」を参照して
以前に出現したものと同じ字面のものだけとマッチさせ
る。パターンルール中の構文要素、 :配列;A: は、コード中の a にマッチし、この「構文要素の対応関係情報」が記憶手
段109に書き出される。
The rule on the ninth line in FIG. 7 is a pattern rule as before. Here, the syntax element named: I: in the previous search, that is, the array using i as the subscript in this case, is searched. When referring to a syntax element that has previously appeared at the time of checking a pattern, the “syntax element description checking means” 509 refers to the “syntax element correspondence relationship information” written in the storage means 109. Match only those that have the same face as the ones that appeared previously. The syntax element in the pattern rule :: array; A: matches a in the code, and this “syntax element correspondence relationship information” is written to the storage unit 109.

【0067】次にまた、ルール制御手段107は、ルー
ルのPROC部(図7の10、11行目)に指定された
「診断対象情報の加工処理」を、「診断対象情報を加工
する手段」110に渡して、「診断対象情報を加工する
処理」908を行う。「診断対象情報を加工する手段」
110では、「処理の振り分け手段」301が、DB操
作手段303を呼び出し、図7の11行目の処理が実行
される。ここでは、DB操作手段303がコード情報D
B106を検索することによって、配列:A:(コード
上では、a)の”大きさ”という属性(ここでは、5と
いう値となる)が得られ、それがMという名の整数型の
変数に代入される。そしてこの整変数Mの情報は、記憶
手段109に書き出される。これが診断対象加工情報で
ある。
Next, the rule control means 107 changes the "processing of diagnosis target information" designated in the PROC section (10th and 11th lines of FIG. 7) of the rule to "means for processing diagnosis target information". The processing is passed to 110, and the “processing of processing diagnosis target information” 908 is performed. "Means for processing diagnosis target information"
In 110, the “processing distribution means” 301 calls the DB operation means 303, and the processing of the 11th line in FIG. 7 is executed. Here, the DB operating means 303 causes the code information D
By searching B106, the attribute "size" of the array: A: (a in the code) (here, the value is 5) is obtained, and this is converted into an integer type variable named M. Substituted. Then, the information of the integer variable M is written in the storage unit 109. This is the diagnosis target processing information.

【0068】次に、ルール制御手段107は、ルールの
CHECK部(図7の12、13行目)に指定された
「診断対象が満たすべき条件」を「診断対象が満たすべ
き条件をチェックする手段」111に渡し、「診断対象
が満たすべき条件」を満たすか判断を行う(909)。
「診断対象が満たすべき条件をチェックする手段」11
1では、第2の論理判定手段404が、「比較条件のチ
ェック手段」402を呼び出し、図7の13行目の括弧
内のチェックが行われる。ここでは、:N:は4、:
M:は5なので括弧内の式は”真”となる。括弧の外に
付いたNOTが、第2の論理判定手段404によって判
定され、「診断対象が満たすべき条件」は”偽”とな
る。
Next, the rule control means 107 is a means for checking the "condition to be satisfied by the diagnosis target" specified in the CHECK part of the rule (12th and 13th lines in FIG. 7). "111", and it is determined whether or not the "condition to be satisfied by the diagnosis target" is satisfied (909).
"Means for checking conditions to be satisfied by the diagnosis target" 11
In 1, the second logic judgment means 404 calls the “comparison condition check means” 402, and the check in parentheses on the 13th line in FIG. 7 is performed. Here,: N: is 4, and:
Since M: is 5, the expression in parentheses is "true". The NOT attached outside the parentheses is judged by the second logic judging means 404, and the “condition to be satisfied by the diagnosis target” is “false”.

【0069】そこで、ルール制御手段107は、ルール
のMSG部(図7の14、15行目)に指定された診断
メッセージを「診断メッセージの出力手段」112に渡
し、「診断メッセージの出力処理」910を行う。この
ようにして出力される診断メッセージが図8である。
Therefore, the rule control means 107 passes the diagnostic message specified in the MSG part of the rule (14th and 15th lines in FIG. 7) to the "diagnostic message output means" 112 and performs "diagnostic message output processing". Perform 910. The diagnostic message output in this way is shown in FIG.

【0070】このあと、ルール制御手段107は、90
5、906のループによって907の判定に戻るが、こ
の範囲には図7の7行目の条件を満たす配列はないの
で、もう一つ外側の901、902のループによって9
03の判定に戻る。ここでも、903の判定を満たすf
or文はないので901、902のループを抜けてルー
ルのチェックが終了する。
After that, the rule control means 107
Returning to the judgment of 907 by the loops of 5 and 906, there is no array satisfying the condition of the 7th row of FIG.
Return to judgment of 03. Again, f that satisfies the determination of 903
Since there is no or statement, the rule check ends by exiting the loop of 901 and 902.

【0071】図1から図5のような構成を持ち、ルール
制御手段107が、「診断対象特定条件を判定する手
段」108、「診断対象情報を加工する手段」110、
「診断対象が満たすべき条件をチェックする手段」11
1、を多段に呼び出すことによって、従来はチェックで
きなかったルールをチェックできるようになった。
1 to 5, the rule control means 107 has a "means for judging a diagnosis target specific condition" 108, a "means for processing diagnosis target information" 110,
"Means for checking conditions to be satisfied by the diagnosis target" 11
By calling 1 and multiple stages, it is now possible to check rules that could not be checked in the past.

【0072】次に、本発明のコード自動診断装置が、図
10に示すコード(C言語によるプログラム)を、図1
1〜13に示すルールに基づいて診断し、図14に示す
診断メッセージを出力する例について説明する。
Next, the code automatic diagnosing device of the present invention executes the code (program in C language) shown in FIG.
An example of diagnosing based on the rules shown in 1 to 13 and outputting the diagnostic message shown in FIG. 14 will be described.

【0073】図11のルールは、「絶対位置のチェック
手段」504を用いる例である。診断対象特定条件とし
てFIND部で、絶対位置を指定する特殊文字を含んだ
パターンルールが指定されている。これにより、パター
ンマッチ位置は、1行1カラム目に位置付けられる。次
に、「診断対象が満たすべき条件」としてCHECK部
のパターンルールが指定されている。このパターンルー
ルは、パターンマッチ位置から記述されるべき定型のコ
メント形式を表現したものである。図10のコードで
は、ルールで指定した通りのコメント形式が1行1カラ
ム目より記述されている。従って診断メッセージの出力
もない。また、パターンルールの中では、”/”や”
*”は、特殊な意味を持つので脱出記号”¥”を用い
て”¥/”,”¥*”と表すことにより単なる文字とし
ての”/”,”*”を表現している。また、” ”も”
_”も空白を表す。”_”は空白の個数を数え易くする
ために用いているものである。
The rule of FIG. 11 is an example of using the "absolute position checking means" 504. As the diagnosis target specifying condition, a pattern rule including a special character that specifies an absolute position is specified in the FIND part. As a result, the pattern matching position is located at the 1st row and 1st column. Next, the pattern rule of the CHECK part is designated as the “condition to be satisfied by the diagnosis target”. This pattern rule expresses a standard comment format to be described from the pattern matching position. In the code of FIG. 10, the comment format as specified by the rule is described from the first row and the first column. Therefore, no diagnostic message is output. Also, in the pattern rules, "/" and "
Since "*" has a special meaning, the escape symbol "\" is used to express "\ /" and "\ *" to represent "/" and "*" as simple characters. ""Also"
"_" Also represents a blank. "_" Is used to facilitate counting the number of blanks.

【0074】図12のルールは、「複数行のコーディン
グパターンルールを一行に変換する手段」506、「相
対位置のチェック手段」505、及び、「対となる記述
のチェック手段」507を用いる例である。
The rule of FIG. 12 is an example of using "means for converting a plurality of lines of coding pattern rule into one line" 506, "relative position checking means" 505, and "paired description checking means" 507. is there.

【0075】このルールは、”if文標準パターン”を
表している。まず、FIND部の指定にある「ifと任
意個の空白と左括弧」というコーディングパターンが検
索される。”(”の前にある脱出記号”¥”は、”(”
の「対となる記述」という特殊な意味を打ち消し、単な
る文字としての”(”を表現している。CHECK部で
は、if文を記述する時の標準パターンが指示されてい
る。先ず、このパターンルールに含まれている特殊文字
の説明をする。 ・ ”@”は、「任意個の空白、省略可能なコメント、
任意個の空白、改行」という記述を表す特殊文字であ
る。因みに、正規表現で表現すると、 /_*<¥/¥*.*¥*¥/>?_*¥n/ となる。 ・ ”<”,”>”は、ブロックを表す。”<...>
*”と表現すると”<”、”>”で挟まれたブロック全
体が、0回以上の任意回繰り返すことを示す。 ・ ”?”は、前の文字もしくはブロックがあってもな
くても良いことを示す。 ・ ”...@*”という風に”@”と”*”を連続し
て記述した場合は、”@”の前の1行分の記述を”
<”,”>”で挟んで”*”を付けるという意味で”
<...@>*”と同等である。特にこの変換は、「複
数行のコーディングパターンルールを1行に変換する手
段」506が、複数行のコーディングパターンルールに
相対位置を表す特殊文字を付けたものに対して行われ、
この変換ののち一行に繋ぎ合わされる。例えば、6行目
と9行目の、”△△△△:文:@*”という記述は、”
*”を除いたものに、”△*¥#△△△△:文:@”と
いう相対位置を表す特殊文字がまず付けられ、次にそれ
を”<△*¥#△△△△:文:@>*”と変換し、その
のちつなぎ合わされる。
This rule represents "if sentence standard pattern". First, the coding pattern "if and arbitrary number of blanks and left parenthesis" in the designation of the FIND section is searched. The escape symbol "\" before "(" is "("
The special meaning of "paired description" is negated, and "(" is expressed as a mere character. In the CHECK part, the standard pattern for describing the if sentence is specified. Explain the special characters included in the rules ・ "@" means "any number of blanks, optional comments,
It is a special character that represents the description "arbitrary number of blanks, line feed". By the way, when expressed by a regular expression, / _ * <\ / \ *. * \ * \ />? It becomes _ * \ n /. -"<", ">" Represent a block. ”<...
When expressed as "*", it means that the entire block sandwiched by "<" and ">" is repeated zero or more times. "" Indicates that the previous character or block may or may not be present. . . If "@" and "*" are described consecutively like "@ *", the description for one line before "@" is "
In the sense that "*" is added between <"and">"
<. . . This is equivalent to @> * ". In particular, this conversion is performed by" means for converting a multi-line coding pattern rule into one line "506 by adding a special character indicating a relative position to the multi-line coding pattern rule. To the
After this conversion, they are joined in one line. For example, the description "△△△△: Sentence: @ *" in the 6th and 9th lines is "
The special character that indicates the relative position of "△ * ¥ # △△△△: Sentence: @" is added to the one without "*", and then it is added to "<△ * \ # △△△△: Sentence. : @> * ”Is converted and then connected.

【0076】したがって、CHECK部のパターンルー
ルは、二次元的に広がっているので、「複数行のコーデ
ィングパターンルールを一行に変換する手段」506に
よって次のような一行のルールに変換される(横幅が足
りないため、便宜上複数行にわたって記述されてい
る)。 /if△(△:条件式:△)△{@<△*¥#△△△
△:文:@>*△*¥#}@△*¥#else△{@<
△*¥#△△△△:文:@>*△*¥#}@/
Therefore, since the pattern rule of the CHECK part is spread two-dimensionally, it is converted into the following one-line rule by the "means for converting a coding pattern rule of a plurality of lines into one line" (horizontal width). There is not enough, so it is written over multiple lines for convenience). / If △ (△: conditional expression: △) △ {@ < △ * ¥ # △△△
△: Sentence: @ > * △ * ¥ #} @ △ * ¥ # else △ {@ <
△ * ¥ # △△△△: Sentence: @ > * △ * ¥ #} @ /

【0077】上のパターンルールの中の”¥#”は、
「パターンチェックの開始位置」のカラム位置つまり、
パターンルールの先頭文字”i”と同じカラム位置とい
う相対位置を示す特殊文字である。”¥#”は、「相対
位置のチェック手段」505によってチェックされる。
"¥ #" in the above pattern rule is
Column position of "start position of pattern check"
It is a special character that indicates the relative position of the same column position as the first character "i" of the pattern rule. “¥ #” is checked by the “relative position checking means” 505.

【0078】このルールを図10のコードに適用する
と、51から54行目のif文の形式は文法的には正し
いが、ルールを満たしていない(if文の条件判定時の
実行文を”{”,”}”で囲んでいない)ので診断メッ
セージが出力される(図14の1行目のメッセージ)。
61から67行目のif文の形式はルールを満たしてい
る。ルールを満たすためには、ルールによりチェックさ
れるパターンとカラム位置が一つずれていても駄目であ
る。
When this rule is applied to the code of FIG. 10, the form of the if statement on lines 51 to 54 is grammatically correct, but it does not satisfy the rule (the executable statement at the time of conditional judgment of the if statement is "{ Since it is not surrounded by ","} ", a diagnostic message is output (the message on the first line in FIG. 14).
The form of the if statement on the 61st to 67th lines satisfies the rule. In order to satisfy the rule, it is useless if the pattern checked by the rule and the column position are deviated by one.

【0079】また、パターンルール中の”(”,”)”
および、”{”,”}”は、「対となる記述」であるの
で、コード中の対となる記述としかマッチしない。従っ
て、71から87行目のようにif文が多重構造になっ
ている場合にも、別のif文のelse句とマッチする
ようなことなく、必ず自身のelse句とパターンのチ
ェックが行われる。例えば、82行目では、”}”が、
1 カラムずれているためこの記述に対応する72行目か
ら始まるif文に対して診断メッセージが出力されるこ
とになる(図14の2行目のメッセージ)。
Also, "(", ")" in the pattern rule
Also, since "{", "}" is a "paired description", it matches only the paired description in the code. Therefore, even if the if statement has a multiple structure like the 71st to 87th lines, its own else clause and pattern are always checked without matching with the else clause of another if statement. . For example, in line 82, "}"
Since it is shifted by one column, a diagnostic message is output for the if statement starting from the 72nd line corresponding to this description (the message on the 2nd line in FIG. 14).

【0080】このように、「パターンのチェック手段」
501により厳密なコーディングパターンルールのチェ
ックができる。また、コーディングパターンルールは常
に厳しい訳でなく、パターンルール中の ・ ”△”を”△*”に置き換えたり(1つの空白を任
意個の空白で良しとする) ・ 字下げにおける”△△△△”を”<△△>*”に置
き換える(4カラム字下げを偶数カラムの字下げで良し
とする)などすることにより、パターンルールの厳しさ
を自由自在に緩めることができる。
In this way, "pattern checking means"
By 501, a strict coding pattern rule can be checked. In addition, the coding pattern rule is not always strict. In the pattern rule, "△" is replaced with "△ *" (one blank is acceptable with any number of blanks) ・ "△△△ in indentation" By replacing “Δ” with “<ΔΔ> *” (the indentation of four columns is considered to be indentation of even columns), the strictness of the pattern rule can be freely relaxed.

【0081】図13のルールは、「別パターンルールの
参照手段」502を用いる例である。このルールでは、
FIND部のパターンルールで、別パターンルール”i
f文標準パターン”を参照している。これは、図12で
示したルールである。このように別パターンルールを参
照すると、「別パターンルールの参照記述」の部分(こ
の場合、図13のFIND部)に、参照されたルールの
CHECK部のパターンルール(この場合、図12のC
HECK部のパターンルール)が書かれているかのよう
に動作する。このパターンルールのチェックは、「パタ
ーンルールの制御手段」502が、「別パターンルール
の参照手段」508を呼び出すことによって行われる。
「別パターンルールの参照手段」508は、ルールDB
104を検索して別パターンルール(この場合、”if
文標準パターン”)を見つけると、CHECK部のパタ
ーンルールと現在の「コードの絶対位置」をパラメータ
として「パターンのチェック手段」501を再帰的に呼
び出すことにより、パターンのチェックを行う。こうし
て、診断対象が特定されると、次に図13のCHECK
部がチェックされる。ここで、NESTLEVELとい
う特殊変数は、パターンマッチ位置、この場合、”if
文標準パターン”の”i”がマッチした位置のネストレ
ベルを表す。これは、「ネストレベルを求める手段」4
01によって求められる。図10の場合、74行目から
始まるif文は、ネストレベルが4となっているため条
件を満たさず、図14の3行目の診断メッセージが出力
される。
The rule of FIG. 13 is an example of using the “reference means of another pattern rule” 502. In this rule,
In the pattern rule of the FIND section, another pattern rule "i
The "f sentence standard pattern" is referred to. This is the rule shown in Fig. 12. When the different pattern rule is referred to in this way, the "reference description of the different pattern rule" portion (in this case, Fig. 13). FIND part), the pattern rule of the CHECK part of the referenced rule (in this case, C of FIG. 12).
It operates as if the pattern rule of the HECK part) is written. This pattern rule check is performed by the “pattern rule control means” 502 calling the “different pattern rule reference means” 508.
“Reference means of another pattern rule” 508 is a rule DB
104 to search for another pattern rule (in this case, "if
When the sentence standard pattern ") is found, the pattern is checked by recursively calling the" pattern checking means "501 with the pattern rule of the CHECK part and the current" absolute position of the code "as parameters. In this way, when the diagnosis target is specified, next, CHECK in FIG.
The department is checked. Here, the special variable NESTLEVEL is the pattern matching position, in this case, "if
It represents the nesting level at the position where the "i" of the sentence standard pattern "matches. This is the" means for finding the nesting level "4
01. In the case of FIG. 10, the if statement starting on the 74th line does not satisfy the condition because the nesting level is 4, and the diagnostic message on the 3rd line of FIG. 14 is output.

【0082】こうして、コード中の絶対的な行カラム位
置を指定してそこに記述されるべきコーディングパター
ンのチェックをすることができる。また、二次元的に広
がったコーディングパターンルールをそのままの形で記
述できるので、書き易く読み易いコーディングパターン
ルールを記述することができる。また、「パターンのチ
ェック手段」501により厳密なコーディングパターン
規約のチェックができる。また、パターンルールの厳し
さを緩めることも自由自在である。また、「対となる記
述のチェック手段」507により多重構造になっている
コーディングパターンにおいても対応する記述がコーデ
ィングパターンルールを満たしているかどうかチェック
できる。つまり、対応しない記述とマッチして不必要な
診断メッセージを出力するという誤診断を回避できるの
で、誤診断を確認するための時間を節約できる。さら
に、別パターンルールを再利用することが出来るので、
コーディングパターンルールを簡潔に表現でき、かつ修
正も簡単になる。
In this way, it is possible to specify the absolute row and column position in the code and check the coding pattern to be described therein. Also, since the coding pattern rules spread two-dimensionally can be described as they are, coding pattern rules that are easy to write and easy to read can be described. In addition, the strict coding pattern rule can be checked by the "pattern check means" 501. In addition, the strictness of pattern rules can be relaxed freely. In addition, it is possible to check whether or not the corresponding description satisfies the coding pattern rule even in the coding pattern having the multiple structure by the “paired description checking means” 507. In other words, it is possible to avoid erroneous diagnosis in which an unnecessary diagnostic message is output by matching a description that does not correspond, and thus it is possible to save time for confirming the erroneous diagnosis. In addition, you can reuse another pattern rule,
Coding pattern rules can be expressed concisely and can be easily modified.

【0083】次に、本発明のコード自動診断装置によっ
て処理可能な、図15、16に示すルールについて説明
する。図15は、本実施例の構成によりコーディングパ
ターンルールだけでなく利用者定義語の命名規約のチェ
ックができることを示したルール例である。FIND部
は、パターンルールと「構文要素が満たすべき属性条
件」の論理結合によりできている。「構文要素が満たす
べき属性条件」は、「構文要素が満たすべき属性条件の
チェック手段」202によりチェックされる。CHEC
K部は、比較条件の形をしているが、右辺がパターンル
ールの形をしていることから、パターンチェックである
ことがわかる。こういった場合、「比較条件のチェック
手段」402は、「パターンのチェック手段」501を
呼び出してチェックを行う。このルールにより、ポイン
タ型関数は、”pf”で始まっていなければならないと
いう命名規約がチェックされる。
Next, the rules shown in FIGS. 15 and 16 that can be processed by the code automatic diagnosis device of the present invention will be described. FIG. 15 is a rule example showing that not only the coding pattern rule but also the naming convention of the user-defined word can be checked by the configuration of this embodiment. The FIND part is made up of a logical combination of pattern rules and "attribute conditions that the syntax element must satisfy". The “attribute condition to be satisfied by the syntax element” is checked by the “attribute condition check means to be satisfied by the syntax element” 202. CHEC
Part K has the shape of the comparison condition, but the right side has the shape of the pattern rule, which indicates that the pattern check is performed. In such a case, the “comparison condition check means” 402 calls the “pattern check means” 501 to perform the check. This rule checks the naming convention that pointer-type functions must start with "pf".

【0084】また、「特定された診断対象情報」や、そ
れを加工した情報に対して、例えば、文字列の連結や部
分文字列の抽出もしくは、プリフィックス(接頭語)や
ポストフィックス(接尾語)の除去といった文字列操作
を行う文字列操作手段を、「診断対象情報を加工する手
段」110に含むことによって、より強力な命名規約の
チェックをすることができる。
Further, with respect to the "specified diagnosis target information" and the information obtained by processing the information, for example, concatenation of character strings, extraction of partial character strings, or prefix (prefix) or postfix (suffix) By including a character string operation means for performing a character string operation such as removal of "in the means for processing the diagnosis target information" 110, a stronger naming convention can be checked.

【0085】図16は、本実施例の構成によりコード上
での利用者定義語の定義順のチェックができることを示
したルール例である。ここでは、「関数名が定義された
あとに変数名の定義が来るべき」というルールを表現し
たものである。PROC部において、まず、属性と順位
をペアにしたテーブルAを作り、次に、コード情報DB
106にある利用者定義語が定義順に収まっている利用
者語テーブルとテーブルAを結合して、「利用者定義語
の字面」と「テーブルAの順位」がペアとなったテーブ
ルCを作る。以上の処理は、DB操作手段303により
行われる。CHECK部において、テーブルCの2列目
が、昇順(Aは昇順を表す)かどうかチェックされる。
CHECKORDER( )は、「テーブル要素の配列
条件のチェック手段」403が提供する関数であり、テ
ーブル要素の配列条件のチェックができる。
FIG. 16 is an example of a rule showing that the definition order of the user-defined words on the code can be checked by the configuration of this embodiment. Here, the rule "the definition of the variable name should come after the function name is defined" is expressed. In the PROC section, first, a table A in which attributes and ranks are paired is created, and then the code information DB
The user word table in which the user defined words in 106 are stored in the order of definition is combined with the table A to create a table C in which the “character surface of the user defined word” and the “rank of the table A” are paired. The above processing is performed by the DB operating means 303. In the CHECK part, it is checked whether the second column of table C is in ascending order (A represents ascending order).
CHECKKORDER () is a function provided by "means for checking arrangement condition of table element" 403 and can check arrangement condition of table element.

【0086】こうして、「パターンのチェック手段」5
01を用いてコーディングパターンルールだけでなく利
用者定義語の命名規約のチェックができる。また、DB
操作手段303と「テーブル要素の配列条件のチェック
手段」403を用いて、コード上での利用者定義語の定
義順のチェックができる。
Thus, the "pattern checking means" 5
01 can be used to check not only coding pattern rules but also user-defined word naming conventions. Also, DB
It is possible to check the definition order of the user-defined words on the code by using the operation means 303 and the "table element arrangement condition checking means" 403.

【0087】「診断対象情報を加工する手段」110
が、「特定された診断対象情報」や、それを加工した情
報に対して、例えば、数値を表す文字列を数値変数に変
換したり逆に数値変数を数値を表す文字列に変換すると
いった属性変換を行う属性変換手段、また、「特定され
た診断対象情報」や、それを加工した情報の中の数値デ
ータに対して四則演算などをおこなって新しいデータに
加工する数値演算手段、さらに、「特定された診断対象
情報」や、それを加工した情報の中のテーブル(コード
情報DBの情報のうち、ある条件を満たすものを集めて
コード上での出現順に並べたもの)のデータに対して例
えば、ソート処理をおこなって新しいデータに加工する
ソート処理手段、といった手段を含んでいると、ルール
のチェック能力がさらに強化される。
“Means for processing diagnosis target information” 110
However, for the "specified diagnosis target information" and the processed information, for example, an attribute such as converting a character string representing a numerical value into a numerical variable or conversely converting a numerical variable into a character string representing a numerical value. Attribute conversion means for performing conversion, numerical operation means for performing four arithmetic operations on the "specified diagnosis target information" and the numerical data in the processed information to process it into new data. "Specified diagnosis target information" or data in a table in which information is processed (of information in the code information DB that meets certain conditions and is arranged in the order of appearance in the code) For example, if a means such as a sort processing means for performing sort processing and processing into new data is included, the rule checking ability is further enhanced.

【0088】また、「診断対象情報を加工する手段」1
10に含まれる「診断対象が存在すべきネストレベル
(階層記述の深さ)を指定する手段」が、「診断対象特
定条件を判定する手段」108にも含まれていれば、さ
らに診断対象の特定能力を強化できる。
Further, "means for processing information to be diagnosed" 1
If the “means for designating the nesting level (depth of the hierarchical description) in which the diagnostic target should exist” included in 10 is also included in the “means for determining the diagnostic target specific condition” 108, the diagnostic target You can strengthen certain abilities.

【0089】コード解析手段が、コードの行数やコード
が含む呼び出し関数の数などを計数する計数手段を含ん
でいると、ルールのチェック能力がさらに強化される。
If the code analysis means includes counting means for counting the number of lines of code and the number of calling functions included in the code, the rule checking ability is further enhanced.

【0090】[0090]

【発明の効果】以上説明したように、本発明に係るコー
ド自動診断装置は、以下のような効果を有する。 (1) コーディングルールの記述能力を大幅に高める
ことができる。すなわち、従来のコード自動診断装置で
は、装置に特定のルールのチェック手段を追加せずには
チェック出来なかった複雑なコーディングルールを装置
の変更や拡張をせずにチェックできる。これにより、客
観的もしくは論理的に正当性を証明出来ないような専門
家の勘とか主観とも言うべき(微妙な、 もしくは凝っ
た)経験則をコーディングルールとして記述できる。こ
ういったベテランプログラマのコーディングノウハウを
コーディングルールとして表現できることにより、この
コード自動診断装置を使う初心者により良いコーディン
グスタイルを指導できる。
As described above, the code automatic diagnosis device according to the present invention has the following effects. (1) The ability to describe coding rules can be significantly improved. That is, in the conventional code automatic diagnosis device, a complicated coding rule, which cannot be checked without adding a check means for a specific rule to the device, can be checked without changing or expanding the device. As a result, it is possible to describe as a coding rule an expert's intuition or subjective (subtle or elaborate) empirical rule that cannot objectively or logically prove correctness. By expressing the coding know-how of such an experienced programmer as a coding rule, it is possible to teach a good coding style to a beginner who uses this automatic code diagnosis device.

【0091】(2) コーディングパターンの厳密なチ
ェックができる。すなわち、行・カラムの位置に至るま
でチェック出来るので人によるコーディングパターンの
差異がでなくなるような厳密なコーディング規約のチェ
ックができる。これにより、コーディングパターンの標
準化を徹底できる。 (3) パターンルールの中に絶対位置の指定ができる
ので、コーディングパターンのルールを簡潔に表現でき
る。 (4) 従来診断できなかった、コーディングパターン
の置かれるべき絶対的な行位置の指定ができる。 (5) コーディングパターンの二次元的な広がりをそ
のままコーディングパターンのルールとして表現できる
ので、ルールを記述し易く、また、読み易い。これによ
り、ルールの記述ミスや修正ミスを防ぐことができると
共に診断対象であるコードとの対比も容易となる。
(2) A strict check of the coding pattern can be performed. In other words, since it is possible to check up to the position of the row / column, it is possible to check a strict coding rule so that there is no difference in coding patterns between people. This makes it possible to thoroughly standardize coding patterns. (3) Since the absolute position can be specified in the pattern rule, the coding pattern rule can be expressed simply. (4) It is possible to specify an absolute line position where a coding pattern should be placed, which could not be conventionally diagnosed. (5) Since the two-dimensional spread of the coding pattern can be expressed as it is as the rule of the coding pattern, the rule is easy to write and easy to read. This makes it possible to prevent a description error or a correction error in the rule and facilitate comparison with the code to be diagnosed.

【0092】(6) ルールの対の記述をコードの対の
記述だけとマッチングさせることができるので、人間の
感覚通りのルールを表現でき、誤動作を防ぎ、誤動作を
分析するために必要な多くの時間を倹約できる。 (7) コーディングルールを幾つかのチェック処理や
データの加工処理の組み合わせとして表現するためルー
ルの内容が厳密且つ客観的に表現される。すなわち、利
用者は、ルールによりチェックされる内容を勘違いする
ことなくルールの修正や追加, 削除をスムーズに行うこ
とができる。 (8) 一度定義したルールを再利用することにより、
以下の効果がある。すなわち、何度も現れるルールの記
述を部品化してルールの記述効率を高めることができ
る。また、同じ記述が何度も現れないので、ルールの修
正や追加, 削除を行う時も一箇所だけ修正すればよく、
ルールの保守性が高まる。さらに、利用者は、今までに
定義されたルールを組み合わせることによってより高度
なルールを簡単に記述出来る。
(6) Since the description of the pair of rules can be matched only with the description of the pair of codes, it is possible to express the rule as perceived by a human, prevent malfunction, and analyze many malfunctions required. You can save time. (7) Since the coding rule is expressed as a combination of some check processing and data processing, the content of the rule is expressed strictly and objectively. That is, the user can smoothly modify, add, or delete the rule without misunderstanding what is checked by the rule. (8) By reusing the rule once defined,
It has the following effects. That is, the description of a rule that appears many times can be made into a component to improve the description efficiency of the rule. Also, since the same description does not appear many times, you only have to modify one place when modifying, adding or deleting rules,
The maintainability of rules increases. Furthermore, the user can easily write more sophisticated rules by combining the rules defined so far.

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

【図1】本発明のコード自動診断装置の構成を示す図で
ある。
FIG. 1 is a diagram showing a configuration of an automatic code diagnosis device of the present invention.

【図2】図1の「診断対象特定条件を判定する手段」の
内部構成を示す図である。
FIG. 2 is a diagram showing an internal configuration of a “means for determining a diagnosis target specifying condition” in FIG.

【図3】図1の「診断対象情報を加工する手段」の内部
構成を示す図である。
FIG. 3 is a diagram showing an internal configuration of a “means for processing diagnosis object information” in FIG. 1.

【図4】図1の「診断対象が満たすべき条件をチェック
する手段」の内部構成を示す図である。
FIG. 4 is a diagram showing an internal configuration of “means for checking conditions to be satisfied by a diagnosis target” in FIG. 1.

【図5】図2及び図4の「パターンのチェック手段」の
内部構成を示す図である。
FIG. 5 is a diagram showing an internal configuration of a “pattern check unit” shown in FIGS. 2 and 4;

【図6】本発明のコード自動診断装置が入力するコード
の第1の例を示す図である。
FIG. 6 is a diagram showing a first example of a code input by the automatic code diagnosis device of the present invention.

【図7】本発明のコード自動診断装置が入力するルール
の第1の例を示す図である。
FIG. 7 is a diagram showing a first example of rules entered by the code automatic diagnosis device of the present invention.

【図8】本発明のコード自動診断装置が出力する診断メ
ッセージの第1の例を示す図である。
FIG. 8 is a diagram showing a first example of a diagnostic message output by the code automatic diagnostic device of the present invention.

【図9】本発明のコード自動診断装置におけるルール制
御手段の処理手順の例を示す図である。
FIG. 9 is a diagram showing an example of a processing procedure of rule control means in the code automatic diagnosis device of the present invention.

【図10】本発明のコード自動診断装置が入力するコー
ドの第2の例を示す図である。
FIG. 10 is a diagram showing a second example of a code input by the automatic code diagnosis device of the present invention.

【図11】本発明のコード自動診断装置が入力するルー
ルの第2の例を示す図である。
FIG. 11 is a diagram showing a second example of a rule input by the code automatic diagnosis device of the present invention.

【図12】本発明のコード自動診断装置が入力するルー
ルの第3の例を示す図である。
FIG. 12 is a diagram showing a third example of a rule input by the code automatic diagnosis device of the present invention.

【図13】本発明のコード自動診断装置が入力するルー
ルの第4の例を示す図である。
FIG. 13 is a diagram showing a fourth example of a rule input by the code automatic diagnosis device of the present invention.

【図14】本発明のコード自動診断装置が出力する診断
メッセージの第2の例を示す図である。
FIG. 14 is a diagram showing a second example of a diagnostic message output by the code automatic diagnostic device of the present invention.

【図15】本発明のコード自動診断装置が入力するルー
ルの第5の例を示す図である。
FIG. 15 is a diagram showing a fifth example of a rule input by the code automatic diagnosis device of the present invention.

【図16】本発明のコード自動診断装置が入力するルー
ルの第6の例を示す図である。
FIG. 16 is a diagram showing a sixth example of rules input by the code automatic diagnosis device of the present invention.

【図17】本発明のコード自動診断装置をマイクロコン
ピュータ・システムとして構成した場合の一実施例を示
す概略ブロック図である。
FIG. 17 is a schematic block diagram showing an embodiment in which the code automatic diagnosis device of the present invention is configured as a microcomputer system.

【符号の説明】 101…ルール 102…コード 103…ルール入力手段 104…ルールDB 105…コード解析手段 106…コード情報DB 107…ルール制御手段 108…診断対象特定条件を判定する手段 109…記憶手段 110…診断対象情報を加工する手段 111…診断対象が満たすべき条件をチェックする手段 112…診断メッセージの出力手段 113…診断メッセージ 201…第1の論理判定手段 202…構文要素が満たすべき属性条件のチェック手段 301…処理の振り分け手段 302…範囲情報の抽出手段 303…DB操作手段 401…ネストレベルを求める手段 402…比較条件のチェック手段 403…テーブル要素の配列条件のチェック手段 404…第2の論理判定手段 501…パターンのチェック手段 502…パターンルールの制御手段 503…一文字の一致のチェック手段 504…絶対位置のチェック手段 505…相対位置のチェック手段 506…複数行のコーディングパターンルールを一行に
変換する手段 507…対となる記述のチェック手段 508…別パターンルールの参照手段 509…構文要素記述のチェック手段 601…CPU 602…主記憶装置 603…入出力端末装置 604…プリンタ出力装置 605…外部記憶装置
[Explanation of Codes] 101 ... Rule 102 ... Code 103 ... Rule Input Means 104 ... Rule DB 105 ... Code Analysis Means 106 ... Code Information DB 107 ... Rule Control Means 108 ... Means for Determining Diagnostic Target Specific Condition 109 ... Storage Means 110 ... means for processing information to be diagnosed 111 ... means for checking conditions to be satisfied by the diagnosis object 112 ... means for outputting diagnostic message 113 ... diagnostic message 201 ... first logical determination means 202 ... check for attribute condition to be satisfied by syntax element Means 301 ... Process distribution means 302 ... Range information extraction means 303 ... DB operation means 401 ... Nest level finding means 402 ... Comparison condition checking means 403 ... Table element array condition checking means 404 ... Second logical judgment Means 501 ... Pattern checking means 02 ... Pattern rule control means 503 ... One character matching check means 504 ... Absolute position check means 505 ... Relative position check means 506 ... Multiple-line coding pattern rule conversion means 507 ... Paired description Checking means 508 ... Reference means for another pattern rule 509 ... Checking means for syntax element description 601 ... CPU 602 ... Main storage device 603 ... Input / output terminal device 604 ... Printer output device 605 ... External storage device

Claims (6)

【特許請求の範囲】[Claims] 【請求項1】 所定の文法に従ってコーディングされて
計算機に入力されるコード(102)を、別に定義した
コーディング規則に基づいて自動的に診断する装置であ
って、該装置は、 該コーディング規則を該装置が解釈可能な形に表現した
ルール(101)を入力してルール情報をルールDB
(104)に格納するルール入力手段(103)と、 該コード(102)を解析してコード情報をコード情報
DB(106)に格納するコード解析手段(105)
と、 該ルール情報に指定された診断対象を特定するための条
件である診断対象特定条件を該コード(102)の特定
位置が満たすかどうかを判定する「診断対象特定条件を
判定する手段」(108)と、 該ルール情報に指定された「診断対象情報の加工処理」
を実行する「診断対象情報を加工する手段」(110)
と、 該ルール情報に指定された「診断対象が満たすべき条
件」をチェックする「診断対象が満たすべき条件をチェ
ックする手段」(111)と、 該ルール情報に従って、前記「診断対象特定条件を判定
する手段」(108)、「診断対象情報を加工する手
段」(110)及び「診断対象が満たすべき条件をチェ
ックする手段」(111)をそれぞれ独立に呼び出すル
ール制御手段(107)と、 前記「診断対象特定条件を判定する手段」(108)、
「診断対象情報を加工する手段」(110)及び「診断
対象が満たすべき条件をチェックする手段」(111)
が処理過程における情報を書き出し及び参照するための
記憶手段(109)と、 前記「診断対象が満たすべき条件」が満たされないとき
に前記ルール制御手段(107)によって呼び出され、
該ルール情報に従って診断メッセージ(113)を出力
する「診断メッセージの出力手段」(112)と、 を具備する、コーディング規則に基づくコード自動診断
装置。
1. A device for automatically diagnosing a code (102) coded according to a predetermined grammar and input to a computer based on a separately defined coding rule, the device comprising: Enter the rule (101) expressed in a format that can be interpreted by the device and write the rule information to the rule DB
Rule input means (103) for storing in (104) and code analyzing means (105) for analyzing the code (102) and storing code information in the code information DB (106).
And a "means for determining a diagnostic target specific condition" for determining whether a specific position of the code (102) satisfies a diagnostic target specific condition that is a condition for specifying a diagnostic target specified in the rule information ( 108) and the "processing of diagnosis target information" specified in the rule information.
"Means for processing information to be diagnosed" for executing (110)
And "means for checking conditions to be satisfied by the diagnosis target" (111) specified in the rule information, and "determining the diagnosis target specific condition" according to the rule information. Rule control means (107) for independently calling "means for performing" (108), "means for processing information to be diagnosed" (110) and "means for checking conditions to be satisfied by the diagnosis target" (111), Means for determining the diagnostic target specific condition "(108),
"Means for processing information to be diagnosed" (110) and "Means for checking conditions to be met by diagnosis object" (111)
A storage unit (109) for writing and referring to information in the processing process, and called by the rule control unit (107) when the "condition to be met by the diagnosis target" is not satisfied,
An automatic code diagnostic device based on a coding rule, comprising: "diagnostic message output means" (112) for outputting a diagnostic message (113) according to the rule information.
【請求項2】 所定の文法に従ってコーディングされて
計算機に入力されるコード(102)を、別に定義した
コーディング規則に基づいて自動的に診断する装置にお
いて、 該装置は、コードとコーディングパターンについてのル
ールとを一文字ずつ比較しながら一致するかどうかをチ
ェックすることにより、該コード(102)がコーディ
ングパターンについてのルールを満たしているかどうか
をチェックする「パターンのチェック手段」(50
1)、を含むことを特徴とする、コーディング規則に基
づくコード自動診断装置。
2. A device for automatically diagnosing a code (102) coded according to a predetermined grammar and input to a computer based on a separately defined coding rule, the device comprising a rule for a code and a coding pattern. A "pattern checking means" (50) for checking whether or not the code (102) satisfies the rule for the coding pattern by comparing and matching one by one character.
1) An automatic code diagnosing device based on a coding rule, including:
【請求項3】 前記「パターンのチェック手段」(50
1)は、 コーディングパターンのルールの中に含まれる文字や記
述が、コード上のある絶対位置に置かれているかどうか
をチェックする「絶対位置のチェック手段」(50
4)、 を含む請求項2記載のコーディング規則に基づくコード
自動診断装置。
3. The "pattern checking means" (50
1) is "absolute position checking means" (50) for checking whether or not a character or description included in a rule of a coding pattern is placed at a certain absolute position on the code.
4), The code automatic diagnosis device based on the coding rule according to claim 2.
【請求項4】 前記「パターンのチェック手段」(50
1)は、 二次元的に広がるコーディングパターンルールを一行ず
つに分解して、前の行からの相対位置の補正を行いなが
らパターンル−ルのチェックを行う「二次元に広がるコ
ーディングパターンルールを制御する手段」(506、
505)、 を含む請求項2記載のコーディング規則に基づくコード
自動診断装置。
4. The “pattern checking means” (50
In 1), the coding pattern rule that spreads two-dimensionally is decomposed line by line, and the pattern rule is checked while correcting the relative position from the previous line. Means "(506,
505), The code automatic diagnosis device based on the coding rule according to claim 2.
【請求項5】 前記「パターンのチェック手段」(50
1)は、 パターンルールの中に対となる記述があるときに呼び出
され、コード上の対となる記述とルール上の対となる記
述がそれぞれ対応していることをチェックする「対とな
る記述のチェック手段」(507)、 を含む請求項2記載のコーディング規則に基づくコード
自動診断装置。
5. The "pattern checking means" (50
1) is called when there is a paired description in the pattern rule, and checks that the paired description on the code and the paired description on the rule correspond to each other. Automatic checking device based on the coding rule according to claim 2, further comprising: "checking means" (507).
【請求項6】 前記「パターンのチェック手段」(50
1)は、 パターンルールの中に「別のパターンルールの参照記
述」があるときに呼び出され、ルールDB(104)か
ら別のパターンルールを取り出してきて、該別のパター
ンルールに従いパターンのチェックを行わせるための
「別のパターンルールの参照手段」(508)、 を含む請求項2記載のコーディング規則に基づくコード
自動診断装置。
6. The “pattern checking means” (50
1) is called when there is a "reference description of another pattern rule" in the pattern rule, fetches another pattern rule from the rule DB (104), and checks the pattern according to the other pattern rule. The code automatic diagnosis device based on the coding rule according to claim 2, further comprising: "a means for referring to another pattern rule" (508) for executing.
JP4179948A 1992-07-07 1992-07-07 Automatic code diagnostic device based upon coding rule Pending JPH0628165A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP4179948A JPH0628165A (en) 1992-07-07 1992-07-07 Automatic code diagnostic device based upon coding rule

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP4179948A JPH0628165A (en) 1992-07-07 1992-07-07 Automatic code diagnostic device based upon coding rule

Publications (1)

Publication Number Publication Date
JPH0628165A true JPH0628165A (en) 1994-02-04

Family

ID=16074751

Family Applications (1)

Application Number Title Priority Date Filing Date
JP4179948A Pending JPH0628165A (en) 1992-07-07 1992-07-07 Automatic code diagnostic device based upon coding rule

Country Status (1)

Country Link
JP (1) JPH0628165A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6675207B1 (en) 1999-02-15 2004-01-06 International Business Machines Corporation Possibility of execution evaluating apparatus and method therefor
JP2009098872A (en) * 2007-10-16 2009-05-07 Toshiba Corp Source program analysis device, source program analysis method and computer program
JP2015130026A (en) * 2014-01-07 2015-07-16 Necソリューションイノベータ株式会社 Diagnosis system, diagnosis method and program

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6675207B1 (en) 1999-02-15 2004-01-06 International Business Machines Corporation Possibility of execution evaluating apparatus and method therefor
JP2009098872A (en) * 2007-10-16 2009-05-07 Toshiba Corp Source program analysis device, source program analysis method and computer program
JP2015130026A (en) * 2014-01-07 2015-07-16 Necソリューションイノベータ株式会社 Diagnosis system, diagnosis method and program

Similar Documents

Publication Publication Date Title
Brady Type-driven development with Idris
Donzeau-Gouge et al. Programming environments based on structured editors: The MENTOR experience
Griswold et al. The SNOBOL4 Programming
EP0643851B1 (en) Debugger program which includes correlation of computer program source code with optimized objet code
Kahn et al. Metal: A formalism to specify formalisms
JPS6375835A (en) Apparatus for generating intended code, program, list and design document
JPH1078959A (en) Edge data structure unifying method
US20070298389A1 (en) System presenting step by step mathematical solutions
US6851106B1 (en) Object oriented optimizing code generator with user selection of use or do not use for dynamic generation of functions
US5949993A (en) Method for the generation of ISA simulators and assemblers from a machine description
de Souza Amorim et al. Multi-purpose syntax definition with SDF3
Lourenço et al. OSTRICH-a type-safe template language for low-code development
Bobot et al. The why3 platform
JPH11249875A (en) Method for supporting programming and device therefor
JPH0628165A (en) Automatic code diagnostic device based upon coding rule
JP2004157927A (en) Creating system for business form input, creating program and creating method
CN113811849A (en) System and method for computer-aided computer programming
Bahlke et al. Context-sensitive editing with PSG environments
JP2002288004A (en) Program source processing device and method, and program source processing program
MacLennan The Synmac syntax macroprocessor: Introduction and manual, version 5
Sasano et al. A text-based syntax completion method using LR parsing and its evaluation
Winkler et al. Program-Variations-in-the-Small.
JP3069050B2 (en) Program conversion method
Liskov et al. Programming with Abstract Data Types (1974)
Johnsson et al. Xtext language-based editor