mirror of
https://github.com/Ed94/refactor.git
synced 2024-09-20 04:37:33 -07:00
Ed_
231c893c6b
For include and multi-file support. I still need to debug it, Test will be adjusted as well; I want to get all the files not just zpl refactored using a powershell script. I dropped the idea of semantically identifiying macros. While it may be possible, I don't see the utility vs the regular idendentifier distinction. I want to keep the refactoring as simple as possible, where it just takes one pass to go through a file without any context to other files. So far the ignores behave as a good guard filter for unwanted refactors and the only true weak area was the includes (which should be aleviated with the coming support for it.
74 lines
986 B
C++
74 lines
986 B
C++
#pragma once
|
|
#include "Bloat.hpp"
|
|
|
|
|
|
namespace Spec
|
|
{
|
|
enum Tok
|
|
{
|
|
Not,
|
|
Include,
|
|
Namespace,
|
|
Word,
|
|
|
|
Num_Tok
|
|
};
|
|
|
|
forceinline
|
|
char const* str_tok( Tok tok )
|
|
{
|
|
static
|
|
char const* tok_to_str[ Tok::Num_Tok ] =
|
|
{
|
|
"not",
|
|
"include",
|
|
"namespace",
|
|
"word",
|
|
};
|
|
|
|
return tok_to_str[ tok ];
|
|
}
|
|
|
|
forceinline
|
|
char strlen_tok( Tok tok )
|
|
{
|
|
static
|
|
const u8 tok_to_len[ Tok::Num_Tok ] =
|
|
{
|
|
3,
|
|
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();
|
|
}
|