|
CodeSonar C++ API
|
An AST Pattern. More...
Public Member Functions | |
| ast_pattern (const ast_pattern &rhs) | |
| Copy constructor. | |
| ast_pattern (const std::string &pattern) | |
| Constructor: given a string representation of a pattern, construct a corresponding ast_pattern. | |
| std::string | as_repr () const |
| Get a representation of a ast_pattern object that includes information useful for debugging. | |
| std::string | as_string () const |
| Get a simple string representation of a ast_pattern object. | |
| cs_hash_t | hash () const |
| Get a hash value for a ast_pattern. | |
| bool | match (ast node) const |
| Check: does the specified ast match the pattern? | |
| ast_bindings | match_with_bindings (ast node) const |
| Get the bindings generated in matching against the specified ast. | |
Related Symbols | |
(Note that these are not member symbols.) | |
| std::ostream & | operator<< (std::ostream &out, const ast_pattern &a) |
An AST Pattern.
Patterns are constructs that describe ast properties, much like specialized regular expressions for ASTs. They are used for testing whether a specific ast object conforms to those properties ("matches the pattern"), particularly in traversal with an ast_iterator.
A successful match results in an ast_bindings object (analogous to regular expression "tags").
For example, the following code uses an ast_pattern to determine whether an ast object to determine whether or not it represents a cast of a const pointer to a non-const pointer type. The ast class documentation has an example in which the same check is performed by dissecting the ast manually.
|
inline |
Constructor: given a string representation of a pattern, construct a corresponding ast_pattern.
| [in] | pattern | The std::string representation of the pattern. |
| ast_pattern_compilation_error | if pattern is not properly formed, or includes an operation on a value of incorrect type. |
For more information, see AST Patterns.
|
inline |
Copy constructor.
| [in] | rhs | The ast_pattern to copy. |
|
inline |
Get a representation of a ast_pattern object that includes information useful for debugging.
|
inline |
Get a simple string representation of a ast_pattern object.
|
inline |
Get a hash value for a ast_pattern.
|
inline |
|
inline |
Get the bindings generated in matching against the specified ast.
| node | The ast to match. |
node. Use ast_bindings::matched() to check whether the pattern matched.
|
related |
Print a representation of a ast_pattern object to the specified stream.
| [in] | out | The stream to print to. |
| [in] | a | The ast_pattern object to print. |