/* * Type parser. * Copyright (c) 2023-2024, Quinn Stephens and the OSMORA team. * Provided under the BSD 3-Clause license. */ #ifndef _PARSER_TYPE_H #define _PARSER_TYPE_H #include #include #include "hashmap.h" #include "parser.h" enum type_kind { TYK_ALIAS, TYK_ENUM, TYK_STRUCT }; struct enum_member { struct hashmap_entry hashmap_entry; char *name; size_t name_len; uint64_t value; }; struct struct_member { struct hashmap_entry hashmap_entry; char *name; size_t name_len; size_t off, size; struct type *typ; int n_ptrs; }; struct type { struct hashmap_entry hashmap_entry; enum type_kind kind; char *name; size_t name_len; size_t size; union { int n_ptrs; struct hashmap members; }; }; void parse_type(struct parser *ctx); bool parse_type_ref(struct parser *ctx, struct type **typ_out, int *n_ptrs_out); #endif /* !_PARSER_TYPE_H */