mirror of
https://github.com/Ed94/metadesk.git
synced 2026-06-13 07:52:22 -07:00
fix build errors; remove dumb non-working printf annotations; move C++ user-defined-literal thing into the header
This commit is contained in:
@@ -411,8 +411,7 @@ GeneratePageContent(MD_Map *index_table, SiteInfo *site_info, PageInfo *page_inf
|
||||
{
|
||||
if(strnode->string.str[i] == '@')
|
||||
{
|
||||
MD_Node *root = MD_RootFromNode(node);
|
||||
MD_ParseResult parse = MD_ParseOneNode(root->string, MD_StringSubstring(strnode->string, i, strnode->string.size));
|
||||
MD_ParseResult parse = MD_ParseOneNode(MD_StringSubstring(strnode->string, i, strnode->string.size), 0);
|
||||
if(!MD_NodeIsNil(parse.node))
|
||||
{
|
||||
if(MD_NodeHasTag(node, MD_S8Lit("i")))
|
||||
|
||||
+26
-38
@@ -3,23 +3,20 @@
|
||||
|
||||
// TODO List
|
||||
//
|
||||
// [ ] Freeing calls, allow hooking the allocator with an arena or
|
||||
// something so that someone can use this for work at an application/game's
|
||||
// runtime
|
||||
// [ ] Outputting anything to MD or C code ideally would do something
|
||||
// smart with auto-indentation, since some people have wanted readable
|
||||
// layout (if they aren't using 4coder with virtual whitespace basically)
|
||||
// [ ] Split out C-related stuff into helper language layers
|
||||
// [ ] Helpers for parsing NodeFlags, figuring out which nodes in a set are
|
||||
// separated by a semicolon, something like MD_SeekNodeWithFlags(node) -> node ?
|
||||
// [ ] Escaping characters from strings
|
||||
// [ ] Fill in more String -> Integer helpers
|
||||
// [ ] Memory Management Strategy
|
||||
// [ ] Gather map of current memory management situation
|
||||
// [ ] Reset all memory operation?
|
||||
// [ ] Thread context?
|
||||
// [ ] Scratch memory?
|
||||
// [ ] Reference Manual
|
||||
// [ ] unify string literal token kinds
|
||||
// [ ] simplify string literal flags (triple as a single flag)
|
||||
// [ ] lexer detects broken comments
|
||||
// [ ] lexer detects broken strings
|
||||
// [ ] tests for legal tag syntaxes
|
||||
// [ ] tests that ensure we don't accept labels when expecting symbols e.g. foo ":" b; foo: "(" )
|
||||
// [ ] pass all tests
|
||||
// [ ] simplify error sorting and catastrophic error handling
|
||||
// [ ] integer -> string helpers
|
||||
// [ ] remove symbol digraphs (maybe a test for this or something) and remove from comments
|
||||
// [ ] stb_snprintf included and modified for %S ~ MD_String8
|
||||
// [ ] naming pass
|
||||
// [ ] get the branches/labels setup on Git for beta 0.1 and dev
|
||||
// [ ] announcement
|
||||
|
||||
// NOTE(allen): "Plugin" functionality
|
||||
//
|
||||
@@ -195,24 +192,6 @@
|
||||
# define MD_C_LINKAGE_END }
|
||||
#endif
|
||||
|
||||
#if MD_COMPILER_CL_YEAR >= 2005
|
||||
# include <sal.h>
|
||||
# if MD_COMPILER_CL_YEAR > 2005
|
||||
# define MD_FORMAT_STRING_ANNOTATION _Printf_format_string_
|
||||
# else
|
||||
# define MD_FORMAT_STRING_ANNOTATION __format_string
|
||||
# endif
|
||||
#else
|
||||
# define MD_FORMAT_STRING_ANNOTATION
|
||||
#endif
|
||||
|
||||
#if MD_COMPILER_CLANG || MD_COMPILER_GCC
|
||||
#define MD_FORMAT_FUNCTION_ANNOTATION(str_idx, check_idx) \
|
||||
__attribute__((format(printf, str_idx, check_idx)))
|
||||
#else
|
||||
#define MD_FORMAT_FUNCTION_ANNOTATION(str_idx, check_idx)
|
||||
#endif
|
||||
|
||||
//~ Common defines
|
||||
|
||||
#define MD_FUNCTION
|
||||
@@ -666,6 +645,15 @@ MD_FUNCTION MD_String8 MD_S8(MD_u8 *str, MD_u64 size);
|
||||
# define MD_S8Lit(s) MD_S8((MD_u8*)(s), sizeof(s) - 1)
|
||||
#endif
|
||||
|
||||
#if MD_LANG_CPP
|
||||
static inline MD_String8
|
||||
operator "" _md(const char *s, size_t size)
|
||||
{
|
||||
MD_String8 str = MD_S8((MD_u8 *)s, (MD_u64)size);
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
MD_FUNCTION MD_String8 MD_S8Range(MD_u8 *str, MD_u8 *opl);
|
||||
|
||||
MD_FUNCTION MD_String8 MD_StringSubstring(MD_String8 str, MD_u64 min, MD_u64 max);
|
||||
@@ -686,7 +674,7 @@ MD_FUNCTION MD_String8 MD_FolderFromPath(MD_String8 string);
|
||||
MD_FUNCTION MD_String8 MD_PushStringCopy(MD_String8 string);
|
||||
MD_FUNCTION MD_String8 MD_PushStringFV(char *fmt, va_list args);
|
||||
|
||||
MD_FUNCTION MD_String8 MD_PushStringF(MD_FORMAT_STRING_ANNOTATION char *fmt, ...) MD_FORMAT_FUNCTION_ANNOTATION(1, 2);
|
||||
MD_FUNCTION MD_String8 MD_PushStringF(char *fmt, ...);
|
||||
|
||||
#define MD_StringExpand(s) (int)(s).size, (s).str
|
||||
|
||||
@@ -796,9 +784,9 @@ it##_r = it##_r->next, it = MD_Deref(it##_r)
|
||||
//~ Error/Warning Helpers
|
||||
|
||||
MD_FUNCTION void MD_Message(FILE *out, MD_CodeLoc loc, MD_MessageKind kind, MD_String8 str);
|
||||
MD_FUNCTION void MD_MessageF(FILE *out, MD_CodeLoc loc, MD_MessageKind kind, MD_FORMAT_STRING_ANNOTATION char *fmt, ...) MD_FORMAT_FUNCTION_ANNOTATION(4, 5);
|
||||
MD_FUNCTION void MD_MessageF(FILE *out, MD_CodeLoc loc, MD_MessageKind kind, char *fmt, ...);
|
||||
MD_FUNCTION void MD_NodeMessage(FILE *out, MD_Node *node, MD_MessageKind kind, MD_String8 str);
|
||||
MD_FUNCTION void MD_NodeMessageF(FILE *out, MD_Node *node, MD_MessageKind kind, MD_FORMAT_STRING_ANNOTATION char *fmt, ...) MD_FORMAT_FUNCTION_ANNOTATION(4, 5);
|
||||
MD_FUNCTION void MD_NodeMessageF(FILE *out, MD_Node *node, MD_MessageKind kind, char *fmt, ...);
|
||||
|
||||
//~ Tree Comparison/Verification
|
||||
|
||||
|
||||
+2
-2
@@ -2295,7 +2295,7 @@ MD_Message(FILE *out, MD_CodeLoc loc, MD_MessageKind kind, MD_String8 str)
|
||||
}
|
||||
|
||||
MD_FUNCTION_IMPL void
|
||||
MD_MessageF(FILE *out, MD_CodeLoc loc, MD_MessageKind kind, MD_FORMAT_STRING_ANNOTATION char *fmt, ...) MD_FORMAT_FUNCTION_ANNOTATION(4, 5)
|
||||
MD_MessageF(FILE *out, MD_CodeLoc loc, MD_MessageKind kind, char *fmt, ...)
|
||||
{
|
||||
// TODO(allen): use scratch
|
||||
va_list args;
|
||||
@@ -2312,7 +2312,7 @@ MD_NodeMessage(FILE *out, MD_Node *node, MD_MessageKind kind, MD_String8 str)
|
||||
}
|
||||
|
||||
MD_FUNCTION_IMPL void
|
||||
MD_NodeMessageF(FILE *out, MD_Node *node, MD_MessageKind kind, MD_FORMAT_STRING_ANNOTATION char *fmt, ...) MD_FORMAT_FUNCTION_ANNOTATION(4, 5)
|
||||
MD_NodeMessageF(FILE *out, MD_Node *node, MD_MessageKind kind, char *fmt, ...)
|
||||
{
|
||||
// TODO(allen): use scratch
|
||||
va_list args;
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#include "md.h"
|
||||
#include "md.c"
|
||||
|
||||
MD_String8 operator "" _md(const char *s, size_t size)
|
||||
{
|
||||
MD_String8 str = MD_S8((MD_u8 *)s, (MD_u64)size);
|
||||
return str;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
MD_String8 str = "foobar"_md;
|
||||
|
||||
+6
-4
@@ -474,13 +474,15 @@ static MD_Node *
|
||||
FirstBadNodeAtPointer(MD_Node *node)
|
||||
{
|
||||
MD_Node *result = 0;
|
||||
MD_Node *root = MD_RootFromNode(node);
|
||||
MD_u8 *node_at = root->whole_string.str + node->offset;
|
||||
switch(node->kind){
|
||||
case MD_NodeKind_File:
|
||||
{
|
||||
} break;
|
||||
case MD_NodeKind_Label:
|
||||
{
|
||||
if(node->at != node->whole_string.str)
|
||||
if(node_at != node->whole_string.str)
|
||||
{
|
||||
if(node->whole_string.size)
|
||||
{
|
||||
@@ -488,7 +490,7 @@ FirstBadNodeAtPointer(MD_Node *node)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!node->at || (node->at[0] != '(' && node->at[0] != '[' && node->at[0] != '{'))
|
||||
if(!node_at || (node_at[0] != '(' && node_at[0] != '[' && node_at[0] != '{'))
|
||||
{
|
||||
result = node;
|
||||
}
|
||||
@@ -503,7 +505,7 @@ FirstBadNodeAtPointer(MD_Node *node)
|
||||
case MD_NodeKind_List:
|
||||
case MD_NodeKind_Tag:
|
||||
{
|
||||
if(node->at != node->whole_string.str)
|
||||
if(node_at != node->whole_string.str)
|
||||
{
|
||||
result = node;
|
||||
goto end;
|
||||
@@ -537,7 +539,7 @@ int main(int argument_count, char **arguments)
|
||||
// 1) Tag []-style sets as optional
|
||||
MD_Node *optional_tag = 0;
|
||||
{
|
||||
MD_ParseResult parse_result = MD_ParseOneNode(MD_S8Lit(""), MD_S8Lit("@"OPTIONAL_TAG" is_a_tag"));
|
||||
MD_ParseResult parse_result = MD_ParseOneNode(MD_S8Lit("@"OPTIONAL_TAG" is_a_tag"), 0);
|
||||
optional_tag = parse_result.node->first_tag;
|
||||
}
|
||||
TagSquareBracketSetsAsOptional(grammar, optional_tag);
|
||||
|
||||
@@ -858,5 +858,7 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
MD_String8 str = MD_PushStringF("%i", "foobar");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user