/
Nodes.td
202 lines (191 loc) · 7.35 KB
/
Nodes.td
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//===- Nodes.td - Node types in the Syntax Tree grammar -------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines concrete nodes in the syntax tree.
// The archetypes they fall into (Sequence, List etc) are defined in Syntax.td.
//
// The C++ classes for the archetypes themselves are written by hand, and the
// concrete node classes will be generated. Migration to TableGen is not
// complete, so currently there is a mix of generated and hand-authored code.
//
//===----------------------------------------------------------------------===//
include "clang/Tooling/Syntax/Syntax.td"
def TranslationUnit : Unconstrained {
let documentation = [{
A root node for a translation unit. Parent is always null.
}];
}
def UnqualifiedId : External<Tree> {}
// Lists
def List : External<Tree> {}
def DeclaratorList : External<List> {}
def ParameterDeclarationList : External<List> {}
def CallArguments : External<List> {}
def NestedNameSpecifier : External<List> {}
def Expression : Alternatives {
let documentation = [{
A base class for all expressions. Note that expressions are not statements,
even though they are in clang.
}];
}
def UnknownExpression : External<Expression> {}
def UnaryOperatorExpression : External<Tree> {}
def PrefixUnaryOperatorExpression : External<UnaryOperatorExpression> {}
def PostfixUnaryOperatorExpression : External<UnaryOperatorExpression> {}
def BinaryOperatorExpression : External<Expression> {}
def ParenExpression : Sequence<Expression> {
let documentation = [{
Models a parenthesized expression `(E)`. C++ [expr.prim.paren]
e.g. `(3 + 2)` in `a = 1 + (3 + 2);`
}];
let children = [
Role<"OpenParen", Token<"l_paren">>,
Role<"SubExpression", Expression>,
Role<"CloseParen", Token<"r_paren">>,
];
}
def LiteralExpression : External<Expression> {}
def IntegerLiteralExpression : External<LiteralExpression> {}
def CharacterLiteralExpression : External<LiteralExpression> {}
def FloatingLiteralExpression : External<LiteralExpression> {}
def StringLiteralExpression : External<LiteralExpression> {}
def BoolLiteralExpression : External<LiteralExpression> {}
def CxxNullPtrExpression : External<LiteralExpression> {}
def UserDefinedLiteralExpression : External<LiteralExpression> {}
def IntegerUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
def FloatUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
def CharUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
def StringUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
def IdExpression : Sequence<Expression> {
let documentation = [{
Models an `id-expression`, e.g. `std::vector<int>::size`.
C++ [expr.prim.id]
id-expression:
unqualified-id
qualified-id
qualified-id:
nested-name-specifier template_opt unqualified-id
}];
let children = [
Role<"Qualifier", Optional<NestedNameSpecifier>>,
Role<"TemplateKeyword", Optional<Keyword<"template">>>,
Role<"UnqualifiedId", UnqualifiedId>,
];
}
def MemberExpression : Sequence<Expression> {
let documentation = [{
Models a class member access. C++ [expr.ref]
member-expression:
expression -> template_opt id-expression
expression . template_opt id-expression
e.g. `x.a`, `xp->a`
Note: An implicit member access inside a class, i.e. `a` instead of
`this->a`, is an `id-expression`.
}];
let children = [
Role<"Object", Expression>,
Role<"AccessToken", AnyToken<["period","arrow"]>>,
Role<"TemplateKeyword", Optional<Keyword<"template">>>,
Role<"Member", IdExpression>,
];
}
def ThisExpression : Sequence<Expression> {
let documentation = [{
Models a this expression `this`. C++ [expr.prim.this]
}];
let children = [
Role<"IntroducerKeyword", Keyword<"this">>,
];
}
def CallExpression : Sequence<Expression> {
let documentation = [{
A function call. C++ [expr.call]
call-expression:
expression '(' call-arguments ')'
e.g `f(1, '2')` or `this->Base::f()`
}];
let children = [
Role<"Callee", Expression>,
Role<"OpenParen", Token<"l_paren">>,
Role<"Arguments", CallArguments>,
Role<"CloseParen", Token<"r_paren">>,
];
}
// Statements.
def Statement : External<Tree> {}
def UnknownStatement : External<Statement> {}
def DeclarationStatement : External<Statement> {}
def EmptyStatement : External<Statement> {}
def SwitchStatement : External<Statement> {}
def CaseStatement : External<Statement> {}
def DefaultStatement : External<Statement> {}
def IfStatement : External<Statement> {}
def ForStatement : External<Statement> {}
def WhileStatement : External<Statement> {}
def ContinueStatement : External<Statement> {}
def BreakStatement : External<Statement> {}
def ReturnStatement : External<Statement> {}
def RangeBasedForStatement : External<Statement> {}
def ExpressionStatement : External<Statement> {}
def CompoundStatement : External<Statement> {}
// Declarations.
def Declaration : External<Tree> {}
def UnknownDeclaration : External<Declaration> {}
def EmptyDeclaration : External<Declaration> {}
def StaticAssertDeclaration : External<Declaration> {}
def LinkageSpecificationDeclaration : External<Declaration> {}
def SimpleDeclaration : External<Declaration> {}
def TemplateDeclaration : External<Declaration> {}
def ExplicitTemplateInstantiation : External<Declaration> {}
def NamespaceDefinition : External<Declaration> {}
def NamespaceAliasDefinition : External<Declaration> {}
def UsingNamespaceDirective : External<Declaration> {}
def UsingDeclaration : External<Declaration> {}
def TypeAliasDeclaration : External<Declaration> {}
// Declarators.
def Declarator : External<Tree> {}
def SimpleDeclarator : External<Declarator> {}
def ParenDeclarator : External<Declarator> {}
def ArraySubscript : External<Tree> {}
def TrailingReturnType : External<Tree> {}
def ParametersAndQualifiers : External<Tree> {}
def MemberPointer : External<Tree> {}
// Name Specifiers.
def NameSpecifier : Alternatives {
let documentation = [{
A sequence of these specifiers make a `nested-name-specifier`.
e.g. the `std` or `vector<int>` in `std::vector<int>::size`.
}];
}
def GlobalNameSpecifier : Unconstrained<NameSpecifier> {
let documentation = [{
The global namespace name specifier, this specifier doesn't correspond to a
token instead an absence of tokens before a `::` characterizes it, in
`::std::vector<int>` it would be characterized by the absence of a token
before the first `::`
}];
}
def DecltypeNameSpecifier : Unconstrained<NameSpecifier> {
let documentation = [{
A name specifier holding a decltype, of the form: `decltype ( expression ) `
e.g. the `decltype(s)` in `decltype(s)::size`.
}];
}
def IdentifierNameSpecifier : Unconstrained<NameSpecifier> {
let documentation = [{
A identifier name specifier, of the form `identifier`
e.g. the `std` in `std::vector<int>::size`.
}];
}
def SimpleTemplateNameSpecifier : Unconstrained<NameSpecifier> {
let documentation = [{
A name specifier with a simple-template-id, of the form `template_opt
identifier < template-args >` e.g. the `vector<int>` in
`std::vector<int>::size`.
}];
}