mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-14 18:51:47 -07:00
c_library compiles
This commit is contained in:
@ -116,4 +116,33 @@ Code scan_file( char const* path )
|
||||
return untyped_str( string_to_strc(str) );
|
||||
}
|
||||
|
||||
CodeBody parse_file( const char* path ) {
|
||||
FileContents file = file_read_contents( GlobalAllocator, true, path );
|
||||
StrC content = { file.size, (char const*)file.data };
|
||||
CodeBody code = parse_global_body( content );
|
||||
log_fmt("\nParsed: %s\n", path);
|
||||
return code;
|
||||
}
|
||||
|
||||
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path) {
|
||||
FileContents content = file_read_contents( allocator, file_zero_terminate, path );
|
||||
Arena csv_arena = arena_init_from_memory(content.data, content.size);
|
||||
|
||||
CSV_Column result;
|
||||
csv_parse( & result.ADT, rcast(char*, content.data), allocator, false );
|
||||
result.Content = result.ADT.nodes[0].nodes;
|
||||
return result;
|
||||
}
|
||||
|
||||
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path) {
|
||||
FileContents content = file_read_contents( allocator, file_zero_terminate, path );
|
||||
Arena csv_arena = arena_init_from_memory(content.data, content.size);
|
||||
|
||||
CSV_Columns2 result;
|
||||
csv_parse( & result.ADT, rcast(char*, content.data), allocator, false );
|
||||
result.Col_1 = result.ADT.nodes[0].nodes;
|
||||
result.Col_2 = result.ADT.nodes[1].nodes;
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma endregion Scanner
|
||||
|
@ -22,14 +22,7 @@
|
||||
// This is done so that includes can be kept in dependency and component files so that intellisense works.
|
||||
Code scan_file( char const* path );
|
||||
|
||||
inline
|
||||
CodeBody parse_file( const char* path )
|
||||
{
|
||||
FileContents file = file_read_contents( GlobalAllocator, true, path );
|
||||
CodeBody code = parse_global_body( { file.size, (char const*)file.data } );
|
||||
log_fmt("\nParsed: %s\n", path);
|
||||
return code;
|
||||
}
|
||||
CodeBody parse_file( const char* path );
|
||||
|
||||
// The follow is basic support for light csv parsing (use it as an example)
|
||||
// Make something robust if its more serious.
|
||||
@ -37,37 +30,17 @@ CodeBody parse_file( const char* path )
|
||||
typedef struct CSV_Column CSV_Column;
|
||||
struct CSV_Column {
|
||||
CSV_Object ADT;
|
||||
Array<ADT_Node> Content;
|
||||
Array(ADT_Node) Content;
|
||||
};
|
||||
|
||||
typedef struct CSV_Columns2 CSV_Columns2;
|
||||
struct CSV_Columns2 {
|
||||
CSV_Object ADT;
|
||||
Array<ADT_Node> Col_1;
|
||||
Array<ADT_Node> Col_2;
|
||||
Array(ADT_Node) Col_1;
|
||||
Array(ADT_Node) Col_2;
|
||||
};
|
||||
|
||||
inline
|
||||
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path) {
|
||||
FileContents content = file_read_contents( allocator, file_zero_terminate, path );
|
||||
Arena csv_arena = arena_init_from_memory(content.data, content.size);
|
||||
|
||||
CSV_Column result;
|
||||
csv_parse( & result.ADT, rcast(char*, content.data), allocator, false );
|
||||
result.Content = result.ADT.nodes[0].nodes;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path) {
|
||||
FileContents content = file_read_contents( allocator, file_zero_terminate, path );
|
||||
Arena csv_arena = arena_init_from_memory(content.data, content.size);
|
||||
|
||||
CSV_Columns2 result;
|
||||
csv_parse( & result.ADT, rcast(char*, content.data), allocator, false );
|
||||
result.Col_1 = result.ADT.nodes[0].nodes;
|
||||
result.Col_2 = result.ADT.nodes[1].nodes;
|
||||
return result;
|
||||
}
|
||||
CSV_Column parse_csv_one_column(AllocatorInfo allocator, char const* path);
|
||||
CSV_Columns2 parse_csv_two_columns(AllocatorInfo allocator, char const* path);
|
||||
|
||||
#pragma endregion Scanner
|
||||
|
@ -22,7 +22,6 @@ void clang_format_file( char const* path, char const* style_path )
|
||||
{
|
||||
GEN_ASSERT_NOT_NULL(path);
|
||||
String resolved_path = string_make_strc(GlobalAllocator, to_strc_from_c_str(path));
|
||||
|
||||
String style_arg;
|
||||
if (style_path) {
|
||||
style_arg = string_make_strc(GlobalAllocator, txt("-style=file:"));
|
||||
@ -38,10 +37,7 @@ void clang_format_file( char const* path, char const* style_path )
|
||||
string_append_strc( & command, cf_verbose );
|
||||
string_append_string( & command, style_arg );
|
||||
string_append_string( & command, resolved_path );
|
||||
|
||||
log_fmt("\tRunning clang-format:\n");
|
||||
system( command );
|
||||
log_fmt("\tclang-format finished formatting.\n");
|
||||
}
|
||||
|
||||
// Will refactor a file with the given script at the provided path.
|
||||
@ -53,16 +49,12 @@ void refactor_file( char const* path, char const* refactor_script )
|
||||
GEN_ASSERT_NOT_NULL(refactor_script);
|
||||
|
||||
String command = string_make_strc(GlobalAllocator, txt("refactor "));
|
||||
string_append_strc( & command, txt("-debug ") );
|
||||
// string_append_strc( & command, txt("-debug ") );
|
||||
string_append_strc( & command, txt("-num=1 ") );
|
||||
string_append_fmt( & command, "-src=%s ", path );
|
||||
string_append_fmt( & command,"-spec=%s ", refactor_script );
|
||||
|
||||
log_fmt("\tBeginning refactor:\n");
|
||||
system(command);
|
||||
log_fmt("\nRefactoring complete.\n");
|
||||
|
||||
#undef refactor
|
||||
log_fmt("\n");
|
||||
}
|
||||
|
||||
// Does either of the above or both to the provided code.
|
||||
|
Reference in New Issue
Block a user