Improve build tool api, cleanup pass, add lexer tests

This commit is contained in:
Krzosa Karol
2024-01-25 22:21:58 +01:00
parent 738d27db9d
commit e39cd78546
12 changed files with 94 additions and 94 deletions

View File

@@ -722,7 +722,7 @@ CL_PRIVATE_FUNCTION bool CL_LexMacro(CL_Lexer *T, CL_Token *token) {
}
// Skipped space here is for case #define Memes (a), this is not a function like macro because of space
static uint32_t CL_TokenID; // @todo: make it stable, thread local?
static uint32_t CL_TokenID; // @todo: make it read only
CL_PRIVATE_FUNCTION void CL_PrepareToken(CL_Lexer *T, CL_Token *token, bool skipped_space) {
CL_MemoryZero(token, sizeof(*token));
token->str = T->stream;

View File

@@ -81,24 +81,24 @@
#endif
#if OS_MAC
#define ON_MAC(x) x
#define IF_MAC(x) x
#else
#define ON_MAC(x)
#define IF_MAC(x)
#endif
#if OS_WINDOWS
#define ON_WINDOWS(x) x
#define IF_WINDOWS(x) x
#define IF_WINDOWS_ELSE(x, y) x
#else
#define ON_WINDOWS(x)
#define IF_WINDOWS(x)
#define IF_WINDOWS_ELSE(x, y) y
#endif
#if OS_LINUX
#define ON_LINUX(x) x
#define IF_LINUX(x) x
#define IF_LINUX_ELSE(x, y) x
#else
#define ON_LINUX(x)
#define IF_LINUX(x)
#define IF_LINUX_ELSE(x, y) y
#endif

View File

@@ -120,7 +120,16 @@ S8_API S8_String S8_CopyChar(S8_Allocator allocator, char *s) {
return result;
}
S8_API void S8_NormalizePath(S8_String s) {
S8_API S8_String S8_NormalizePath(S8_Allocator allocator, S8_String s) {
S8_String copy = S8_Copy(allocator, s);
for (int64_t i = 0; i < copy.len; i++) {
if (copy.str[i] == '\\')
copy.str[i] = '/';
}
return copy;
}
S8_API void S8_NormalizePathUnsafe(S8_String s) {
for (int64_t i = 0; i < s.len; i++) {
if (s.str[i] == '\\')
s.str[i] = '/';

View File

@@ -131,7 +131,8 @@ S8_API bool S8_EndsWith(S8_String a, S8_String end, unsigned ignore_case S8_IF_C
S8_API bool S8_StartsWith(S8_String a, S8_String start, unsigned ignore_case S8_IF_CPP(= false));
S8_API S8_String S8_Make(char *str, int64_t len);
S8_API S8_String S8_Copy(S8_Allocator allocator, S8_String string);
S8_API void S8_NormalizePath(S8_String s);
S8_API S8_String S8_NormalizePath(S8_Allocator allocator, S8_String s);
S8_API void S8_NormalizePathUnsafe(S8_String s); // make sure there is no way string is const etc.
S8_API S8_String S8_Chop(S8_String string, int64_t len);
S8_API S8_String S8_Skip(S8_String string, int64_t len);
S8_API S8_String S8_GetPostfix(S8_String string, int64_t len);