forked from sqlc-dev/sqlc-gen-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathast.proto
More file actions
242 lines (206 loc) · 5.29 KB
/
ast.proto
File metadata and controls
242 lines (206 loc) · 5.29 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
syntax = "proto3";
package ast;
option go_package = "github.com/sqlc-dev/sqlc-gen-python/internal/ast";
message Node {
oneof node {
ClassDef class_def = 1 [json_name="ClassDef"];
Import import = 2 [json_name="Import"];
ImportFrom import_from = 3 [json_name="ImportFrom"];
Module module = 4 [json_name="Module"];
Alias alias = 5 [json_name="Alias"];
AnnAssign ann_assign = 6 [json_name="AnnAssign"];
Name name = 7 [json_name="Name"];
Subscript subscript = 8 [json_name="Subscript"];
Attribute attribute = 9 [json_name="Attribute"];
Constant constant = 10 [json_name="Constant"];
Assign assign = 11 [json_name="Assign"];
Comment comment = 12 [json_name="Comment"];
Expr expr = 13 [json_name="Expr"];
Call call = 14 [json_name="Call"];
FunctionDef function_def = 15 [json_name="FunctionDef"];
Arg arg = 16 [json_name="Arg"];
Arguments arguments = 17 [json_name="Arguments"];
AsyncFunctionDef async_function_def = 18 [json_name="AsyncFunctionDef"];
Pass pass = 19 [json_name="Pass"];
Dict dict = 20 [json_name="Dict"];
If if = 21 [json_name="If"];
Compare compare = 22 [json_name="Compare"];
Return return = 23 [json_name="Return"];
Is is = 24 [json_name="Is"];
Keyword keyword = 25 [json_name="Keyword"];
Yield yield = 26 [json_name="Yield"];
For for = 27 [json_name="For"];
Await await = 28 [json_name="Await"];
AsyncFor async_for = 29 [json_name="AsyncFor"];
ImportGroup import_group = 30 [json_name="ImportGroup"];
}
}
message Alias
{
string name = 1 [json_name="name"];
}
message Await
{
Node value = 1 [json_name="value"];
}
message Attribute
{
Node value = 1 [json_name="value"];
string attr = 2 [json_name="attr"];
}
message AnnAssign
{
Name target = 1 [json_name="target"];
Node annotation = 2 [json_name="annotation"];
int32 simple = 3 [json_name="simple"];
string Comment = 4 [json_name="comment"];
}
message Arg
{
string arg = 1 [json_name="arg"];
Node annotation = 2 [json_name="annotation"];
}
message Arguments
{
repeated Arg args = 1 [json_name="args"];
repeated Arg kw_only_args = 2 [json_name="kwonlyargs"];
}
message AsyncFor
{
Node target = 1 [json_name="target"];
Node iter = 2 [json_name="iter"];
repeated Node body = 3 [json_name="body"];
}
message AsyncFunctionDef
{
string name = 1 [json_name="name"];
Arguments Args = 2 [json_name="args"];
repeated Node body = 3 [json_name="body"];
Node returns = 4 [json_name="returns"];
}
message Assign
{
repeated Node targets = 1 [json_name="targets"];
Node value = 2 [json_name="value"];
string Comment = 3 [json_name="comment"];
}
message Call
{
Node func = 1 [json_name="func"];
repeated Node args = 2 [json_name="args"];
repeated Keyword keywords = 3 [json_name="keywords"];
}
message ClassDef
{
string name = 1 [json_name="name"];
repeated Node bases = 2 [json_name="bases"];
repeated Node keywords = 3 [json_name="keywords"];
repeated Node body = 4 [json_name="body"];
repeated Node decorator_list = 5 [json_name="decorator_list"];
}
// The Python ast module does not parse comments. It's not clear if this is the
// best way to support them in the AST
message Comment
{
string text = 1 [json_name="text"];
}
message Compare
{
Node left = 1 [json_name="left"];
repeated Node ops = 2 [json_name="ops"];
repeated Node comparators = 3 [json_name="comparators"];
}
message Constant
{
oneof value {
string str = 1 [json_name="string"];
int32 int = 2 [json_name="int"];
bool none = 3 [json_name="none"];
}
}
message Dict
{
repeated Node keys = 1 [json_name="keys"];
repeated Node values = 2 [json_name="values"];
}
message Expr
{
Node value = 1 [json_name="value"];
}
message For
{
Node target = 1 [json_name="target"];
Node iter = 2 [json_name="iter"];
repeated Node body = 3 [json_name="body"];
}
message FunctionDef
{
string name = 1 [json_name="name"];
Arguments Args = 2 [json_name="args"];
repeated Node body = 3 [json_name="body"];
Node returns = 4 [json_name="returns"];
}
message If
{
Node test = 1 [json_name="test"];
repeated Node body = 2 [json_name="body"];
repeated Node or_else = 3 [json_name="orelse"];
}
message Import
{
repeated Node names = 1 [json_name="names"];
}
message ImportFrom
{
string module = 1 [json_name="module"];
repeated Node names = 2 [json_name="names"];
int32 level = 3 [json_name="level"];
}
// Imports are always put at the top of the file, just after any module
// comments and docstrings, and before module globals and constants.
//
// Imports should be grouped in the following order:
//
// Standard library imports.
// Related third party imports.
// Local application/library specific imports.
//
// You should put a blank line between each group of imports.
//
// https://www.python.org/dev/peps/pep-0008/#imports
message ImportGroup
{
repeated Node imports = 1 [json_name="imports"];
}
message Is
{
}
message Keyword
{
string arg = 1 [json_name="arg"];
Node value = 2 [json_name="value"];
}
message Module
{
repeated Node body = 1 [json_name="body"];
}
message Name
{
string id = 1 [json_name="id"];
}
message Pass
{
}
message Return
{
Node value = 1 [json_name="value"];
}
message Subscript
{
Name value = 1 [json_name="value"];
Node slice = 2 [json_name="slice"];
}
message Yield
{
Node value = 1 [json_name="value"];
}