starting to review mdesk.h/c

This commit is contained in:
ed
2025-02-08 11:10:23 -05:00
parent 43baf82a8b
commit 68fadce5c6
21 changed files with 1166 additions and 1153 deletions
+13 -13
View File
@@ -83,7 +83,7 @@ print_expression(FILE *out, MD_Expr *expr)
MD_ExprOpr *op = expr->op;
if (op == 0)
{
MD_Node *node = expr->md_node;
Node *node = expr->md_node;
if (node->raw_string.size != 0)
{
fprintf(out, "%.*s", MD_S8VArg(node->raw_string));
@@ -92,27 +92,27 @@ print_expression(FILE *out, MD_Expr *expr)
{
char c1 = 0;
char c2 = 0;
if (node->flags & MD_NodeFlag_HasParenLeft)
if (node->flags & NodeFlag_HasParenLeft)
{
c1 = '(';
}
if (node->flags & MD_NodeFlag_HasBraceLeft)
if (node->flags & NodeFlag_HasBraceLeft)
{
c1 = '{';
}
if (node->flags & MD_NodeFlag_HasBracketLeft)
if (node->flags & NodeFlag_HasBracketLeft)
{
c1 = '[';
}
if (node->flags & MD_NodeFlag_HasParenRight)
if (node->flags & NodeFlag_HasParenRight)
{
c2 = ')';
}
if (node->flags & MD_NodeFlag_HasBraceRight)
if (node->flags & NodeFlag_HasBraceRight)
{
c2 = '}';
}
if (node->flags & MD_NodeFlag_HasBracketRight)
if (node->flags & NodeFlag_HasBracketRight)
{
c2 = ']';
}
@@ -131,7 +131,7 @@ print_expression(FILE *out, MD_Expr *expr)
{
default:
{
MD_Node *node = expr->md_node;
Node *node = expr->md_node;
MD_CodeLoc loc = MD_CodeLocFromNode(node);
MD_PrintMessage(stderr, loc, MD_MessageKind_FatalError,
MD_S8Lit("this is an unknown kind of operator"));
@@ -139,7 +139,7 @@ print_expression(FILE *out, MD_Expr *expr)
case MD_ExprOprKind_Prefix:
{
MD_Node *node = expr->md_node;
Node *node = expr->md_node;
fprintf(out, "%.*s(", MD_S8VArg(op->string));
print_expression(out, expr->unary_operand);
fprintf(out, ")");
@@ -150,7 +150,7 @@ print_expression(FILE *out, MD_Expr *expr)
fprintf(out, "(");
print_expression(out, expr->unary_operand);
MD_String8 op_string = op->string;
if ((expr->md_node->flags & MD_NodeFlag_MaskSetDelimiters) != 0)
if ((expr->md_node->flags & NodeFlag_MaskSetDelimiters) != 0)
{
fprintf(out, ")%c...%c", op_string.str[0], op_string.str[1]);
}
@@ -191,13 +191,13 @@ int main(int argc, char **argv)
arena = MD_ArenaAlloc();
// parse all files passed to the command line
MD_Node *list = MD_MakeList(arena);
Node *list = MD_MakeList(arena);
for (int i = 1; i < argc; i += 1)
{
// parse the file
MD_String8 file_name = MD_S8CString(argv[i]);
MD_ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
// print metadesk errors
for (MD_Message *message = parse_result.errors.first;
@@ -233,7 +233,7 @@ MD_ExprOprPush(arena, &list, MD_ExprOprKind_##k, p, MD_S8Lit(t), Op##e, 0);
// print the verbose parse results
for (MD_EachNode(root_it, list->first_child))
{
MD_Node *root = MD_ResolveNodeFromReference(root_it);
Node *root = MD_ResolveNodeFromReference(root_it);
for (MD_EachNode(node, root->first_child))
{
MD_ExprParseResult parse = MD_ExprParse(arena, &table, node->first_child, MD_NilNode());
+8 -8
View File
@@ -40,8 +40,8 @@ print_expression(FILE *out, MD_Expr *expr)
// whether it is a leaf or an operator. This node gives us a way to
// see information about this leaf, and also gives a way to create an
// MD_CodeLoc for error messages. The same works on operator nodes.
MD_Node *node = expr->md_node;
if ((node->flags & MD_NodeFlag_MaskSetDelimiters) == 0)
Node *node = expr->md_node;
if ((node->flags & NodeFlag_MaskSetDelimiters) == 0)
{
fprintf(out, "%.*s", MD_S8VArg(node->raw_string));
}
@@ -86,12 +86,12 @@ eval_expression(MD_Expr *expr)
MD_ExprOpr *op = expr->op;
if (op == 0)
{
MD_Node *node = expr->md_node;
if (node->flags & MD_NodeFlag_Numeric)
Node *node = expr->md_node;
if (node->flags & NodeFlag_Numeric)
{
result = MD_CStyleIntFromString(node->string);
}
else if (node->flags & MD_NodeFlag_Identifier)
else if (node->flags & NodeFlag_Identifier)
{
MD_MapSlot *slot = MD_MapLookup(&eval_map, MD_MapKeyStr(node->string));
if (slot != 0)
@@ -140,13 +140,13 @@ int main(int argc, char **argv)
arena = MD_ArenaAlloc();
// parse all files passed to the command line
MD_Node *list = MD_MakeList(arena);
Node *list = MD_MakeList(arena);
for (int i = 1; i < argc; i += 1)
{
// parse the file
MD_String8 file_name = MD_S8CString(argv[i]);
MD_ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
// print metadesk errors
for (MD_Message *message = parse_result.errors.first;
@@ -215,7 +215,7 @@ int main(int argc, char **argv)
// init eval map
eval_map = MD_MapMake(arena);
MD_Node *root = MD_ResolveNodeFromReference(root_it);
Node *root = MD_ResolveNodeFromReference(root_it);
for (MD_EachNode(node, root->first_child))
{
// @notes An expression parse is an extra stage of analysis on top
+2 -2
View File
@@ -61,7 +61,7 @@ typedef struct ConfigFile{
MD_Arena *arena;
MD_String8 file_name;
MD_String8 contents;
MD_Node *root;
Node *root;
MD_MessageList errors;
} ConfigFile;
@@ -86,7 +86,7 @@ new_config_file_from_file_name(char *file_name_cstr)
// explicitly so that we can save the contents and the parse in the
// ConfigFile.
MD_String8 contents = MD_LoadEntireFile(arena, file_name);
MD_ParseResult parse = MD_ParseWholeString(arena, file_name, contents);
ParseResult parse = MD_ParseWholeString(arena, file_name, contents);
// @notes This part can be a little bit subtle. First we allocated the
// arena with MD_ArenaAlloc. Then we used the arena to allocate a
+4 -4
View File
@@ -67,7 +67,7 @@ typedef struct ThreadData
// unique-to-thread
MD_Arena *arena;
MD_Node *list;
Node *list;
MD_MessageList errors;
} ThreadData;
@@ -86,7 +86,7 @@ parse_worker_loop(ThreadData *thread_data)
// load and parse the file specified by this task.
MD_String8 file_name = MD_S8CString(task->tasks[task_index]);
MD_ParseResult parse = MD_ParseWholeFile(thread_data->arena, file_name);
ParseResult parse = MD_ParseWholeFile(thread_data->arena, file_name);
MD_MessageListConcat(&thread_data->errors, &parse.errors);
MD_PushNewReference(thread_data->arena, thread_data->list, parse.node);
}
@@ -186,7 +186,7 @@ main(int argc, char **argv)
// print the name of each root
for (MD_EachNode(root_it, threads[i].list->first_child))
{
MD_Node *root = MD_ResolveNodeFromReference(root_it);
Node *root = MD_ResolveNodeFromReference(root_it);
fprintf(stdout, "%.*s\n", MD_S8VArg(root->string));
}
@@ -221,7 +221,7 @@ main(int argc, char **argv)
// combine results
MD_Arena *arena = threads[0].arena;
MD_Node *list = threads[0].list;
Node *list = threads[0].list;
MD_MessageList errors = threads[0].errors;
for (int i = 1; i < THREAD_COUNT; i += 1)
{
+5 -5
View File
@@ -27,7 +27,7 @@ static MD_Arena *arena = 0;
//~ Declare user defined functions (the data desk "custom layer") //////////////
static void Initialize(void); // Runs at the beginning of generation.
static void TopLevel(MD_Node *node); // Runs once for each top-level node from each file.
static void TopLevel(Node *node); // Runs once for each top-level node from each file.
static void CleanUp(void); // Runs at the end of generation.
@@ -40,13 +40,13 @@ int main(int argument_count, char **arguments)
// parse all files passed to the command line
MD_b32 failed_parse = 0;
MD_Node *list = MD_MakeList(arena);
Node *list = MD_MakeList(arena);
for(int i = 1; i < argument_count; i += 1)
{
// parse the file
MD_String8 file_name = MD_S8CString(arguments[i]);
MD_ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
// print metadesk errors
for (MD_Message *message = parse_result.errors.first;
@@ -73,7 +73,7 @@ int main(int argument_count, char **arguments)
Initialize();
for(MD_EachNode(ref, list->first_child))
{
MD_Node *root = MD_ResolveNodeFromReference(ref);
Node *root = MD_ResolveNodeFromReference(ref);
for(MD_EachNode(node, root->first_child))
{
TopLevel(node);
@@ -95,7 +95,7 @@ Initialize(void)
}
static void
TopLevel(MD_Node *node)
TopLevel(Node *node)
{
/*TODO*/
}
+1 -1
View File
@@ -20,7 +20,7 @@ main(int argc, char **argv)
// parse a string
MD_String8 name = MD_S8Lit("<name>");
MD_String8 hello_world = MD_S8Lit("hello world");
MD_ParseResult parse = MD_ParseWholeString(arena, name, hello_world);
ParseResult parse = MD_ParseWholeString(arena, name, hello_world);
// print the results
MD_PrintDebugDumpFromNode(stdout, parse.node, MD_GenerateFlags_All);
+7 -7
View File
@@ -25,7 +25,7 @@ int main(int argc, char **argv)
arena = MD_ArenaAlloc();
// parse all files passed to the command line
MD_Node *list = MD_MakeList(arena);
Node *list = MD_MakeList(arena);
for (int i = 1; i < argc; i += 1)
{
@@ -35,7 +35,7 @@ int main(int argc, char **argv)
// this metadesk's default implementations for the overrides make
// this work.
MD_String8 file_name = MD_S8CString(argv[i]);
MD_ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
// print metadesk errors
for (MD_Message *message = parse_result.errors.first;
@@ -65,21 +65,21 @@ int main(int argc, char **argv)
// print the verbose parse results
// @notes The Metadesk library provides a macros for iterating chains of
// MD_Node as shown here. The first parameter to the macro names an
// MD_Node pointer in the for loop that iterates through each node in the
// Node as shown here. The first parameter to the macro names an
// Node pointer in the for loop that iterates through each node in the
// list. The second parameter is a pointer to the first node of the list.
// Generally we past the `first_child` of a list or parent MD_Node, but we
// Generally we past the `first_child` of a list or parent Node, but we
// don't always have to.
for (MD_EachNode(root_it, list->first_child))
{
// @notes The `list` we have been building does not contain a normal
// MD_Node chain like in the trees returned from the parser. Instead
// Node chain like in the trees returned from the parser. Instead
// it contains a chain of 'reference' nodes, which can point to any
// metadesk node from a previous parse. So our `root_it` is iterating
// a list of reference nodes. Here we resolve the reference node to
// get the root of the parse tree.
MD_Node *root = MD_ResolveNodeFromReference(root_it);
Node *root = MD_ResolveNodeFromReference(root_it);
for (MD_EachNode(node, root->first_child))
{
+48 -48
View File
@@ -59,7 +59,7 @@ FILE *error_file = 0;
// @notes As we analyze the Metadesk tree we create more data. In this example
// the new data is stored in two major types GEN_TypeInfo and GEN_MapInfo.
// We form a list for each type of these "processed" types holds a pointer
// back to the original MD_Node that generated it, and room for information
// back to the original Node that generated it, and room for information
// that will be equiped to the "processed" type in later stages of analysis.
// We also use the MD_Map helper to create a string -> pointer mapping so that
// we can look up the "processed" info pointers by name after the initial
@@ -76,11 +76,11 @@ MD_Map map_map = {0};
//~ helpers ///////////////////////////////////////////////////////////////////
MD_Node*
gen_get_child_value(MD_Node *parent, MD_String8 child_name)
Node*
gen_get_child_value(Node *parent, MD_String8 child_name)
{
MD_Node *child = MD_ChildFromString(parent, child_name, 0);
MD_Node *result = child->first_child;
Node *child = MD_ChildFromString(parent, child_name, 0);
Node *result = child->first_child;
return(result);
}
@@ -103,7 +103,7 @@ gen_resolve_type_info_from_string(MD_String8 name)
}
GEN_TypeInfo*
gen_resolve_type_info_from_referencer(MD_Node *reference)
gen_resolve_type_info_from_referencer(Node *reference)
{
GEN_TypeInfo *result = gen_resolve_type_info_from_string(reference->string);
return(result);
@@ -143,10 +143,10 @@ gen_map_case_from_enumerant(GEN_MapInfo *map, GEN_TypeEnumerant *enumerant)
return(result);
}
MD_Node*
Node*
gen_get_symbol_md_node_by_name(MD_String8 name)
{
MD_Node *result = MD_NilNode();
Node *result = MD_NilNode();
MD_MapSlot *type_slot = MD_MapLookup(&type_map, MD_MapKeyStr(name));
if (type_slot != 0)
{
@@ -163,7 +163,7 @@ gen_get_symbol_md_node_by_name(MD_String8 name)
}
void
gen_type_resolve_error(MD_Node *reference)
gen_type_resolve_error(Node *reference)
{
MD_CodeLoc loc = MD_CodeLocFromNode(reference);
MD_PrintMessageFmt(error_file, loc, MD_MessageKind_Error,
@@ -171,7 +171,7 @@ gen_type_resolve_error(MD_Node *reference)
}
void
gen_duplicate_symbol_error(MD_Node *new_node, MD_Node *existing_node)
gen_duplicate_symbol_error(Node *new_node, Node *existing_node)
{
MD_CodeLoc loc = MD_CodeLocFromNode(new_node);
MD_PrintMessageFmt(error_file, loc, MD_MessageKind_Error,
@@ -184,9 +184,9 @@ gen_duplicate_symbol_error(MD_Node *new_node, MD_Node *existing_node)
}
void
gen_check_and_do_duplicate_symbol_error(MD_Node *new_node)
gen_check_and_do_duplicate_symbol_error(Node *new_node)
{
MD_Node *existing = gen_get_symbol_md_node_by_name(new_node->string);
Node *existing = gen_get_symbol_md_node_by_name(new_node->string);
if (!MD_NodeIsNil(existing))
{
gen_duplicate_symbol_error(new_node, existing);
@@ -206,22 +206,22 @@ gen_check_and_do_duplicate_symbol_error(MD_Node *new_node)
// where the kind field is not one of the expected values.
void
gen_gather_types_and_maps(MD_Node *list)
gen_gather_types_and_maps(Node *list)
{
for(MD_EachNode(ref, list->first_child))
{
MD_Node *root = MD_ResolveNodeFromReference(ref);
Node *root = MD_ResolveNodeFromReference(ref);
for(MD_EachNode(node, root->first_child))
{
// gather type
MD_Node *type_tag = MD_TagFromString(node, MD_S8Lit("type"), 0);
Node *type_tag = MD_TagFromString(node, MD_S8Lit("type"), 0);
if (!MD_NodeIsNil(type_tag))
{
gen_check_and_do_duplicate_symbol_error(node);
GEN_TypeKind kind = GEN_TypeKind_Null;
MD_Node *tag_arg_node = type_tag->first_child;
Node *tag_arg_node = type_tag->first_child;
MD_String8 tag_arg_str = tag_arg_node->string;
if (MD_S8Match(tag_arg_str, MD_S8Lit("basic"), 0))
{
@@ -274,7 +274,7 @@ gen_check_duplicate_member_names(void)
type != 0;
type = type->next)
{
MD_Node *type_root_node = type->node;
Node *type_root_node = type->node;
for (MD_EachNode(member_node, type_root_node->first_child))
{
MD_String8 name = member_node->string;
@@ -315,8 +315,8 @@ gen_equip_basic_type_size(void)
// extract the size
int size = 0;
MD_Node *size_node = type->node->first_child;
MD_Node *error_at = 0;
Node *size_node = type->node->first_child;
Node *error_at = 0;
if (MD_NodeIsNil(size_node))
{
error_at = type->node;
@@ -361,10 +361,10 @@ gen_equip_struct_members(void)
GEN_TypeMember *last_member = 0;
int member_count = 0;
MD_Node *type_root_node = type->node;
Node *type_root_node = type->node;
for (MD_EachNode(member_node, type_root_node->first_child))
{
MD_Node *type_name_node = member_node->first_child;
Node *type_name_node = member_node->first_child;
// missing type node?
if (MD_NodeIsNil(type_name_node))
@@ -392,10 +392,10 @@ gen_equip_struct_members(void)
if (got_list)
{
GEN_TypeMember *array_count = 0;
MD_Node *array_tag = MD_TagFromString(type_name_node, MD_S8Lit("array"), 0);
Node *array_tag = MD_TagFromString(type_name_node, MD_S8Lit("array"), 0);
if (!MD_NodeIsNil(array_tag))
{
MD_Node *array_count_referencer = array_tag->first_child;
Node *array_count_referencer = array_tag->first_child;
if (array_count_referencer->string.size == 0)
{
MD_CodeLoc loc = MD_CodeLocFromNode(array_tag);
@@ -404,7 +404,7 @@ gen_equip_struct_members(void)
}
else
{
MD_Node *array_count_member_node =
Node *array_count_member_node =
MD_ChildFromString(type_root_node, array_count_referencer->string, 0);
if (MD_NodeIsNil(array_count_member_node))
{
@@ -471,10 +471,10 @@ gen_equip_enum_underlying_type(void)
// extract underlying type
GEN_TypeInfo *underlying_type = 0;
MD_Node *type_node = type->node;
MD_Node *type_tag = MD_TagFromString(type_node, MD_S8Lit("type"), 0);
MD_Node *type_tag_param = type_tag->first_child;
MD_Node *underlying_type_ref = type_tag_param->first_child;
Node *type_node = type->node;
Node *type_tag = MD_TagFromString(type_node, MD_S8Lit("type"), 0);
Node *type_tag_param = type_tag->first_child;
Node *underlying_type_ref = type_tag_param->first_child;
if (!MD_NodeIsNil(underlying_type_ref))
{
GEN_TypeInfo *resolved_type = gen_resolve_type_info_from_referencer(underlying_type_ref);
@@ -522,10 +522,10 @@ gen_equip_enum_members(void)
int next_implicit_value = 0;
MD_Node *type_root_node = type->node;
Node *type_root_node = type->node;
for (MD_EachNode(enumerant_node, type_root_node->first_child))
{
MD_Node *value_node = enumerant_node->first_child;
Node *value_node = enumerant_node->first_child;
int value = 0;
// missing value node?
@@ -581,19 +581,19 @@ gen_equip_map_in_out_types(void)
map != 0;
map = map->next)
{
MD_Node *map_root_node = map->node;
MD_Node *map_tag = MD_TagFromString(map_root_node, MD_S8Lit("map"), 0);
Node *map_root_node = map->node;
Node *map_tag = MD_TagFromString(map_root_node, MD_S8Lit("map"), 0);
// NOTE we could use an expression parser here to make this fancier
// and check for the 'In -> Out' semicolon delimited syntax more
// carefully, this isn't checking it very rigorously. But there are
// no other cases we need to expect so far so being a bit sloppy
// buys us a lot of simplicity.
MD_Node *in_node = map_tag->first_child;
MD_Node *arrow = in_node->next;
MD_Node *out_node = arrow->next;
Node *in_node = map_tag->first_child;
Node *arrow = in_node->next;
Node *out_node = arrow->next;
{
MD_Node *error_at = 0;
Node *error_at = 0;
if (MD_NodeIsNil(in_node))
{
error_at = map_tag;
@@ -666,8 +666,8 @@ gen_equip_map_in_out_types(void)
// check for named children in the map tag
int is_complete = MD_NodeHasChild(map_tag, MD_S8Lit("complete"), 0);
MD_Node *default_val = gen_get_child_value(map_tag, MD_S8Lit("default"));
MD_Node *auto_val = gen_get_child_value(map_tag, MD_S8Lit("auto"));
Node *default_val = gen_get_child_value(map_tag, MD_S8Lit("default"));
Node *auto_val = gen_get_child_value(map_tag, MD_S8Lit("auto"));
// save to map
map->typed_map = typed_map;
@@ -697,16 +697,16 @@ gen_equip_map_cases(void)
GEN_MapCase *last_case = 0;
int case_count = 0;
MD_Node *map_root_node = map->node;
Node *map_root_node = map->node;
for (MD_Node *case_node = map_root_node->first_child;
for (Node *case_node = map_root_node->first_child;
!MD_NodeIsNil(case_node);
case_node = MD_FirstNodeWithFlags(case_node->next, MD_NodeFlag_IsAfterComma))
case_node = MD_FirstNodeWithFlags(case_node->next, NodeFlag_IsAfterComma))
{
// extract in & out
MD_Node *in = case_node;
MD_Node *arrow = in->next;
MD_Node *out = arrow->next;
Node *in = case_node;
Node *arrow = in->next;
Node *out = arrow->next;
if (!MD_S8Match(arrow->string, MD_S8Lit("->"), 0) ||
MD_NodeIsNil(out))
{
@@ -1237,12 +1237,12 @@ main(int argc, char **argv)
error_file = stderr;
// parse all files passed to the command line
MD_Node *list = MD_MakeList(arena);
Node *list = MD_MakeList(arena);
for (int i = 1; i < argc; i += 1)
{
// parse the file
MD_String8 file_name = MD_S8CString(argv[i]);
MD_ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
// print metadesk errors
for (MD_Message *message = parse_result.errors.first;
@@ -1323,7 +1323,7 @@ main(int argc, char **argv)
case GEN_TypeKind_Enum: kind_string = "enum"; break;
}
MD_Node *node = type->node;
Node *node = type->node;
printf("%.*s: %s\n", MD_S8VArg(node->string), kind_string);
// print member lists
@@ -1351,7 +1351,7 @@ main(int argc, char **argv)
map != 0;
map = map->next)
{
MD_Node *node = map->node;
Node *node = map->node;
printf("%.*s: map\n", MD_S8VArg(node->string));
// print case list
+15 -15
View File
@@ -24,7 +24,7 @@ struct GEN_TypeInfo
{
GEN_TypeInfo *next;
GEN_TypeKind kind;
MD_Node *node;
Node *node;
// basic
int size;
@@ -45,10 +45,10 @@ typedef struct GEN_TypeMember GEN_TypeMember;
struct GEN_TypeMember
{
GEN_TypeMember *next;
MD_Node *node;
Node *node;
GEN_TypeInfo *type;
struct GEN_TypeMember *array_count;
//MD_Node *array_count;
//Node *array_count;
int member_index;
};
@@ -56,7 +56,7 @@ typedef struct GEN_TypeEnumerant GEN_TypeEnumerant;
struct GEN_TypeEnumerant
{
GEN_TypeEnumerant *next;
MD_Node *node;
Node *node;
int value;
};
@@ -64,13 +64,13 @@ typedef struct GEN_MapInfo GEN_MapInfo;
struct GEN_MapInfo
{
GEN_MapInfo *next;
MD_Node *node;
Node *node;
struct GEN_TypedMapInfo *typed_map;
int is_complete;
MD_Node *default_val;
MD_Node *auto_val;
Node *default_val;
Node *auto_val;
struct GEN_MapCase *first_case;
struct GEN_MapCase *last_case;
@@ -95,29 +95,29 @@ struct GEN_MapCase
{
GEN_MapCase *next;
GEN_TypeEnumerant *in_enumerant;
MD_Node *out;
Node *out;
};
//~ helpers ///////////////////////////////////////////////////////////////////
MD_Node* gen_get_child_value(MD_Node *parent, MD_String8 child_name);
Node* gen_get_child_value(Node *parent, MD_String8 child_name);
GEN_TypeInfo* gen_resolve_type_info_from_string(MD_String8 name);
GEN_TypeInfo* gen_resolve_type_info_from_referencer(MD_Node *reference);
GEN_TypeInfo* gen_resolve_type_info_from_referencer(Node *reference);
GEN_TypeEnumerant* gen_enumerant_from_name(GEN_TypeInfo *enum_type, MD_String8 name);
GEN_MapCase* gen_map_case_from_enumerant(GEN_MapInfo *map, GEN_TypeEnumerant *enumerant);
MD_Node* gen_get_symbol_md_node_by_name(MD_String8 name);
Node* gen_get_symbol_md_node_by_name(MD_String8 name);
void gen_type_resolve_error(MD_Node *reference);
void gen_duplicate_symbol_error(MD_Node *new_node, MD_Node *existing_node);
void gen_type_resolve_error(Node *reference);
void gen_duplicate_symbol_error(Node *new_node, Node *existing_node);
void gen_check_and_do_duplicate_symbol_error(MD_Node *new_node);
void gen_check_and_do_duplicate_symbol_error(Node *new_node);
//~ analyzers /////////////////////////////////////////////////////////////////
void gen_gather_types_and_maps(MD_Node *list);
void gen_gather_types_and_maps(Node *list);
void gen_check_duplicate_member_names(void);
void gen_equip_basic_type_size(void);
void gen_equip_struct_members(void);
+6 -6
View File
@@ -28,12 +28,12 @@ int main(int argc, char **argv)
arena = MD_ArenaAlloc();
// parse all files passed to the command line
MD_Node *list = MD_MakeList(arena);
Node *list = MD_MakeList(arena);
for(int i = 1; i < argc; i += 1)
{
// parse the file
MD_String8 file_name = MD_S8CString(argv[i]);
MD_ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
ParseResult parse_result = MD_ParseWholeFile(arena, file_name);
// @notes Here we are printing out all the messages that came back from
// the parser. We could try to wait and print all the errors at once,
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
// check for custom errors
for(MD_EachNode(ref, list->first_child))
{
MD_Node *root = MD_ResolveNodeFromReference(ref);
Node *root = MD_ResolveNodeFromReference(ref);
// @notes The custom rules in this example apply to the top level nodes
// so we can check for them by visiting each node from the root.
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
// as an array and access it by index. If there's a tag at index 1
// then we know there are at least two tags, which is against
// the first custom rule.
MD_Node *tag_2 = MD_TagFromIndex(node, 1);
Node *tag_2 = MD_TagFromIndex(node, 1);
if (!MD_NodeIsNil(tag_2))
{
// @notes The MD_PrintMessage helper formats a message for us
@@ -97,8 +97,8 @@ int main(int argc, char **argv)
// @notes The second custom rule applies to sets with "[]"
// delimiters. We can easily detect nodes for those sets by
// checking the node flags:
if ((node->flags & MD_NodeFlag_HasBracketLeft) ||
(node->flags & MD_NodeFlag_HasBracketRight))
if ((node->flags & NodeFlag_HasBracketLeft) ||
(node->flags & NodeFlag_HasBracketRight))
{
if (node->string.size > 0)
{