class syntax_kind¶
Enumeration class: the kind of a span within a source file instance ( sfileinst ).
Corresponds to syntax coloring in the CodeSonar GUI.
To iterate over the spans of a particular syntax kind within a particular source file instance, use a sfileinst_color_map_iterator initialized with sfileinst.color_map_iterator().
Not to be confused with point_syntax_kind , which is a property of a single point .
syntax_kind Members¶
| Constructors | none |
| Static Method | from_integer() |
| Methods | __cmp__(), __eq__(), __ge__(), __gt__(), __hash__(), __le__(), __lt__(), __ne__(), __repr__(), __str__(), as_integer(), name() |
| Attributes | COMMENT, GRAYOUT, INCLUDE, INCLUDE_DIRECTIVE, KEYWORD, LABEL, MACRO, OPCODE, PREPROCESSOR, STRING |
syntax_kind Details¶
-
class
cs.syntax_kind¶ Enumeration class: the kind of a span within a source file instance (
sfileinst).-
static
from_integer(_inner)¶ Construct an instance from an integer representation.
Parameters: _inner (int) – The integer representation, as returned by syntax_kind.as_integer().Return type: syntax_kindRaises: result.ERROR_INVALID_ARGUMENTif_inneris not a valid integer representation for asyntax_kindinstance.Invariant: For
syntax_kindx, syntax_kind.from_integer(x.as_integer()) == x>>> sk = syntax_kind.MACRO.as_integer() >>> sk 1 >>> syntax_kind.from_integer(sk) <cs.syntax_kind macro>
-
__cmp__(other)¶ Comparison function for
syntax_kind, with respect to a stable overall ordering.Parameters: other ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: int Returns: An integer N such that: - N==0 if the two objects compare equal
- N<0 if
self< other - N>0 if
self> other
>>> syntax_kind.INCLUDE.__cmp__(syntax_kind.PREPROCESSOR) 1
-
__eq__(b)¶ Equality operator for
syntax_kind.Parameters: b ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: bool Returns: Trueifselfandbcompare equal,Falseotherwise.>>> syntax_kind.COMMENT == syntax_kind.INCLUDE_DIRECTIVE False
-
__ge__(b)¶ Greater-than-or-equal operator for
syntax_kind.Parameters: b ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: bool Returns: Trueifself>=b,Falseotherwise.>>> syntax_kind.KEYWORD >= syntax_kind.GRAYOUT False
-
__gt__(b)¶ Greater-than operator for
syntax_kind.Parameters: b ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: bool Returns: Trueifself>b,Falseotherwise.>>> syntax_kind.LABEL > syntax_kind.INCLUDE True
-
__hash__()¶ Hash function for
syntax_kind.Return type: int >>> hash(syntax_kind.PREPROCESSOR) 2
-
__le__(b)¶ Less-than-or-equal operator for
syntax_kind.Parameters: b ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: bool Returns: Trueifself<=b,Falseotherwise.>>> syntax_kind.OPCODE <= syntax_kind.LABEL True
-
__lt__(b)¶ Less-than operator for
syntax_kind.Parameters: b ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: bool Returns: Trueifself<b,Falseotherwise.>>> syntax_kind.GRAYOUT < syntax_kind.INCLUDE_DIRECTIVE True
-
__ne__(b)¶ Inequality operator for
syntax_kind.Parameters: b ( syntax_kind) – Thesyntax_kindobject to compare against.Return type: bool Returns: Falseifselfandbcompare equal,Trueotherwise.>>> syntax_kind.KEYWORD != syntax_kind.STRING True
-
__repr__()¶ Get a representation of a
syntax_kindobject that includes information useful for debugging.Return type: str Returns: The string representation. >>> repr(syntax_kind.COMMENT) '<cs.syntax_kind comment>'
-
__str__()¶ Get a simple string representation of a
syntax_kindobject.Return type: str Returns: The string representation. >>> str(syntax_kind.MACRO) 'macro'
-
as_integer()¶ Get an integer representation of
self.Return type: int Returns: An integer suitable for use with syntax_kind.from_integer().Invariant: For
syntax_kindx, syntax_kind.from_integer(x.as_integer()) == x>>> sk = syntax_kind.MACRO.as_integer() >>> sk 1 >>> syntax_kind.from_integer(sk) <cs.syntax_kind macro>
-
name()¶ Get the name of a
syntax_kindobject.Return type: str Returns: The name. >>> syntax_kind.COMMENT.name() 'comment'
-
COMMENT¶ Code comment.
>>> syntax_kind.COMMENT <cs.syntax_kind comment>
-
GRAYOUT¶ Code present in the underlying source file but removed by the preprocessor for the compilation unit containing this instance.
>>> syntax_kind.GRAYOUT <cs.syntax_kind grayout>
-
INCLUDE¶ Preprocessor include directive.
>>> syntax_kind.INCLUDE <cs.syntax_kind include>
-
INCLUDE_DIRECTIVE¶ Preprocessor include directive.
>>> syntax_kind.INCLUDE_DIRECTIVE <cs.syntax_kind #include>
-
KEYWORD¶ Programming language keyword.
>>> syntax_kind.KEYWORD <cs.syntax_kind keyword>
-
LABEL¶ Statement label.
>>> syntax_kind.LABEL <cs.syntax_kind label>
-
MACRO¶ Macro name.
>>> syntax_kind.MACRO <cs.syntax_kind macro>
-
OPCODE¶ Assembly language opcode.
>>> syntax_kind.OPCODE <cs.syntax_kind opcode>
-
PREPROCESSOR¶ Preprocessor directive.
>>> syntax_kind.PREPROCESSOR <cs.syntax_kind preprocessor>
-
STRING¶ String literal.
>>> syntax_kind.STRING <cs.syntax_kind string>
-
static