Cpp.Identifier Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the identifier nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Identifier represents the node identifier in the syntax tree of your code.
// example_identifier.cpp
#include <iostream>
int main() {
int myVar = 42;
std::cout << myVar << std::endl;
return 0;
}The myVar token in the example corresponds to an
identifier node. PQL class Identifier matches this
node.
Predicates
| Type | Raisable | Printable |
|---|---|---|
Identifier
| Yes | No |
This class defines these predicates that act on the objects of this class. In addition, objects of this class can access the predicates defined by the base class AstNodeProperties. An object of this class is an object of AstNodeProperties class.
| Predicates | Description | Example |
|---|---|---|
is(required Identifier &identifier)
| Checks whether a syntax node is an identifier and returns that identifier node as the required output &identifier. | This PQL defect checks for an defect identIs =
when
Cpp.Identifier.is(&id)
and id.nodeText(&txt)
raise "Found identifier: \"{txt}\""
on idIn this C++ code, the defect finds the tokens such
as
// ident_is_demo.cpp
#include <iostream>
int main() {
int count = 5; // 'count' is an identifier
std::cout << count << std::endl;
return 0;
} |
cast(Cpp.Node.Node node, required Identifier &cast)
| Checks whether a generic Cpp.Node.Node is specifically an
identifier. If so, returns it via &cast
for further identifier-specific queries. | This PQL defect checks whether a generic node is an
defect identCast =
when
Cpp.Node.is(&node, &,&,&)
and Cpp.Identifier.cast(node, &id)
and id.nodeText(&txt)
raise "Node is identifier: \"{txt}\""
on idIn this C++ code, the defect converts a generic node into an identifier and reports its text.
// ident_cast_demo.cpp
#include <string>
std::string makeName() {
std::string name = "demo"; // 'name' is an identifier node
return name;
}
int main() {
auto s = makeName();
return 0;
} |
isa(Cpp.Node.Node node)
| Tests whether a Cpp.Node.Node is an
identifier. Use this to perform a boolean check if a node is an
identifier. |
This PQL defect checks whether a given node is not an defect notIdentifier =
when
Cpp.Node.is(&node, &,&,&)
and not Cpp.Identifier.isa(node)
raise "Node is not an identifier"
on nodeIn this C++ code, the defect distinguishes non-identifier nodes (for example, punctuation or keywords) from identifiers.
// ident_isa_demo.cpp
#include <iostream>
int main() {
int x = 0; // 'int' is a keyword node, not an identifier
++x; // '++' is an operator token, not an identifier
std::cout << x << std::endl;
return 0;
} |
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)