Cpp.ParenthesizedExpression Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the parenthesized_expression nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.ParenthesizedExpression represents the node parenthesized_expression in the syntax tree of your code.
#define FOO
void test() {
int a = (1 + 2);
int b = (a, 3);
#if defined(FOO)
int c = 1;
#endif
}The examples show three parenthesized expressions: (1 + 2),
(a, 3), and (FOO) where each corresponds to a
parenthesized_expression PQL node.
Predicates
| Type | Raisable | Printable |
|---|---|---|
ParenthesizedExpression
| 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 ParenthesizedExpression &pe)
| Match any parenthesized_expression node and return it in
&pe for further inspection. | This PQL defect checks for any
defect defectIs =
when
Cpp.ParenthesizedExpression.is(&pe)
and pe.nodeText(&txt)
raise "ParenthesizedExpression.is matched: \"{txt}\""
on peIn this C++ code the defect finds every parenthesized expression such as arithmetic and comma expressions.
void f() {
int x = (1 + 2);
int y = (x, 4);
} |
cast(Cpp.Node.Node node, required ParenthesizedExpression
&cast)
| Convert a generic Node to a
ParenthesizedExpression when the node is actually a
parenthesized_expression. | This PQL defect checks for child nodes of declaration nodes that can be
converted to
defect defectCast =
when
Cpp.Declaration.is(&decl)
and decl.getADescendant(&node)
and Cpp.ParenthesizedExpression.cast(node, &cast)
and cast.nodeText(&txt)
raise "ParenthesizedExpression.cast matched: \"{txt}\""
on castIn this C++ code the defect converts a child
node of a declaration node to a
void g() {
int v = (2 * 3);
} |
isa(Cpp.Node.Node node)
| Check whether a given Node represents a
parenthesized_expression returning true or false. | This PQL defect checks whether a generic node is a
defect defectIsa =
when
Cpp.Declaration.is(&decl)
and decl.getADescendant(&node)
and Cpp.ParenthesizedExpression.isa(node)
and pe.nodeText(&txt)
raise "ParenthesizedExpression.isa matched: \"{txt}\""
on peIn this C++ code the defect verifies that a child node of a declaration is a parenthesized expression.
void h() {
int z = (5);
} |
expression(ParenthesizedExpression self, Cpp.Node.Node
&child)
| Return the inner expression node contained inside the parentheses such as an arithmetic expression. | This PQL defect checks for defect defectExpression =
when
Cpp.ParenthesizedExpression.is(&pe)
and pe.expression(&expr)
and expr.nodeText(&txt)
raise "ParenthesizedExpression.expression matched: \"{txt}\""
on peIn this C++ code the defect finds the arithmetic
expression inside
void i() {
int a = (1 + 2);
} |
commaExpression(ParenthesizedExpression self, Cpp.Node.Node
&child)
| Return the inner comma expression node when the parentheses contain a comma-separated expression. | This PQL defect checks for defect defectCommaExpression =
when
Cpp.ParenthesizedExpression.is(&pe)
and pe.commaExpression(&cexpr)
and cexpr.nodeText(&txt)
raise "ParenthesizedExpression.commaExpression matched: \"{txt}\""
on peIn this C++ code the defect finds the comma
expression inside
void j() {
int a = 0;
int b = (a, 3);
} |
preprocDefined(ParenthesizedExpression self, Cpp.Node.Node
&child)
| Match a parenthesized preprocessor defined expression and
return the defined node. | This PQL defect checks for parenthesized preprocessor defined expressions
such as defect defectPreprocDefined =
when
Cpp.ParenthesizedExpression.is(&pe)
and pe.preprocDefined(&ppd)
and ppd.nodeText(&txt)
raise "ParenthesizedExpression.preprocDefined matched: \"{txt}\""
on peIn this C++ code the defect finds the
#define FOO #if (defined FOO) int k = 1; #endif |
getEnclosingParenthesizedExpression(Cpp.Node.Node child, required
ParenthesizedExpression &parent)
| Find the nearest enclosing parenthesized_expression that
contains the given child node. | This PQL defect checks for number literal nodes that are enclosed by a
defect defectGetEnclosing =
when
Cpp.NumberLiteral.is(&nl)
and nl.toNode(&node)
and Cpp.ParenthesizedExpression.getEnclosingParenthesizedExpression(node, &parent)
and parent.nodeText(&txt)
raise "Enclosing ParenthesizedExpression matched: \"{txt}\""
on parentIn this C++ code the defect locates the parenthesized expression that encloses the inner number literals.
void m() {
int v = (1 + 2);
} |
isEnclosedInParenthesizedExpression(Cpp.Node.Node child)
| Check whether the given child node has any
parenthesized_expression ancestor. | This PQL defect checks whether a binary expression node is inside some
defect defectIsEnclosed =
when
Cpp.BiaryExpression.is(&be)
and be.toNode(&node)
and Cpp.ParenthesizedExpression.isEnclosedInParenthesizedExpression(node)
and node.nodeText(&txt)
raise "Node is enclosed in ParenthesizedExpression: \"{txt}\""
on nodeIn this C++ code the defect verifies that the
binary expression
void n() {
int r = (1 + 2);
} |
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)