2020-12-20 00:00:00 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "./tree.h"
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
const uint8_t* zone = biner_tree_parse(stdin);
|
|
|
|
if (zone == NULL) return EXIT_FAILURE;
|
|
|
|
|
|
|
|
const biner_tree_root_t* root = (const biner_tree_root_t*) zone;
|
|
|
|
|
|
|
|
const biner_tree_decl_t* decl =
|
|
|
|
(const biner_tree_decl_t*) (zone + root->decls);
|
|
|
|
while ((uintptr_t) decl != (uintptr_t) zone) {
|
|
|
|
printf("%s:\n", zone + decl->name);
|
|
|
|
|
|
|
|
const biner_tree_struct_member_t* member =
|
|
|
|
(const biner_tree_struct_member_t*) (zone + decl->member);
|
|
|
|
while ((uintptr_t) member != (uintptr_t) zone) {
|
2020-12-22 00:00:00 +00:00
|
|
|
printf(" ");
|
|
|
|
const biner_tree_struct_member_type_t* type =
|
|
|
|
(const biner_tree_struct_member_type_t*) (zone + member->type);
|
|
|
|
if (type->name == BINER_TREE_STRUCT_MEMBER_TYPE_NAME_USER_DECL) {
|
|
|
|
const biner_tree_decl_t* decl =
|
|
|
|
(const biner_tree_decl_t*) (zone + type->decl);
|
|
|
|
printf("%8s ", zone + decl->name);
|
|
|
|
} else {
|
|
|
|
printf("%8s ",
|
|
|
|
biner_tree_struct_member_type_name_string_map[type->name]);
|
|
|
|
}
|
|
|
|
printf("%s\n", zone + member->name);
|
2020-12-20 00:00:00 +00:00
|
|
|
member = (const biner_tree_struct_member_t*) (zone + member->prev);
|
|
|
|
}
|
|
|
|
decl = (const biner_tree_decl_t*) (zone + decl->prev);
|
|
|
|
}
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|