Switch to map_proposal.

This commit is contained in:
Miguel Lechon
2021-03-16 11:11:13 +01:00
parent d5ab0e88df
commit fed011fc52
4 changed files with 18 additions and 12 deletions
@@ -516,11 +516,11 @@ GeneratePageContent(MD_NodeTable *index_table, SiteInfo *site_info, PageInfo *pa
for(MD_NodeTableSlot *slot = MD_NodeTable_Lookup(index_table, index_string->string);
slot; slot = slot->next)
{
if(slot->node)
if(slot->value)
{
PageInfo info = ParsePageInfo(slot->node);
PageInfo info = ParsePageInfo((MD_Node *)slot->value);
MD_String8 filename = slot->node->filename;
MD_String8 filename = ((MD_Node *)slot->value)->filename;
MD_String8 filename_no_ext = MD_ChopExtension(MD_SkipFolder(filename));
MD_String8 link = MD_PushStringF("%.*s.html", MD_StringExpand(filename_no_ext));
MD_String8 name = info.title->string;
+4 -1
View File
@@ -385,7 +385,7 @@ typedef enum MD_MessageKind
MD_MessageKind;
//~ String-To-Node table
#if 0
typedef enum MD_NodeTableCollisionRule
{
MD_NodeTableCollisionRule_Chain,
@@ -407,6 +407,9 @@ struct MD_NodeTable
MD_u64 table_size;
MD_NodeTableSlot **table;
};
#else
#include "map_proposal.h"
#endif
//~ Token kinds.
+5 -2
View File
@@ -947,7 +947,7 @@ MD_S32FromS8(MD_String8 in)
return(result);
}
#if 0
MD_PRIVATE_FUNCTION_IMPL void
_MD_NodeTable_Initialize(MD_NodeTable *table)
{
@@ -1027,6 +1027,9 @@ MD_NodeTable_Insert(MD_NodeTable *table, MD_NodeTableCollisionRule collision_rul
return !!slot;
}
#else
#include "map_proposal.c"
#endif
MD_FUNCTION_IMPL MD_b32
MD_TokenKindIsWhitespace(MD_TokenKind kind)
@@ -1990,7 +1993,7 @@ MD_ParseWholeString(MD_String8 filename, MD_String8 contents)
MD_NodeTable_Insert(&ctx.namespace_table, MD_NodeTableCollisionRule_Overwrite, token.string, ns);
existing_namespace_slot = MD_NodeTable_Lookup(&ctx.namespace_table, token.string);
}
ctx.selected_namespace = existing_namespace_slot->node;
ctx.selected_namespace = (MD_Node *)existing_namespace_slot->value;
}
else
{
+6 -6
View File
@@ -251,7 +251,7 @@ static void ExpandRule(MD_Node *rule, MD_String8List *out_strings, MD_Node *cur_
}
else // NOTE(mal): Non-terminal production
{
MD_Node * production = MD_NodeTable_Lookup(globals.production_table, rule_element->string)->node;
MD_Node * production = MD_NodeTable_Lookup(globals.production_table, rule_element->string)->value;
MD_Assert(production);
ExpandProduction(production, out_strings, cur_node, op_flags, max_depth, depth+1);
}
@@ -314,7 +314,7 @@ static MD_Node * FindNonTerminalProduction(MD_Node *node, MD_NodeTable *visited)
MD_NodeTableSlot *slot = MD_NodeTable_Lookup(globals.production_table, node->string);
if(slot)
{
MD_Node *production = slot->node;
MD_Node *production = slot->value;
result = FindNonTerminalProduction(production, visited);
}
else
@@ -429,7 +429,7 @@ static void ComputeElementDepth(MD_Node *re)
}
else
{
MD_Node * production = MD_NodeTable_Lookup(globals.production_table, re->string)->node;
MD_Node * production = MD_NodeTable_Lookup(globals.production_table, re->string)->value;
result = GET_DEPTH(production)+1;
}
}
@@ -592,7 +592,7 @@ int main(int argument_count, char **arguments)
fprintf(stderr, "Error: Grammar file does not specify \"file\" production\n");
goto error;
}
file_production = file_production_slot->node;
file_production = file_production_slot->value;
}
// NOTE(mal): Check that all branches lead to terminal nodes
@@ -641,7 +641,7 @@ int main(int argument_count, char **arguments)
MD_Assert(MD_NodeIsNil(rule_element->first_child));
if(!(rule_element->flags & MD_NodeFlag_CharLiteral))
{
MD_Node * production = MD_NodeTable_Lookup(globals.production_table, rule_element->string)->node;
MD_Node * production = MD_NodeTable_Lookup(globals.production_table, rule_element->string)->value;
depth = GET_DEPTH(production);
}
depth += 1;
@@ -694,7 +694,7 @@ int main(int argument_count, char **arguments)
RandomSeries random_series = rand_seed(0, 0); // NOTE(mal): Reproduceable
globals.random_series = &random_series;
MD_Node* file_production_node = MD_NodeTable_Lookup(globals.production_table, MD_S8Lit("file"))->node;
MD_Node* file_production_node = MD_NodeTable_Lookup(globals.production_table, MD_S8Lit("file"))->value;
// NOTE(mal): Generate test_count unique tests, sorted by complexity
MD_u32 test_count = 1000;