Abstract syntax tree classes for working with Go programs¶
CodeQL has a large selection of classes for representing the abstract syntax tree of Go programs.
The abstract syntax tree (AST) represents the syntactic structure of a program. Nodes on the AST represent elements such as statements and expressions.
Statement classes¶
This table lists all subclasses of Stmt.
Statement syntax |
CodeQL class |
Superclasses |
Remarks |
---|---|---|---|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
can only occur as final non-empty child of a CaseClause in an ExpressionSwitchStmt |
||
|
|||
|
|||
VariableName |
|||
Expr |
|||
Expr |
|||
|
|||
|
|||
can only occur as child of a SwitchStmt |
|||
|
|||
can only occur as child of a SelectStmt |
|||
|
|||
can only occur as child of a CommClause |
|||
VariableName |
|||
(anything unparseable) |
Expression classes¶
There are many expression classes, so we present them by category. All classes in this section are subclasses of Expr.
Literals¶
Expression syntax example |
CodeQL class |
Superclass |
---|---|---|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Unary expressions¶
All classes in this subsection are subclasses of UnaryExpr.
Expression syntax |
CodeQL class |
Superclasses |
---|---|---|
|
||
|
||
|
||
|
||
|
||
|
Binary expressions¶
All classes in this subsection are subclasses of BinaryExpr.
Expression syntax |
CodeQL class |
Superclasses |
---|---|---|
Type expressions¶
These classes represent different expressions for types. They do not have a common superclass.
Expression syntax |
CodeQL class |
Superclasses |
---|---|---|
|
||
|
||
|
||
|
||
|
||
|
Name expressions¶
All classes in this subsection are subclasses of Name.
The following classes relate to the structure of the name.
Expression syntax |
CodeQL class |
Superclasses |
---|---|---|
The following classes relate to what sort of entity the name refers to.
Miscellaneous¶
Expression syntax |
CodeQL class |
Superclasses |
Remarks |
---|---|---|---|
|
|||
|
|||
|
|||
|
|||
|
|||
Expr |
|||
(anything unparseable) |
The following classes organize expressions by the kind of entity they refer to.
CodeQL class |
Explanation |
---|---|
an expression that denotes a type |
|
an expression that refers to a variable, a constant, a function, a field, or an element of an array or a slice |
|
an expression that can be evaluated to a value (as opposed to expressions that refer to a package, a type, or a statement label). This generalizes ReferenceExpr |