注釈説明用の完全な XML テンプレート
次の表に、注釈形式の定義と Polyspace® 注釈構文へのマッピングに使用できる XML のすべての要素、属性、および値を示します。XML を編集して注釈構文を定義する方法の例は、カスタム注釈形式の定義を参照してください。
要素 | 属性 | 使用 | 値 |
---|---|---|---|
Annotations | Group | 必要 | ユーザー定義文字列。例: "Custom Annotation" |
Expressions | Search_For_Keywords | 必要 | ユーザー定義文字列。この文字列は、注釈構文を識別しやすくするために注釈構文のパターンに含めるキーワードです。例: "myKeyword"。複数のカスタム注釈を使用するには、キーワードのコンマ区切りリストを入力します。複数のカスタム注釈構文の定義を参照してください。 |
Separator_Result_Name | 必要 | ユーザー定義文字列。この文字列は、複数の Polyspace の結果名を同じ注釈にリストする場合の区切り記号です。例: "," | |
Separator_Family_And_Result_Name | オプション | ユーザー定義文字列。この文字列は、複数の Polyspace の結果ファミリを同じ注釈にリストする場合の区切り記号です。例: " " | |
Separator_Family | オプション | ユーザー定義文字列。この文字列は、Polyspace の結果ファミリと結果名を同じ注釈にリストする場合の区切り記号です。例: ":" | |
Expression | Mode | 必要 | SAME_LINE |
GOTO_INCREMENT | |||
BEGIN | |||
END | |||
END_ALL | |||
この注釈は、次の行のコードに適用されます。コメントと空行は無視されます。 | |||
GOTO_LABEL | |||
LABEL | |||
XML_START | |||
この表現の注釈は、1 行になければなりません。 | |||
XML_END | |||
Regex | 必要 | 注釈のパターンを照合する regex 検索文字列。 | |
Rule_Identifier_Position | 必要 (Mode="END_ALL" or "LABEL" を設定している場合を除く) | 整数。この属性の整数値は、関連する検索式の前の正規表現に含まれる左かっこの数に対応します。 | |
Increment_Position | 必要 (Mode="GOTO_INCREMENT" を設定している場合のみ) | 整数。この属性の整数値は、関連する検索式の前の正規表現に含まれる左かっこの数に対応します。 | |
Status_Position | オプション | 整数。この属性の整数値は、関連する検索式の前の正規表現に含まれる左かっこの数に対応します。 | |
Severity_Position | オプション | 整数。この属性の整数値は、関連する検索式の前の正規表現に含まれる左かっこの数に対応します。 | |
Comment_Position | オプション | 整数。この属性の整数値は、関連する検索式の前の正規表現に含まれる左かっこの数に対応します。 | |
Label_Position | 必要 (Mode="GOTO_LABEL" or "LABEL" を設定している場合のみ) | 整数。この属性の整数値は、関連する検索式の前の正規表現に含まれる左かっこの数に対応します。 | |
Case_Insensitive | オプション | true または false。この属性を宣言しない場合、既定値は false です。 | |
Is_Pragma | オプション | true または false。この属性を宣言しない場合、既定値は false です。 コメントではなくプラグマを使用して注釈を宣言する場合、この属性を true に設定します。 | |
Applies_Also_On_Same_Line | オプション | true または false。この属性を宣言しない場合、既定値は true です。 古い Polyspace 構文を使用した注釈を有効にして注釈を同じ行のコードに適用するには、この属性を使用します。 | |
Mapping | なし | なし | なし |
Result_Name_Mapping | Rule_Identifier | 必要 | ユーザー定義 |
Family | 必要 | Polyspace の結果ファミリに対応します。指定可能な値の一覧は、指定可能な値を参照してください。 | |
Result_Name | 必要 | Polyspace の結果名に対応します。指定可能な値の一覧は、指定可能な値を参照してください。 |
例
このコード例は、あまり使用されることのない XML の注釈定義用の属性をいくつか使用しています。
<?xml version="1.0" encoding="UTF-8"?>
<Annotations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="annotations_xml_schema.xsd"
Group="XML Template">
<Expressions Separator_Result_Name=","
Search_For_Keywords="myKeyword">
<Expression Mode="GOTO_LABEL"
Regex="(\A|\W)myKeyword\s+S\s+(\d+(\s*,\s*\d+)*)\s+([a-zA-Z_-]\w+)"
Rule_Identifier_Position="2"
Label_Position="4"
/>
<Expression Mode="LABEL"
Regex="(\A|\W)myKeyword\s+L:(\w+)"
Label_Position="2"
/>
<!-- Annotation applies starting current line until
next declaration of label word "myLabel"
Example:
code; // myKeyword S 100 myLabel
...
more code;
// myKeyword L myLabel
-->
<Expression Mode="BEGIN"
Regex="#\s*pragma\s+myKeyword_MESSAGES_ON\s+(\w+)"
Rule_Identifier_Position="1"
Is_Pragma="true"
/>
<!-- Annotation declared with pragma instead of comment
Example:#pragma myKeyword_MESSAGES_ON 100 -->
<!-- Comment declaration with XML format-->
<!-- XML_START must be declared before XML_CONTENT -->
<Expression Mode="XML_START"
Regex="<\s*myKeyword_COMMENT\s*>"
/>
<!-- Example: <myKeyword_COMMENT> -->
<Expression Mode="XML_CONTENT"
Regex="<\s*(\d*)\s*>(((?![*]/)(?!<).)*)</\s*(\d*)\s*>"
Rule_Identifier_Position="1"
Comment_Position="2"
/>
<!-- Example: <100>This is my comment</100>
XML_CONTENT must be declare on a single line.
<100>This is my comment
</100>
is incorrect.
-->
<Expression Mode="XML_END"
Regex="</\s*myKeyword_COMMENT\s*>"
/>
<!-- Example: </myKeyword_COMMENT> -->
</Expressions>
<Mapping>
<Result_Name_Mapping Rule_Identifier="100" Family="MISRA-C" Result_Name="4.1"/>
</Mapping>
</Annotations>