Docs update, parser impl design changes, AST::add fleshed out.

This commit is contained in:
2023-04-22 22:24:55 -04:00
parent 4c4fe98e7e
commit 7ba474069c
9 changed files with 1330 additions and 1637 deletions

View File

@ -2,11 +2,6 @@
#include "Bloat.hpp"
namespace Global
{
bool ShouldShowDebug = false;
}
namespace Memory
{
using namespace zpl;
@ -41,92 +36,3 @@ namespace Memory
arena_free( & Global_Arena);
}
}
struct TokEntry
{
char const* Str;
sw Length;
};
ZPL_TABLE( static, TokMap, tokmap_, TokEntry )
sw token_fmt_va( char* buf, uw buf_size, char const* fmt, s32 num_tokens, va_list va )
{
char const* buf_begin = buf;
sw remaining = buf_size;
TokMap tok_map;
{
tokmap_init( & tok_map, g_allocator );
s32 left = num_tokens;
while ( left-- )
{
char const* token = va_arg( va, char const* );
char const* value = va_arg( va, char const* );
TokEntry entry
{
value,
str_len(value, (sw)128)
};
u32 key = crc32( token, str_len(token, 32) );
tokmap_set( & tok_map, key, entry );
}
}
sw result = 0;
char current = *fmt;
while ( current )
{
sw len = 0;
while ( current && current != '{' && remaining )
{
*buf = *fmt;
buf++;
fmt++;
current = *fmt;
}
if ( current == '{' )
{
char const* scanner = fmt;
s32 tok_len = 0;
while ( *scanner != '}' )
{
tok_len++;
scanner++;
}
char const* token = fmt;
u32 key = crc32( token, tok_len );
TokEntry value = * tokmap_get( & tok_map, key );
sw left = value.Length;
while ( left-- )
{
*buf = *value.Str;
buf++;
value.Str++;
}
scanner++;
fmt = scanner;
current = *fmt;
}
}
tokmap_clear( & tok_map );
return result;
}