CppParser
Loading...
Searching...
No Matches
CppExpr Struct Reference

An expression in a C/C++ program. More...

#include <cppast.h>

Inheritance diagram for CppExpr:
Inheritance graph
Collaboration diagram for CppExpr:
Collaboration graph

Public Types

enum  Flag {
  kReturn = 0x01 , kNew = 0x02 , kDelete = 0x08 , kDeleteArray = 0x10 ,
  kBracketed = 0x20 , kInitializer = 0x40 , kThrow = 0x80 , kSizeOf = 0x100 ,
  kVariadicPack = 0x200 , kGoto = 0x400
}
 

Public Member Functions

 CppExpr (CppExprAtom e1, CppOperator op, CppExprAtom e2=CppExprAtom())
 
 CppExpr (CppExprAtom e1, short flags)
 
 CppExpr (CppExprAtom e1, CppOperator op, CppExprAtom e2, short flags)
 
 CppExpr (CppExprAtom e1, CppExprAtom e2, CppExprAtom e3)
 
 CppExpr (std::string name)
 
 CppExpr (CppLambda *l)
 
 ~CppExpr () override
 
void accept (CppVisitorBase *v) override
 
- Public Member Functions inherited from CppObj
 CppObj (CppObjType type, CppAccessType accessType)
 
CppCompoundowner ()
 
void owner (CppCompound *o)
 
virtual void accept (CppVisitorBase *v)=0
 
virtual ~CppObj ()
 

Public Attributes

CppExprAtom expr1_ {(CppExpr*) (nullptr)}
 
CppExprAtom expr2_ {(CppExpr*) (nullptr)}
 
CppExprAtom expr3_ {(CppExpr*) (nullptr)}
 
CppOperator oper_
 
short flags_
 
- Public Attributes inherited from CppObj
CppObjType objType_
 
CppAccessType accessType_
 All objects do not need this. More...
 

Static Public Attributes

static constexpr CppObjType kObjectType = CppObjType::kExpression
 

Detailed Description

An expression in a C/C++ program.

In C/C++ an expression is a complicated beast that needs to be tamed to parse it correctly. An expression can be as simple as a word, e.g. x, 5 are valid expressions. It can be a function call. It can be an initialization list for an array or struct. e.g. POINT pt = {100, 500}; It can be a list of expressions used to call a function e.g. gcd(36, 42); new/delete statements are also expressions. It can be any of the arithmetic expression, e.g. a+b. To make things simple we treat a return statement as an expression.

structs CppExprAtom, and CppExpr are required to tame this difficult beast called expression in C/C++.

Definition at line 1749 of file cppast.h.

Member Enumeration Documentation

◆ Flag

Enumerator
kReturn 
kNew 
kDelete 
kDeleteArray 
kBracketed 
kInitializer 
kThrow 
kSizeOf 
kVariadicPack 
kGoto 

Definition at line 1753 of file cppast.h.

Constructor & Destructor Documentation

◆ CppExpr() [1/6]

CppExpr::CppExpr ( CppExprAtom  e1,
CppOperator  op,
CppExprAtom  e2 = CppExprAtom() 
)
inline

Definition at line 1774 of file cppast.h.

◆ CppExpr() [2/6]

CppExpr::CppExpr ( CppExprAtom  e1,
short  flags 
)
inline

Definition at line 1779 of file cppast.h.

◆ CppExpr() [3/6]

CppExpr::CppExpr ( CppExprAtom  e1,
CppOperator  op,
CppExprAtom  e2,
short  flags 
)
inline

Definition at line 1789 of file cppast.h.

◆ CppExpr() [4/6]

CppExpr::CppExpr ( CppExprAtom  e1,
CppExprAtom  e2,
CppExprAtom  e3 
)
inline

Definition at line 1798 of file cppast.h.

◆ CppExpr() [5/6]

CppExpr::CppExpr ( std::string  name)
inline

Definition at line 1808 of file cppast.h.

◆ CppExpr() [6/6]

CppExpr::CppExpr ( CppLambda l)
inline

Definition at line 1813 of file cppast.h.

◆ ~CppExpr()

CppExpr::~CppExpr ( )
inlineoverride

Definition at line 1821 of file cppast.h.

Here is the call graph for this function:

Member Function Documentation

◆ accept()

void CppExpr::accept ( CppVisitorBase v)
inlineoverridevirtual

Implements CppObj.

Definition at line 1828 of file cppast.h.

Here is the call graph for this function:

Member Data Documentation

◆ expr1_

CppExprAtom CppExpr::expr1_ {(CppExpr*) (nullptr)}

Definition at line 1768 of file cppast.h.

◆ expr2_

CppExprAtom CppExpr::expr2_ {(CppExpr*) (nullptr)}

Definition at line 1769 of file cppast.h.

◆ expr3_

CppExprAtom CppExpr::expr3_ {(CppExpr*) (nullptr)}

Definition at line 1770 of file cppast.h.

◆ flags_

short CppExpr::flags_

Definition at line 1772 of file cppast.h.

◆ kObjectType

constexpr CppObjType CppExpr::kObjectType = CppObjType::kExpression
staticconstexpr

Definition at line 1751 of file cppast.h.

◆ oper_

CppOperator CppExpr::oper_

Definition at line 1771 of file cppast.h.


The documentation for this struct was generated from the following file: