mirror of
https://github.com/Ed94/refactor.git
synced 2024-11-10 04:14:53 -08:00
Ed_
87c939e2b6
Not sure yet if include renames work just yet (need to test) Comment signatures are currently hardcoded for C/C++.
77 lines
1018 B
C++
77 lines
1018 B
C++
#pragma once
|
|
#include "Bloat.hpp"
|
|
|
|
|
|
namespace Spec
|
|
{
|
|
enum Tok
|
|
{
|
|
Not,
|
|
Comment,
|
|
Include,
|
|
Namespace,
|
|
Word,
|
|
|
|
Num_Tok
|
|
};
|
|
|
|
forceinline
|
|
char const* str_tok( Tok tok )
|
|
{
|
|
static
|
|
char const* tok_to_str[ Tok::Num_Tok ] =
|
|
{
|
|
"not",
|
|
"comments",
|
|
"include",
|
|
"namespace",
|
|
"word",
|
|
};
|
|
|
|
return tok_to_str[ tok ];
|
|
}
|
|
|
|
forceinline
|
|
char strlen_tok( Tok tok )
|
|
{
|
|
static
|
|
const u8 tok_to_len[ Tok::Num_Tok ] =
|
|
{
|
|
3,
|
|
8,
|
|
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();
|
|
}
|