2023-03-16 23:09:19 -07:00
|
|
|
#pragma once
|
|
|
|
#include "Bloat.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Spec
|
|
|
|
{
|
2023-07-19 22:03:31 -07:00
|
|
|
enum Tok
|
2023-03-16 23:09:19 -07:00
|
|
|
{
|
|
|
|
Not,
|
2023-03-25 19:44:36 -07:00
|
|
|
Comment,
|
2023-03-16 23:09:19 -07:00
|
|
|
Include,
|
|
|
|
Namespace,
|
|
|
|
Word,
|
|
|
|
|
|
|
|
Num_Tok
|
|
|
|
};
|
|
|
|
|
|
|
|
forceinline
|
|
|
|
char const* str_tok( Tok tok )
|
|
|
|
{
|
|
|
|
static
|
2023-07-19 22:03:31 -07:00
|
|
|
char const* tok_to_str[ Tok::Num_Tok ] =
|
2023-03-16 23:09:19 -07:00
|
|
|
{
|
|
|
|
"not",
|
2023-03-25 19:44:36 -07:00
|
|
|
"comments",
|
2023-03-16 23:09:19 -07:00
|
|
|
"include",
|
|
|
|
"namespace",
|
|
|
|
"word",
|
|
|
|
};
|
|
|
|
|
|
|
|
return tok_to_str[ tok ];
|
|
|
|
}
|
|
|
|
|
|
|
|
forceinline
|
|
|
|
char strlen_tok( Tok tok )
|
|
|
|
{
|
|
|
|
static
|
2023-07-19 22:03:31 -07:00
|
|
|
const u8 tok_to_len[ Tok::Num_Tok ] =
|
2023-03-16 23:09:19 -07:00
|
|
|
{
|
|
|
|
3,
|
2023-03-25 19:44:36 -07:00
|
|
|
8,
|
2023-03-16 23:09:19 -07:00
|
|
|
7,
|
|
|
|
9,
|
|
|
|
4,
|
|
|
|
};
|
|
|
|
|
|
|
|
return tok_to_len[ tok ];
|
|
|
|
}
|
|
|
|
|
|
|
|
forceinline
|
|
|
|
bool is_tok( Tok tok, zpl_string str, u32 length )
|
|
|
|
{
|
|
|
|
char const* tok_str = str_tok(tok);
|
|
|
|
const u8 tok_len = strlen_tok(tok);
|
|
|
|
|
|
|
|
if ( tok_len != length)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
s32 result = zpl_strncmp( tok_str, str, tok_len );
|
|
|
|
|
|
|
|
return result == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Entry
|
|
|
|
{
|
|
|
|
zpl_string Sig = nullptr; // Signature
|
|
|
|
zpl_string Sub = nullptr; // Substitute
|
|
|
|
};
|
|
|
|
|
|
|
|
using Array_Entry = zpl_array( Entry );
|
|
|
|
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
// Extract the specificication from the provided file.
|
|
|
|
void parse();
|
|
|
|
}
|