diff --git a/docs/metadesk_reference.md b/docs/metadesk_reference.md index 9dd96db..c1014bb 100644 --- a/docs/metadesk_reference.md +++ b/docs/metadesk_reference.md @@ -1117,26 +1117,6 @@ main: return: *MD_Node, }; -@send(Nodes) -@func MD_MakeNodeFromToken: { - kind: MD_NodeKind, - filename: MD_String8, - file: *MD_u8, - at: *MD_u8, - token: MD_Token, - return: *MD_Node, -}; - -@send(Nodes) -@func MD_MakeNodeFromString: { - kind: MD_NodeKind, - filename: MD_String8, - file: *MD_u8, - at: *MD_u8, - string: MD_String8 - return: *MD_Node, -}; - @send(Nodes) @func MD_PushSibling: { first: **MD_Node, diff --git a/source/md.h b/source/md.h index d4c7094..85e2384 100644 --- a/source/md.h +++ b/source/md.h @@ -708,7 +708,6 @@ MD_FUNCTION MD_Node *MD_NilNode(void); MD_FUNCTION MD_Node *MD_MakeNode(MD_NodeKind kind, MD_String8 string, MD_String8 whole_string, MD_String8 filename, MD_u8 *file_contents, MD_u8 *at); -MD_FUNCTION MD_Node *MD_MakeNodeFromToken(MD_NodeKind kind, MD_String8 filename, MD_u8 *file, MD_u8 *at, MD_Token token); MD_FUNCTION MD_Node *MD_MakeNodeFromString(MD_NodeKind kind, MD_String8 filename, MD_u8 *file, MD_u8 *at, MD_String8 string); MD_FUNCTION MD_Node *MD_MakeNodeReference(MD_Node *target); MD_FUNCTION void MD_PushSibling(MD_Node **first, MD_Node **last, MD_Node *new_sibling); diff --git a/source/md_impl.c b/source/md_impl.c index 5be8ed8..5a0e0d5 100644 --- a/source/md_impl.c +++ b/source/md_impl.c @@ -1887,8 +1887,8 @@ MD_ParseOneNodeFromCtx(MD_ParseCtx *ctx) MD_Parse_RequireKind(ctx, MD_TokenKind_CharLiteral, &token) || MD_Parse_RequireKind(ctx, MD_TokenKind_Symbol, &token)) { - result.node = MD_MakeNodeFromToken(MD_NodeKind_Label, ctx->filename, ctx->file_contents.str, - token.outer_string.str, token); + result.node = _MD_MakeNode_Ctx(ctx, MD_NodeKind_Label, + token.string, token.outer_string, token.outer_string.str); result.node->flags |= _MD_NodeFlagsFromTokenKind(token.kind); if(token.kind == MD_TokenKind_CharLiteral || token.kind == MD_TokenKind_StringLiteral) @@ -2018,7 +2018,11 @@ MD_FUNCTION_IMPL MD_ParseResult MD_ParseWholeString(MD_String8 filename, MD_String8 contents) { MD_ParseResult result = MD_ZERO_STRUCT; - MD_Node *root = MD_MakeNodeFromString(MD_NodeKind_File, filename, contents.str, contents.str, MD_PushStringF("`DD Parsed From \"%.*s\"`", MD_StringExpand(filename))); + // TODO(allen): we want to make the string for this actually just + // be the filename in the root/file idea. + MD_String8 root_string = MD_PushStringF("`DD Parsed From \"%.*s\"`", MD_StringExpand(filename)); + MD_Node *root = MD_MakeNode(MD_NodeKind_File, root_string, root_string, + filename, contents.str, contents.str); if(contents.size > 0) { // NOTE(allen): setup parse context @@ -2211,22 +2215,11 @@ MD_MakeNode(MD_NodeKind kind, MD_String8 string, return node; } -MD_FUNCTION_IMPL MD_Node * -MD_MakeNodeFromToken(MD_NodeKind kind, MD_String8 filename, MD_u8 *file, MD_u8 *at, MD_Token token) -{ - return MD_MakeNode(kind, token.string, token.outer_string, filename, file, at); -} - -MD_FUNCTION_IMPL MD_Node * -MD_MakeNodeFromString(MD_NodeKind kind, MD_String8 filename, MD_u8 *file, MD_u8 *at, MD_String8 string) -{ - return MD_MakeNode(kind, string, string, filename, file, at); -} - MD_FUNCTION_IMPL MD_Node * MD_MakeNodeReference(MD_Node *target) { - MD_Node *n = MD_MakeNodeFromString(MD_NodeKind_Reference, MD_S8Lit("`reference node`"), 0, 0, MD_S8Lit("`reference node`")); + MD_String8 string = MD_S8Lit("`reference node`"); + MD_Node *n = MD_MakeNode(MD_NodeKind_Reference, string, string, string, 0, 0); n->ref_target = target; return n; } diff --git a/tests/grammar.c b/tests/grammar.c index 16d8fa9..6fbf939 100644 --- a/tests/grammar.c +++ b/tests/grammar.c @@ -66,7 +66,7 @@ static MD_Node * NewChildLabel(MD_Node *parent, MD_String8 label) { MD_Node *result = 0; - result = MD_MakeNodeFromString(MD_NodeKind_Label, MD_S8Lit(""), 0, 0, label); + result = MD_MakeNode(MD_NodeKind_Label, label, label, MD_S8Lit(""), 0, 0); if(parent) { MD_PushChild(parent, result); diff --git a/tests/sanity_tests.c b/tests/sanity_tests.c index ec03d56..20c2043 100644 --- a/tests/sanity_tests.c +++ b/tests/sanity_tests.c @@ -58,7 +58,7 @@ EndTest(void) static MD_Node * MakeTestNode(MD_NodeKind kind, MD_String8 string) { - return MD_MakeNodeFromString(kind, MD_S8Lit("`TEST_NODE`"), 0, 0, string); + return MD_MakeNode(kind, string, string, MD_S8Lit("`TEST_NODE`"), 0, 0); } static MD_C_Expr *