Cthulhu  0.2.10
Cthulhu compiler collection
ast.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-3.0-only
2 
3 #include "ctu/ast.h"
4 
5 #include "std/vector.h"
6 
7 #include "arena/arena.h"
8 
9 #include "cthulhu/broker/scan.h"
10 
11 static ctu_t *ctu_new(scan_t *scan, where_t where, ctu_kind_t kind)
12 {
13  arena_t *arena = ctx_get_ast_arena(scan);
14 
15  ctu_t *self = ARENA_MALLOC(sizeof(ctu_t), "ctu", scan, arena);
16  self->kind = kind;
17  self->node = node_new(scan, where);
18 
19  ARENA_IDENTIFY(self->node, "node", self, arena);
20 
21  return self;
22 }
23 
24 static ctu_t *ctu_decl(scan_t *scan, where_t where, ctu_kind_t kind, char *name, bool exported)
25 {
26  ctu_t *self = ctu_new(scan, where, kind);
27  self->name = name;
28  self->exported = exported;
29  self->attribs = &kEmptyVector;
30  return self;
31 }
32 
33 ctu_t *ctu_module(scan_t *scan, where_t where, const vector_t *modspec, const vector_t *imports, const vector_t *decls)
34 {
35  ctu_t *ast = ctu_new(scan, where, eCtuModule);
36  ast->modspec = modspec;
37  ast->imports = imports;
38  ast->decls = decls;
39  return ast;
40 }
41 
42 ctu_t *ctu_import(scan_t *scan, where_t where, vector_t *path, char *name)
43 {
44  ctu_t *ast = ctu_decl(scan, where, eCtuImport, name, false);
45  ast->import_path = path;
46  return ast;
47 }
48 
49 /* attribs */
50 
51 ctu_t *ctu_attrib(scan_t *scan, where_t where, const vector_t *path, const vector_t *args)
52 {
53  ctu_t *ast = ctu_new(scan, where, eCtuAttrib);
54  ast->attrib_path = path;
55  ast->attrib_args = args;
56  return ast;
57 }
58 
59 ctu_t *ctu_apply(ctu_t *decl, const vector_t *attribs)
60 {
61  decl->attribs = attribs;
62  return decl;
63 }
64 
65 /* stmts */
66 
67 ctu_t *ctu_stmt_list(scan_t *scan, where_t where, vector_t *stmts)
68 {
69  ctu_t *ast = ctu_new(scan, where, eCtuStmtList);
70  ast->stmts = stmts;
71  return ast;
72 }
73 
74 ctu_t *ctu_stmt_local(scan_t *scan, where_t where, bool mutable, char *name, ctu_t *type, ctu_t *value)
75 {
76  ctu_t *ast = ctu_decl(scan, where, eCtuStmtLocal, name, false);
77  ast->mut = mutable;
78  ast->type = type;
79  ast->value = value;
80  return ast;
81 }
82 
83 ctu_t *ctu_stmt_return(scan_t *scan, where_t where, ctu_t *value)
84 {
85  ctu_t *ast = ctu_new(scan, where, eCtuStmtReturn);
86  ast->result = value;
87  return ast;
88 }
89 
90 ctu_t *ctu_stmt_while(scan_t *scan, where_t where, char *name, ctu_t *cond, ctu_t *then, ctu_t *other)
91 {
92  ctu_t *ast = ctu_decl(scan, where, eCtuStmtWhile, name, false);
93  ast->cond = cond;
94  ast->then = then;
95  ast->other = other;
96  return ast;
97 }
98 
99 ctu_t *ctu_stmt_assign(scan_t *scan, where_t where, ctu_t *dst, ctu_t *src)
100 {
101  ctu_t *ast = ctu_new(scan, where, eCtuStmtAssign);
102  ast->dst = dst;
103  ast->src = src;
104  return ast;
105 }
106 
107 ctu_t *ctu_stmt_break(scan_t *scan, where_t where, char *label)
108 {
109  ctu_t *ast = ctu_new(scan, where, eCtuStmtBreak);
110  ast->label = label;
111  return ast;
112 }
113 
114 ctu_t *ctu_stmt_continue(scan_t *scan, where_t where, char *label)
115 {
116  ctu_t *ast = ctu_new(scan, where, eCtuStmtContinue);
117  ast->label = label;
118  return ast;
119 }
120 
121 ctu_t *ctu_stmt_branch(scan_t *scan, where_t where, ctu_t *cond, ctu_t *then, ctu_t *other)
122 {
123  ctu_t *ast = ctu_new(scan, where, eCtuStmtBranch);
124  ast->cond = cond;
125  ast->then = then;
126  ast->other = other;
127  return ast;
128 }
129 
130 /* exprs */
131 
133 {
134  ctu_t *ast = ctu_new(scan, where, eCtuExprInt);
135  ast->integer = value;
136  return ast;
137 }
138 
139 ctu_t *ctu_expr_bool(scan_t *scan, where_t where, bool value)
140 {
141  ctu_t *ast = ctu_new(scan, where, eCtuExprBool);
142  ast->bool_value = value;
143  return ast;
144 }
145 
146 ctu_t *ctu_expr_string(scan_t *scan, where_t where, char *text, size_t length)
147 {
148  ctu_t *ast = ctu_new(scan, where, eCtuExprString);
149  ast->text = text;
150  ast->length = length;
151  return ast;
152 }
153 
154 ctu_t *ctu_expr_char(scan_t *scan, where_t where, char *text, size_t length)
155 {
156  ctu_t *ast = ctu_new(scan, where, eCtuExprChar);
157  ast->text = text;
158  ast->length = length;
159  return ast;
160 }
161 
162 ctu_t *ctu_expr_init(scan_t *scan, where_t where, const vector_t *inits)
163 {
164  ctu_t *ast = ctu_new(scan, where, eCtuExprInit);
165  ast->inits = inits;
166  return ast;
167 }
168 
169 ctu_t *ctu_expr_call(scan_t *scan, where_t where, ctu_t *callee, const vector_t *args)
170 {
171  ctu_t *ast = ctu_new(scan, where, eCtuExprCall);
172  ast->callee = callee;
173  ast->args = args;
174  return ast;
175 }
176 
177 ctu_t *ctu_expr_name(scan_t *scan, where_t where, const vector_t *path)
178 {
179  ctu_t *ast = ctu_new(scan, where, eCtuExprName);
180  ast->path = path;
181  return ast;
182 }
183 
184 ctu_t *ctu_expr_cast(scan_t *scan, where_t where, ctu_t *expr, ctu_t *type)
185 {
186  ctu_t *ast = ctu_new(scan, where, eCtuExprCast);
187  ast->expr = expr;
188  ast->cast = type;
189  return ast;
190 }
191 
192 ctu_t *ctu_expr_ref(scan_t *scan, where_t where, ctu_t *expr)
193 {
194  ctu_t *ast = ctu_new(scan, where, eCtuExprRef);
195  ast->expr = expr;
196  return ast;
197 }
198 
199 ctu_t *ctu_expr_deref(scan_t *scan, where_t where, ctu_t *expr)
200 {
201  ctu_t *ast = ctu_new(scan, where, eCtuExprDeref);
202  ast->expr = expr;
203  return ast;
204 }
205 
206 ctu_t *ctu_expr_index(scan_t *scan, where_t where, ctu_t *expr, ctu_t *index)
207 {
208  ctu_t *ast = ctu_new(scan, where, eCtuExprIndex);
209  ast->expr = expr;
210  ast->index = index;
211  return ast;
212 }
213 
214 ctu_t *ctu_expr_field(scan_t *scan, where_t where, ctu_t *expr, char *field)
215 {
216  ctu_t *ast = ctu_new(scan, where, eCtuExprField);
217  ast->expr = expr;
218  ast->field = field;
219  return ast;
220 }
221 
222 ctu_t *ctu_expr_field_indirect(scan_t *scan, where_t where, ctu_t *expr, char *field)
223 {
224  ctu_t *ast = ctu_new(scan, where, eCtuExprFieldIndirect);
225  ast->expr = expr;
226  ast->field = field;
227  return ast;
228 }
229 
230 ctu_t *ctu_expr_unary(scan_t *scan, where_t where, unary_t unary, ctu_t *expr)
231 {
232  ctu_t *ast = ctu_new(scan, where, eCtuExprUnary);
233  ast->unary = unary;
234  ast->expr = expr;
235  return ast;
236 }
237 
238 ctu_t *ctu_expr_binary(scan_t *scan, where_t where, binary_t binary, ctu_t *lhs, ctu_t *rhs)
239 {
240  ctu_t *ast = ctu_new(scan, where, eCtuExprBinary);
241  ast->binary = binary;
242  ast->lhs = lhs;
243  ast->rhs = rhs;
244  return ast;
245 }
246 
247 ctu_t *ctu_expr_compare(scan_t *scan, where_t where, compare_t compare, ctu_t *lhs, ctu_t *rhs)
248 {
249  ctu_t *ast = ctu_new(scan, where, eCtuExprCompare);
250  ast->compare = compare;
251  ast->lhs = lhs;
252  ast->rhs = rhs;
253  return ast;
254 }
255 
256 /* builtins */
257 
259 {
260  ctu_t *ast = ctu_new(scan, where, eCtuExprSizeOf);
261  ast->type = type;
262  return ast;
263 }
264 
266 {
267  ctu_t *ast = ctu_new(scan, where, eCtuExprAlignOf);
268  ast->type = type;
269  return ast;
270 }
271 
272 ctu_t *ctu_builtin_offsetof(scan_t *scan, where_t where, ctu_t *type, char *field)
273 {
274  ctu_t *ast = ctu_new(scan, where, eCtuExprOffsetOf);
275  ast->expr = type;
276  ast->field = field;
277  return ast;
278 }
279 
280 /* types */
281 
283 {
284  ctu_t *ast = ctu_new(scan, where, eCtuTypeName);
285  ast->type_name = path;
286  return ast;
287 }
288 
289 ctu_t *ctu_type_pointer(scan_t *scan, where_t where, ctu_t *pointer, bool array)
290 {
291  ctu_t *ast = ctu_new(scan, where, eCtuTypePointer);
292  ast->pointer = pointer;
293  ast->array = array;
294  return ast;
295 }
296 
297 ctu_t *ctu_type_array(scan_t *scan, where_t where, ctu_t *array, ctu_t *length)
298 {
299  ctu_t *ast = ctu_new(scan, where, eCtuTypeArray);
300  ast->array_type = array;
301  ast->array_length = length;
302  return ast;
303 }
304 
305 ctu_t *ctu_type_function(scan_t *scan, where_t where, const vector_t *params, ctu_t *return_type)
306 {
307  ctu_t *ast = ctu_new(scan, where, eCtuTypeFunction);
308  ast->params = params;
309  ast->return_type = return_type;
310  return ast;
311 }
312 
313 ctu_t *ctu_type_const(scan_t *scan, where_t where, ctu_t *type)
314 {
315  ctu_t *ast = ctu_new(scan, where, eCtuTypeConst);
316  ast->type = type;
317  return ast;
318 }
319 
320 /* decls */
321 
322 ctu_t *ctu_decl_global(scan_t *scan, where_t where, bool exported, bool mut, char *name, ctu_t *type, ctu_t *value)
323 {
324  ctu_t *ast = ctu_decl(scan, where, eCtuDeclGlobal, name, exported);
325  ast->mut = mut;
326  ast->type = type;
327  ast->value = value;
328  return ast;
329 }
330 
331 ctu_t *ctu_decl_function(scan_t *scan, where_t where, bool exported, char *name, const vector_t *params, char *variadic, ctu_t *return_type, ctu_t *body)
332 {
333  ctu_t *ast = ctu_decl(scan, where, eCtuDeclFunction, name, exported);
334  ast->params = params;
335  ast->variadic = variadic;
336  ast->return_type = return_type;
337  ast->body = body;
338  return ast;
339 }
340 
341 /* type decls */
342 
343 ctu_t *ctu_decl_typealias(scan_t *scan, where_t where, bool exported, char *name, bool newtype, ctu_t *type)
344 {
345  ctu_t *ast = ctu_decl(scan, where, eCtuDeclTypeAlias, name, exported);
346  ast->newtype = newtype;
347  ast->type_alias = type;
348  return ast;
349 }
350 
351 ctu_t *ctu_decl_union(scan_t *scan, where_t where, bool exported, char *name, vector_t *fields)
352 {
353  ctu_t *ast = ctu_decl(scan, where, eCtuDeclUnion, name, exported);
354  ast->fields = fields;
355  return ast;
356 }
357 
358 ctu_t *ctu_decl_struct(scan_t *scan, where_t where, bool exported, char *name, vector_t *fields)
359 {
360  ctu_t *ast = ctu_decl(scan, where, eCtuDeclStruct, name, exported);
361  ast->fields = fields;
362  return ast;
363 }
364 
365 ctu_t *ctu_decl_variant(scan_t *scan, where_t where, bool exported, char *name, ctu_t *underlying, const vector_t *cases)
366 {
367  ctu_t *ast = ctu_decl(scan, where, eCtuDeclVariant, name, exported);
368  ast->underlying = underlying;
369  ast->cases = cases;
370  return ast;
371 }
372 
373 ctu_t *ctu_field(scan_t *scan, where_t where, char *name, ctu_t *type)
374 {
375  ctu_t *ast = ctu_new(scan, where, eCtuField);
376  ast->name = name;
377  ast->field_type = type;
378  return ast;
379 }
380 
381 ctu_t *ctu_param(scan_t *scan, where_t where, char *name, ctu_t *type)
382 {
383  ctu_t *ast = ctu_new(scan, where, eCtuParam);
384  ast->name = name;
385  ast->param_type = type;
386  return ast;
387 }
388 
389 ctu_t *ctu_field_init(scan_t *scan, where_t where, char *name, ctu_t *value)
390 {
391  ctu_t *ast = ctu_new(scan, where, eCtuFieldInit);
392  ast->field = name;
393  ast->expr = value;
394  return ast;
395 }
396 
397 ctu_t *ctu_variant_case(scan_t *scan, where_t where, char *name, bool is_default, ctu_t *expr)
398 {
399  ctu_t *ast = ctu_new(scan, where, eCtuVariantCase);
400  ast->name = name;
401  ast->default_case = is_default;
402  ast->case_value = expr;
403  return ast;
404 }
405 
409 
410 ctu_params_t ctu_params_new(const vector_t *params, char *variadic)
411 {
412  ctu_params_t result = {
413  .params = params,
414  .variadic = variadic
415  };
416 
417  return result;
418 }
CT_BROKER_API arena_t * ctx_get_ast_arena(const scan_t *scan)
Definition: context.c:32
ctu_kind_t
Definition: ast.h:21
@ eCtuField
Definition: ast.h:75
@ eCtuExprField
Definition: ast.h:36
@ eCtuImport
Definition: ast.h:82
@ eCtuExprAlignOf
Definition: ast.h:44
@ eCtuDeclStruct
Definition: ast.h:72
@ eCtuStmtBranch
Definition: ast.h:55
@ eCtuTypeArray
Definition: ast.h:61
@ eCtuStmtWhile
Definition: ast.h:51
@ eCtuTypePointer
Definition: ast.h:59
@ eCtuTypeConst
Definition: ast.h:62
@ eCtuStmtContinue
Definition: ast.h:54
@ eCtuAttrib
Definition: ast.h:77
@ eCtuExprBinary
Definition: ast.h:32
@ eCtuParam
Definition: ast.h:76
@ eCtuModule
Definition: ast.h:83
@ eCtuDeclUnion
Definition: ast.h:71
@ eCtuStmtAssign
Definition: ast.h:52
@ eCtuExprChar
Definition: ast.h:26
@ eCtuDeclVariant
Definition: ast.h:70
@ eCtuExprFieldIndirect
Definition: ast.h:37
@ eCtuDeclTypeAlias
Definition: ast.h:69
@ eCtuExprName
Definition: ast.h:27
@ eCtuDeclGlobal
Definition: ast.h:65
@ eCtuExprCast
Definition: ast.h:28
@ eCtuVariantCase
Definition: ast.h:79
@ eCtuExprDeref
Definition: ast.h:40
@ eCtuStmtBreak
Definition: ast.h:53
@ eCtuTypeName
Definition: ast.h:58
@ eCtuExprCompare
Definition: ast.h:31
@ eCtuExprSizeOf
Definition: ast.h:43
@ eCtuStmtList
Definition: ast.h:48
@ eCtuStmtLocal
Definition: ast.h:49
@ eCtuStmtReturn
Definition: ast.h:50
@ eCtuExprCall
Definition: ast.h:34
@ eCtuExprInt
Definition: ast.h:23
@ eCtuDeclFunction
Definition: ast.h:66
@ eCtuExprString
Definition: ast.h:25
@ eCtuExprOffsetOf
Definition: ast.h:45
@ eCtuExprInit
Definition: ast.h:29
@ eCtuExprBool
Definition: ast.h:24
@ eCtuFieldInit
Definition: ast.h:78
@ eCtuExprRef
Definition: ast.h:39
@ eCtuExprUnary
Definition: ast.h:33
@ eCtuTypeFunction
Definition: ast.h:60
@ eCtuExprIndex
Definition: ast.h:35
CT_NODISCARD CT_SCAN_API node_t * node_new(const scan_t *scan, where_t where)
create a new node on the heap
Definition: node.c:40
#define ARENA_IDENTIFY(ptr, name, parent, arena)
rename and reparent a pointer in a custom allocator
Definition: arena.h:409
#define ARENA_MALLOC(size, name, parent, arena)
allocate memory from a custom allocator
Definition: arena.h:392
binary_t
all binary operators
Definition: ops.h:32
unary_t
all unary operators
Definition: ops.h:48
compare_t
all comparison operators
Definition: ops.h:40
CT_STD_API const vector_t kEmptyVector
a global empty vector used to avoid allocating alot of empty vectors
Definition: vector.c:25
ctu_t * ctu_stmt_return(scan_t *scan, where_t where, ctu_t *value)
Definition: ast.c:83
ctu_t * ctu_expr_name(scan_t *scan, where_t where, const vector_t *path)
Definition: ast.c:177
ctu_t * ctu_expr_init(scan_t *scan, where_t where, const vector_t *inits)
Definition: ast.c:162
ctu_t * ctu_expr_char(scan_t *scan, where_t where, char *text, size_t length)
Definition: ast.c:154
ctu_t * ctu_expr_field_indirect(scan_t *scan, where_t where, ctu_t *expr, char *field)
Definition: ast.c:222
ctu_t * ctu_builtin_alignof(scan_t *scan, where_t where, ctu_t *type)
Definition: ast.c:265
ctu_t * ctu_stmt_branch(scan_t *scan, where_t where, ctu_t *cond, ctu_t *then, ctu_t *other)
Definition: ast.c:121
ctu_t * ctu_expr_deref(scan_t *scan, where_t where, ctu_t *expr)
Definition: ast.c:199
ctu_t * ctu_variant_case(scan_t *scan, where_t where, char *name, bool is_default, ctu_t *expr)
Definition: ast.c:397
ctu_t * ctu_stmt_break(scan_t *scan, where_t where, char *label)
Definition: ast.c:107
ctu_t * ctu_expr_cast(scan_t *scan, where_t where, ctu_t *expr, ctu_t *type)
Definition: ast.c:184
ctu_t * ctu_expr_ref(scan_t *scan, where_t where, ctu_t *expr)
Definition: ast.c:192
ctu_t * ctu_import(scan_t *scan, where_t where, vector_t *path, char *name)
Definition: ast.c:42
ctu_t * ctu_expr_binary(scan_t *scan, where_t where, binary_t binary, ctu_t *lhs, ctu_t *rhs)
Definition: ast.c:238
ctu_t * ctu_decl_struct(scan_t *scan, where_t where, bool exported, char *name, vector_t *fields)
Definition: ast.c:358
ctu_t * ctu_apply(ctu_t *decl, const vector_t *attribs)
Definition: ast.c:59
ctu_t * ctu_expr_compare(scan_t *scan, where_t where, compare_t compare, ctu_t *lhs, ctu_t *rhs)
Definition: ast.c:247
ctu_t * ctu_type_array(scan_t *scan, where_t where, ctu_t *array, ctu_t *length)
Definition: ast.c:297
ctu_t * ctu_decl_global(scan_t *scan, where_t where, bool exported, bool mut, char *name, ctu_t *type, ctu_t *value)
Definition: ast.c:322
ctu_t * ctu_expr_index(scan_t *scan, where_t where, ctu_t *expr, ctu_t *index)
Definition: ast.c:206
ctu_t * ctu_decl_variant(scan_t *scan, where_t where, bool exported, char *name, ctu_t *underlying, const vector_t *cases)
Definition: ast.c:365
ctu_t * ctu_type_name(scan_t *scan, where_t where, vector_t *path)
Definition: ast.c:282
ctu_t * ctu_expr_string(scan_t *scan, where_t where, char *text, size_t length)
Definition: ast.c:146
ctu_t * ctu_field_init(scan_t *scan, where_t where, char *name, ctu_t *value)
Definition: ast.c:389
ctu_t * ctu_expr_int(scan_t *scan, where_t where, ctu_integer_t value)
Definition: ast.c:132
ctu_t * ctu_type_const(scan_t *scan, where_t where, ctu_t *type)
Definition: ast.c:313
ctu_t * ctu_type_pointer(scan_t *scan, where_t where, ctu_t *pointer, bool array)
Definition: ast.c:289
ctu_t * ctu_module(scan_t *scan, where_t where, const vector_t *modspec, const vector_t *imports, const vector_t *decls)
Definition: ast.c:33
ctu_t * ctu_param(scan_t *scan, where_t where, char *name, ctu_t *type)
Definition: ast.c:381
ctu_t * ctu_builtin_sizeof(scan_t *scan, where_t where, ctu_t *type)
Definition: ast.c:258
ctu_t * ctu_field(scan_t *scan, where_t where, char *name, ctu_t *type)
Definition: ast.c:373
ctu_t * ctu_stmt_continue(scan_t *scan, where_t where, char *label)
Definition: ast.c:114
ctu_t * ctu_stmt_assign(scan_t *scan, where_t where, ctu_t *dst, ctu_t *src)
Definition: ast.c:99
ctu_t * ctu_stmt_local(scan_t *scan, where_t where, bool mutable, char *name, ctu_t *type, ctu_t *value)
Definition: ast.c:74
ctu_t * ctu_stmt_list(scan_t *scan, where_t where, vector_t *stmts)
Definition: ast.c:67
ctu_t * ctu_builtin_offsetof(scan_t *scan, where_t where, ctu_t *type, char *field)
Definition: ast.c:272
ctu_t * ctu_expr_unary(scan_t *scan, where_t where, unary_t unary, ctu_t *expr)
Definition: ast.c:230
ctu_t * ctu_expr_call(scan_t *scan, where_t where, ctu_t *callee, const vector_t *args)
Definition: ast.c:169
ctu_t * ctu_expr_bool(scan_t *scan, where_t where, bool value)
Definition: ast.c:139
ctu_t * ctu_decl_union(scan_t *scan, where_t where, bool exported, char *name, vector_t *fields)
Definition: ast.c:351
ctu_t * ctu_type_function(scan_t *scan, where_t where, const vector_t *params, ctu_t *return_type)
Definition: ast.c:305
ctu_t * ctu_decl_function(scan_t *scan, where_t where, bool exported, char *name, const vector_t *params, char *variadic, ctu_t *return_type, ctu_t *body)
Definition: ast.c:331
ctu_t * ctu_attrib(scan_t *scan, where_t where, const vector_t *path, const vector_t *args)
Definition: ast.c:51
ctu_params_t ctu_params_new(const vector_t *params, char *variadic)
Definition: ast.c:410
ctu_t * ctu_decl_typealias(scan_t *scan, where_t where, bool exported, char *name, bool newtype, ctu_t *type)
Definition: ast.c:343
ctu_t * ctu_expr_field(scan_t *scan, where_t where, ctu_t *expr, char *field)
Definition: ast.c:214
ctu_t * ctu_stmt_while(scan_t *scan, where_t where, char *name, ctu_t *cond, ctu_t *then, ctu_t *other)
Definition: ast.c:90
an allocator object
Definition: arena.h:86
const vector_t * params
Definition: ast.h:349
Definition: ast.h:86
ctu_t * then
Definition: ast.h:103
ctu_t * array_type
Definition: ast.h:232
const vector_t * attrib_path
Definition: ast.h:238
bool array
Definition: ast.h:227
ctu_t * body
Definition: ast.h:119
ctu_t * cond
Definition: ast.h:102
ctu_t * other
Definition: ast.h:104
const vector_t * attribs
Definition: ast.h:94
binary_t binary
Definition: ast.h:172
ctu_t * callee
Definition: ast.h:202
size_t length
Definition: ast.h:160
ctu_t * index
Definition: ast.h:185
compare_t compare
Definition: ast.h:175
const vector_t * import_path
Definition: ast.h:98
const vector_t * fields
Definition: ast.h:129
const vector_t * attrib_args
Definition: ast.h:239
ctu_t * value
Definition: ast.h:110
const vector_t * inits
Definition: ast.h:164
ctu_t * underlying
Definition: ast.h:139
char * field
Definition: ast.h:191
ctu_t * case_value
Definition: ast.h:146
char * text
Definition: ast.h:159
const vector_t * imports
Definition: ast.h:245
const vector_t * decls
Definition: ast.h:246
char * label
Definition: ast.h:219
const vector_t * params
Definition: ast.h:116
vector_t * type_name
Definition: ast.h:222
ctu_t * param_type
Definition: ast.h:135
bool newtype
Definition: ast.h:124
ctu_integer_t integer
Definition: ast.h:152
bool mut
Definition: ast.h:111
const vector_t * args
Definition: ast.h:203
ctu_t * src
Definition: ast.h:215
bool default_case
Definition: ast.h:145
ctu_t * return_type
Definition: ast.h:118
ctu_t * rhs
Definition: ast.h:179
ctu_t * lhs
Definition: ast.h:178
ctu_t * array_length
Definition: ast.h:233
const vector_t * modspec
Definition: ast.h:244
ctu_t * cast
Definition: ast.h:194
const vector_t * stmts
Definition: ast.h:207
char * variadic
Definition: ast.h:117
ctu_t * type
Definition: ast.h:109
ctu_t * field_type
Definition: ast.h:132
ctu_t * expr
Definition: ast.h:197
ctu_t * pointer
Definition: ast.h:226
ctu_t * result
Definition: ast.h:210
const vector_t * path
Definition: ast.h:167
ctu_t * type_alias
Definition: ast.h:125
unary_t unary
Definition: ast.h:188
const vector_t * cases
Definition: ast.h:140
bool bool_value
Definition: ast.h:155
char * name
Definition: ast.h:92
ctu_t * dst
Definition: ast.h:214
a source file scanner
Definition: scan.h:24
a generic vector of pointers
Definition: vector.c:16
a location inside a scanner locations are inclusive and 0-based
Definition: where.h:23