Annotation Description Full XML Template
This table lists all the elements, attributes, and values of the XML that you can use to define an annotation format and map it to the Polyspace annotation syntax. For an example of how to edit an XML to define annotation syntax, see Define Custom Annotation Format.
Element | Attribute | Use | Value |
---|---|---|---|
Annotations | Group | Required | User defined string. For example, "Custom Annotations" |
Expressions | Search_For_Keywords | Required | User defined string. This string is a keyword you include in the pattern of your annotation syntax to help identify it. For example, "myKeyword". To use multiple custom annotations, enter a comma separated list of keyword. See Define Multiple Custom Annotation Syntaxes. |
Separator_Result_Name | Required | User defined string. This string is a separator when you list multiple Polyspace result names in the same annotation. For example "," | |
Separator_Family_And_Result_Name | Optional | User defined string. This string is a separator when you list multiple Polyspace results families in the same annotation. For example, " " | |
Separator_Family | Optional | User defined string. This string is a separator when you list a Polyspace results family and results name in the same annotation. For example, ":" | |
Expression | Mode | Required | SAME_LINE |
GOTO_INCREMENT
| |||
BEGIN
| |||
END
| |||
END_ALL
| |||
The annotation applies to the next line of code. Comments and blank lines are ignored. | |||
GOTO_LABEL
| |||
LABEL
| |||
XML_START
| |||
The annotation for this expression must be on a single line. | |||
XML_END
| |||
Regex | Required | Regular expression search string that matches the pattern of your annotation. | |
Rule_Identifier_Position | Required, except when you set Mode="END_ALL" or
"LABEL" | Integer. The integer value of this attribute corresponds to the number of opening parentheses in the regular expression before the relevant search expression. | |
Increment_Position | Required only when you set
Mode="GOTO_INCREMENT" | Integer. The integer value of this attribute corresponds to the number of opening parentheses in the regular expression before the relevant search expression. | |
Status_Position | Optional | Integer. The integer value of this attribute corresponds to the number of opening parentheses in the regular expression before the relevant search expression. | |
Severity_Position | Optional | Integer. The integer value of this attribute corresponds to the number of opening parentheses in the regular expression before the relevant search expression. | |
Comment_Position
| Optional | Integer. The integer value of this attribute corresponds to the number of opening parentheses in the regular expression before the relevant search expression. | |
Label_Position | Required only when you set Mode="GOTO_LABEL" or
"LABEL" | Integer. The integer value of this attribute corresponds to the number of opening parentheses in the regular expression before the relevant search expression. | |
Case_Insensitive
| Optional | True or false. When you do not declare this attribute, the default value is false. | |
Is_Pragma
| Optional | True or false. When you do not declare this attribute, the default value is false. Set this attribute to true if you want to declare your annotation using a pragma instead of a comment. | |
Applies_Also_On_Same_Line | Optional | True or false. When you do not declare this attribute, the default value is true. Use this attribute to enable annotations with the old Polyspace syntax to apply on the same line of code. | |
Mapping | None | None | None |
Result_Name_Mapping | Rule_Identifier | Required | User defined |
Family | Required | Corresponds to Polyspace results family. For a list of allowed values, see allowed values. | |
Result_Name | Required | Corresponds to Polyspace result names. For a list of allowed values, see allowed values. |
Example
This example code covers some of the less commonly used attributes for defining annotations in 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>