diff --git a/samples/node_errors/node_errors.c b/samples/node_errors/node_errors.c
index c5506ea..3cb929e 100644
--- a/samples/node_errors/node_errors.c
+++ b/samples/node_errors/node_errors.c
@@ -5,20 +5,18 @@
int main(int argument_count, char **arguments)
{
- // TODO(allen): use list system
-
// NOTE(rjf): Parse all the files passed in via command line.
- MD_Node *first = MD_NilNode();
- MD_Node *last = MD_NilNode();
+ MD_Node *list = MD_MakeList();
for(int i = 1; i < argument_count; i += 1)
{
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
- MD_PushSibling(&first, &last, root);
+ MD_PushReference(list, root);
}
// NOTE(rjf): Print errors on every single node.
- for(MD_EachNode(root, first))
+ for(MD_EachNode(ref, list->first_child))
{
+ MD_Node *root = MD_Deref(ref);
for(MD_EachNode(node, root->first_child))
{
MD_NodeMessageF(stderr, node, MD_MessageKind_Error, "This node has an error!");
diff --git a/samples/old_style_custom_layer.c b/samples/old_style_custom_layer.c
index 26bfd8a..94bf130 100644
--- a/samples/old_style_custom_layer.c
+++ b/samples/old_style_custom_layer.c
@@ -23,21 +23,19 @@ CleanUp(void)
int main(int argument_count, char **arguments)
{
- // TODO(allen): use list system
-
// NOTE(rjf): Parse all the files passed in via command line.
- MD_Node *first = MD_NilNode();
- MD_Node *last = MD_NilNode();
+ MD_Node *list = MD_MakeList();
for(int i = 1; i < argument_count; i += 1)
{
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
- MD_PushSibling(&first, &last, root);
+ MD_PushReference(list, root);
}
// NOTE(rjf): Call "custom layer" back.
Initialize();
- for(MD_EachNode(root, first))
+ for(MD_EachNode(ref, list->first_child))
{
+ MD_Node *root = MD_Deref(ref);
for(MD_EachNode(node, root->first_child))
{
TopLevel(node);
diff --git a/samples/output_parse/output_parse.c b/samples/output_parse/output_parse.c
index fc70f69..95dd903 100644
--- a/samples/output_parse/output_parse.c
+++ b/samples/output_parse/output_parse.c
@@ -58,19 +58,17 @@ static void PrintNode(MD_Node* node, FILE* file, int indent_count) {
int main(int argument_count, char **arguments)
{
- // TODO(allen): use list system
-
// NOTE(pmh): Parse all the files passed in via command line.
- MD_Node *first = MD_NilNode();
- MD_Node *last = MD_NilNode();
+ MD_Node *list = MD_MakeList();
for(int i = 1; i < argument_count; i += 1)
{
MD_Node *root = MD_ParseWholeFile(MD_S8CString(arguments[i])).node;
- MD_PushSibling(&first, &last, root);
+ MD_PushReference(list, root);
}
- for(MD_EachNode(root, first))
+ for(MD_EachNode(ref, list->first_child))
{
+ MD_Node *root = MD_Deref(ref);
MD_String8 code_filename = MD_ChopExtension(MD_SkipFolder(root->string));
MD_String8 info_filename = MD_PushStringF("parsed_%.*s.txt", MD_StringExpand(code_filename));
printf("Parse Input -> Output: %.*s -> %.*s\n", MD_StringExpand(code_filename), MD_StringExpand(info_filename));
diff --git a/samples/static_site_generator/example_site/generated/.html b/samples/static_site_generator/example_site/generated/.html
new file mode 100644
index 0000000..89c6771
--- /dev/null
+++ b/samples/static_site_generator/example_site/generated/.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Example Site
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/static_site_generator/static_site_generator.c b/samples/static_site_generator/static_site_generator.c
index 78161d1..6285f25 100644
--- a/samples/static_site_generator/static_site_generator.c
+++ b/samples/static_site_generator/static_site_generator.c
@@ -55,11 +55,8 @@ int main(int argument_count, char **arguments)
site_info = ParseSiteInfo(site_info_file);
}
- // TODO(allen): use list system
-
//~ NOTE(rjf): Parse pages.
- MD_Node *first_root = MD_NilNode();
- MD_Node *last_root = MD_NilNode();
+ MD_Node *root_list = MD_MakeList();
{
printf("Searching for site pages at \"%.*s\"...\n", MD_StringExpand(page_dir_path));
MD_FileInfo file_info = {0};
@@ -76,7 +73,8 @@ int main(int argument_count, char **arguments)
MD_String8 path = MD_PushStringF("%.*s/%.*s",
MD_StringExpand(folder),
MD_StringExpand(file_info.filename));
- MD_PushSibling(&first_root, &last_root, MD_ParseWholeFile(path).node);
+ MD_Node *node = MD_ParseWholeFile(path).node;
+ MD_PushReference(root_list, node);
}
}
}
@@ -84,8 +82,9 @@ int main(int argument_count, char **arguments)
//~ NOTE(rjf): Generate index table.
MD_Map index_table = {0};
{
- for(MD_EachNode(root, first_root))
+ for(MD_EachNode(ref, root_list->first_child))
{
+ MD_Node *root = MD_Deref(ref);
for(MD_EachNode(node, root->first_child))
{
if(!MD_NodeIsNil(node->first_child) && MD_StringMatch(node->string, MD_S8Lit("index"), MD_MatchFlag_CaseInsensitive))
@@ -123,8 +122,9 @@ int main(int argument_count, char **arguments)
}
//~ NOTE(rjf): Generate files for all roots.
- for(MD_EachNode(root, first_root))
+ for(MD_EachNode(ref, root_list->first_child))
{
+ MD_Node *root = MD_Deref(ref);
PageInfo page_info = ParsePageInfo(root);
MD_String8 name_without_extension = MD_SkipFolder(MD_ChopExtension(root->string));
diff --git a/samples/toy_language/toy_language.c b/samples/toy_language/toy_language.c
index 74159a2..fd844bb 100644
--- a/samples/toy_language/toy_language.c
+++ b/samples/toy_language/toy_language.c
@@ -179,21 +179,19 @@ int main(int argument_count, char **arguments)
//- rjf: parse command line
MD_CommandLine cmdln = MD_CommandLineFromOptions(MD_StringListFromArgCV(argument_count, arguments));
- // TODO(allen): use list system
-
//- rjf: parse all input files
- MD_Node *first_file = MD_NilNode();
- MD_Node *last_file = MD_NilNode();
+ MD_Node *file_list = MD_MakeList();
for(MD_String8Node *n = cmdln.inputs.first; n; n = n->next)
{
MD_ParseResult parse = MD_ParseWholeFile(n->string);
- MD_PushSibling(&first_file, &last_file, parse.node);
+ MD_PushReference(file_list, parse.node);
}
//- rjf: gather top-level symbol map
NamespaceNode global_ns_node = {0};
- for(MD_EachNode(file, first_file))
+ for(MD_EachNode(file_ref, file_list->first_child))
{
+ MD_Node *file = MD_Deref(file_ref);
for(MD_EachNode(top_level, file->first_child))
{
if(MD_NodeHasTag(top_level, MD_S8Lit("proc")))
diff --git a/source/md.h b/source/md.h
index fc1bd6d..6231f72 100644
--- a/source/md.h
+++ b/source/md.h
@@ -26,8 +26,6 @@
// MD_b32 MD_IMPL_FileIterIncrement(MD_FileIter*, MD_String8, MD_FileInfo*) - optional
// void* MD_IMPL_Alloc(MD_u64) - required
//
-// TODO(allen): Commentary about this system somewhere easy to discover when
-// you go digging.
#ifndef MD_H
#define MD_H
@@ -183,9 +181,6 @@
# define MD_LANG_CPP 0
#endif
-#define MD_FUNCTION
-#define MD_GLOBAL static
-
#if MD_LANG_CPP
# define MD_ZERO_STRUCT {}
#else
@@ -200,6 +195,11 @@
# define MD_C_LINKAGE_END }
#endif
+//~ Common defines
+
+#define MD_FUNCTION
+#define MD_GLOBAL static
+
#include
#include
#include
@@ -222,7 +222,7 @@ typedef float MD_f32;
typedef double MD_f64;
-//~ Basic UTF-8 string types.
+//~ Basic Unicode string types.
typedef struct MD_String8 MD_String8;
struct MD_String8
@@ -740,6 +740,8 @@ MD_FUNCTION MD_Node *MD_MakeNode(MD_NodeKind kind, MD_String8 string,
MD_String8 whole_string, MD_u8 *at);
MD_FUNCTION void MD_PushChild(MD_Node *parent, MD_Node *new_child);
MD_FUNCTION void MD_PushTag(MD_Node *node, MD_Node *tag);
+
+MD_FUNCTION MD_Node *MD_MakeList(void);
MD_FUNCTION MD_Node *MD_PushReference(MD_Node *list, MD_Node *target);
// TODO(allen): eliminate
diff --git a/source/md_impl.c b/source/md_impl.c
index 7b16bab..a170ed9 100644
--- a/source/md_impl.c
+++ b/source/md_impl.c
@@ -2166,6 +2166,14 @@ MD_PushTag(MD_Node *node, MD_Node *tag)
}
}
+MD_FUNCTION_IMPL MD_Node*
+MD_MakeList(void)
+{
+ MD_String8 empty = {0};
+ MD_Node *result = MD_MakeNode(MD_NodeKind_List, empty, empty, 0);
+ return(result);
+}
+
MD_FUNCTION_IMPL MD_Node*
MD_PushReference(MD_Node *list, MD_Node *target)
{