mirror of
https://github.com/Ed94/gencpp.git
synced 2024-12-22 15:54:45 -08:00
builder compiles in c (some issues with filtering out preprocess #if)
This commit is contained in:
parent
0ccffe3f80
commit
a4143b537d
@ -1067,6 +1067,64 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodeBody parsed_header_builder = parse_file( project_dir "auxillary/builder.hpp" );
|
||||||
|
CodeBody header_builder = def_body(CT_Global_Body);
|
||||||
|
for ( Code entry = parsed_header_builder.begin(); entry != parsed_header_builder.end(); ++ entry ) switch( entry->Type )
|
||||||
|
{
|
||||||
|
case CT_Preprocess_IfDef:
|
||||||
|
{
|
||||||
|
b32 found = ignore_preprocess_cond_block(txt("GEN_INTELLISENSE_DIRECTIVES"), entry, parsed_header_builder, header_builder );
|
||||||
|
if (found) break;
|
||||||
|
|
||||||
|
header_builder.append(entry);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CT_Preprocess_If:
|
||||||
|
{
|
||||||
|
b32 found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP"), entry, parsed_header_builder, header_builder );
|
||||||
|
if (found) break;
|
||||||
|
|
||||||
|
found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP"), entry, parsed_header_builder, header_builder );
|
||||||
|
if (found) break;
|
||||||
|
|
||||||
|
header_builder.append(entry);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CT_Struct:
|
||||||
|
{
|
||||||
|
CodeBody body = cast(CodeBody, entry->Body);
|
||||||
|
CodeBody new_body = def_body(CT_Struct_Body);
|
||||||
|
for ( Code body_entry = body.begin(); body.end(); ++ body_entry ) switch(body_entry->Type)
|
||||||
|
{
|
||||||
|
case CT_Preprocess_If:
|
||||||
|
{
|
||||||
|
b32 found = ignore_preprocess_cond_block(txt("GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP"), body_entry, body, new_body );
|
||||||
|
if (found) break;
|
||||||
|
|
||||||
|
new_body.append(body_entry);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
new_body.append(body_entry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( new_body->NumEntries > 0 ) {
|
||||||
|
entry->Body = new_body;
|
||||||
|
}
|
||||||
|
|
||||||
|
header_builder.append(entry);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
header_builder.append(entry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
s32 idx = 0;
|
s32 idx = 0;
|
||||||
CodeBody parsed_header_end = parse_file( project_dir "components/header_end.hpp" );
|
CodeBody parsed_header_end = parse_file( project_dir "components/header_end.hpp" );
|
||||||
CodeBody header_end = def_body(CT_Global_Body);
|
CodeBody header_end = def_body(CT_Global_Body);
|
||||||
@ -1217,8 +1275,6 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CodeBody hashtable_strc = gen_hashtable(txt("StrC"), txt("HashTable_StrC"));
|
|
||||||
|
|
||||||
CodeBody parsed_src_lexer = parse_file( project_dir "components/lexer.cpp" );
|
CodeBody parsed_src_lexer = parse_file( project_dir "components/lexer.cpp" );
|
||||||
CodeBody src_lexer = def_body(CT_Global_Body);
|
CodeBody src_lexer = def_body(CT_Global_Body);
|
||||||
for ( Code entry = parsed_src_lexer.begin(); entry != parsed_src_lexer.end(); ++ entry ) switch( entry ->Type )
|
for ( Code entry = parsed_src_lexer.begin(); entry != parsed_src_lexer.end(); ++ entry ) switch( entry ->Type )
|
||||||
@ -1448,6 +1504,10 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
|
|
||||||
header.print( format_code_to_untyped(header_end) );
|
header.print( format_code_to_untyped(header_end) );
|
||||||
|
|
||||||
|
header.print_fmt( "\n#pragma region Builder\n" );
|
||||||
|
header.print( format_code_to_untyped(header_builder) );
|
||||||
|
header.print_fmt( "#pragma endregion Builder\n" );
|
||||||
|
|
||||||
header.print_fmt( "\nGEN_API_C_END\n" );
|
header.print_fmt( "\nGEN_API_C_END\n" );
|
||||||
|
|
||||||
header.print_fmt( "GEN_NS_END\n\n" );
|
header.print_fmt( "GEN_NS_END\n\n" );
|
||||||
@ -1461,6 +1521,7 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
#pragma region Print Dependencies
|
#pragma region Print Dependencies
|
||||||
header.print_fmt( roll_own_dependencies_guard_start );
|
header.print_fmt( roll_own_dependencies_guard_start );
|
||||||
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
||||||
|
header.print_fmt( "GEN_API_C_BEGIN\n\n" );
|
||||||
|
|
||||||
header.print( src_impl_start );
|
header.print( src_impl_start );
|
||||||
header.print( src_debug );
|
header.print( src_debug );
|
||||||
@ -1513,13 +1574,15 @@ R"(#define <interface_name>( code ) _Generic( (code), \
|
|||||||
header.print( src_untyped );
|
header.print( src_untyped );
|
||||||
header.print_fmt( "\n#pragma endregion Interface\n\n");
|
header.print_fmt( "\n#pragma endregion Interface\n\n");
|
||||||
|
|
||||||
// header.print_fmt( "#pragma region Builder\n" );
|
header.print_fmt( "#pragma region Builder\n" );
|
||||||
// header.print( scan_file( project_dir "auxillary/builder.cpp" ) );
|
header.print( scan_file( project_dir "auxillary/builder.cpp" ) );
|
||||||
// header.print_fmt( "\n#pragma endregion Builder\n\n" );
|
header.print_fmt( "\n#pragma endregion Builder\n\n" );
|
||||||
|
|
||||||
// header.print_fmt( "\n#pragma region Scanner\n" );
|
// header.print_fmt( "\n#pragma region Scanner\n" );
|
||||||
// header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
|
// header.print( scan_file( project_dir "auxillary/scanner.hpp" ) );
|
||||||
// header.print_fmt( "#pragma endregion Scanner\n\n" );
|
// header.print_fmt( "#pragma endregion Scanner\n\n" );
|
||||||
|
|
||||||
|
header.print_fmt( "\nGEN_API_C_END\n" );
|
||||||
#pragma endregion Print Components
|
#pragma endregion Print Components
|
||||||
|
|
||||||
header.print_fmt( implementation_guard_end );
|
header.print_fmt( implementation_guard_end );
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# include "builder.hpp"
|
# include "builder.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Builder Builder::open( char const* path )
|
Builder builder_open( char const* path )
|
||||||
{
|
{
|
||||||
Builder result;
|
Builder result;
|
||||||
|
|
||||||
@ -19,41 +19,38 @@ Builder Builder::open( char const* path )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Builder::pad_lines( s32 num )
|
void builder_pad_lines( Builder* builder, s32 num )
|
||||||
{
|
{
|
||||||
string_append_strc( & Buffer, txt("\n") );
|
string_append_strc( & builder->Buffer, txt("\n") );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Builder::print( Code code )
|
void builder_print( Builder* builder, Code code )
|
||||||
{
|
{
|
||||||
String str = code_to_string(code);
|
String str = code_to_string(code);
|
||||||
// const ssize len = str.length();
|
// const ssize len = str.length();
|
||||||
// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data );
|
// log_fmt( "%s - print: %.*s\n", File.filename, len > 80 ? 80 : len, str.Data );
|
||||||
string_append_string( & Buffer, str );
|
string_append_string( & builder->Buffer, str );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Builder::print_fmt( char const* fmt, ... )
|
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va )
|
||||||
{
|
{
|
||||||
ssize res;
|
ssize res;
|
||||||
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
char buf[ GEN_PRINTF_MAXLEN ] = { 0 };
|
||||||
|
|
||||||
va_list va;
|
|
||||||
va_start( va, fmt );
|
|
||||||
res = str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1;
|
res = str_fmt_va( buf, count_of( buf ) - 1, fmt, va ) - 1;
|
||||||
va_end( va );
|
|
||||||
|
|
||||||
// log_fmt( "$%s - print_fmt: %.*s\n", File.filename, res > 80 ? 80 : res, buf );
|
string_append_c_str_len( (String*) & builder->Buffer, (char const*)buf, res);
|
||||||
string_append_c_str_len( (String*) & Buffer, (char const*)buf, res);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Builder::write()
|
void builder_write(Builder* builder)
|
||||||
{
|
{
|
||||||
b32 result = file_write( & File, Buffer, string_length(Buffer) );
|
b32 result = file_write( & builder->File, builder->Buffer, string_length(builder->Buffer) );
|
||||||
|
|
||||||
if ( result == false )
|
if ( result == false )
|
||||||
log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & File ) );
|
log_failure("gen::File::write - Failed to write to file: %s\n", file_name( & builder->File ) );
|
||||||
|
|
||||||
log_fmt( "Generated: %s\n", File.filename );
|
log_fmt( "Generated: %s\n", builder->File.filename );
|
||||||
file_close( & File );
|
file_close( & builder->File );
|
||||||
string_free(& Buffer);
|
string_free(& builder->Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,18 +3,48 @@
|
|||||||
# include "gen.hpp"
|
# include "gen.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct Builder;
|
||||||
|
typedef struct Builder Builder;
|
||||||
|
|
||||||
|
Builder builder_open ( char const* path );
|
||||||
|
void builder_pad_lines ( Builder* builder, s32 num );
|
||||||
|
void builder_print ( Builder* builder, Code code );
|
||||||
|
void builder_print_fmt_va( Builder* builder, char const* fmt, va_list va );
|
||||||
|
void builder_print_fmt ( Builder* builder, char const* fmt, ... ) {
|
||||||
|
va_list va;
|
||||||
|
va_start( va, fmt );
|
||||||
|
builder_print_fmt_va( builder, fmt, va );
|
||||||
|
va_end( va );
|
||||||
|
}
|
||||||
|
void builder_write( Builder* builder );
|
||||||
|
|
||||||
struct Builder
|
struct Builder
|
||||||
{
|
{
|
||||||
FileInfo File;
|
FileInfo File;
|
||||||
String Buffer;
|
String Buffer;
|
||||||
|
|
||||||
static Builder open( char const* path );
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
|
forceinline static Builder open( char const* path ) { return builder_open(path); }
|
||||||
|
|
||||||
void pad_lines( s32 num );
|
forceinline void pad_lines( s32 num ) { return builder_pad_lines(this, num); }
|
||||||
|
|
||||||
void print( Code );
|
forceinline void print( Code code ) { return builder_print(this, code); }
|
||||||
void print_fmt( char const* fmt, ... );
|
forceinline void print_fmt( char const* fmt, ... ) {
|
||||||
|
|
||||||
void write();
|
}
|
||||||
|
|
||||||
|
forceinline void write() { return builder_write(this); }
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKE_CPP
|
||||||
|
void builder_pad_lines( Builder& builder, s32 num ) { return builder_pad_lines(& builder, num); }
|
||||||
|
void builder_print ( Builder& builder, Code code ) { return builder_print(& builder, code); }
|
||||||
|
void builder_write ( Builder& builder ) { return builder_write(& builder ); }
|
||||||
|
void builder_print_fmt( Builder& builder, char const* fmt, ...) {
|
||||||
|
va_list va;
|
||||||
|
va_start( va, fmt );
|
||||||
|
builder_print_fmt_va( & builder, fmt, va );
|
||||||
|
va_end( va );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
||||||
#define GEN_EXPOSE_BACKEND
|
#define GEN_EXPOSE_BACKEND
|
||||||
#define GEN_C_LIKE_CPP 1
|
#define GEN_C_LIKE_CPP 1
|
||||||
#include "gen.cpp"
|
#include "../project/gen.cpp"
|
||||||
|
|
||||||
#include "helpers/push_ignores.inline.hpp"
|
#include "helpers/push_ignores.inline.hpp"
|
||||||
#include "helpers/helper.hpp"
|
#include "helpers/helper.hpp"
|
||||||
@ -52,9 +52,9 @@ void format_file( char const* path )
|
|||||||
|
|
||||||
Code dump_to_scratch_and_retireve( Code code )
|
Code dump_to_scratch_and_retireve( Code code )
|
||||||
{
|
{
|
||||||
Builder ecode_file_temp = Builder::open("gen/scratch.hpp");
|
Builder ecode_file_temp = builder_open("gen/scratch.hpp");
|
||||||
ecode_file_temp.print(code);
|
builder_print( & ecode_file_temp, code);
|
||||||
ecode_file_temp.write();
|
builder_write(& ecode_file_temp);
|
||||||
format_file("gen/scratch.hpp");
|
format_file("gen/scratch.hpp");
|
||||||
Code result = scan_file( "gen/scratch.hpp" );
|
Code result = scan_file( "gen/scratch.hpp" );
|
||||||
remove("gen/scratch.hpp");
|
remove("gen/scratch.hpp");
|
||||||
@ -85,27 +85,27 @@ int gen_main()
|
|||||||
Code filesystem = scan_file( "dependencies/filesystem.hpp" );
|
Code filesystem = scan_file( "dependencies/filesystem.hpp" );
|
||||||
Code timing = scan_file( "dependencies/timing.hpp" );
|
Code timing = scan_file( "dependencies/timing.hpp" );
|
||||||
|
|
||||||
Builder
|
Builder _header = builder_open("gen/gen.dep.hpp");
|
||||||
header = Builder::open("gen/gen.dep.hpp");
|
Builder* header = & _header;
|
||||||
header.print_fmt( generation_notice );
|
builder_print_fmt( header, generation_notice );
|
||||||
header.print_fmt( "// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)\n" );
|
builder_print_fmt( header, "// This file is intended to be included within gen.hpp (There is no pragma diagnostic ignores)\n" );
|
||||||
header.print( platform );
|
builder_print( header, platform );
|
||||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
builder_print_fmt( header, "\nGEN_NS_BEGIN\n" );
|
||||||
|
|
||||||
header.print( macros );
|
builder_print( header, macros );
|
||||||
header.print( basic_types );
|
builder_print( header, basic_types );
|
||||||
header.print( debug );
|
builder_print( header, debug );
|
||||||
header.print( memory );
|
builder_print( header, memory );
|
||||||
header.print( string_ops );
|
builder_print( header, string_ops );
|
||||||
header.print( printing );
|
builder_print( header, printing );
|
||||||
header.print( containers );
|
builder_print( header, containers );
|
||||||
header.print( hashing );
|
builder_print( header, hashing );
|
||||||
header.print( strings );
|
builder_print( header, strings );
|
||||||
header.print( filesystem );
|
builder_print( header, filesystem );
|
||||||
header.print( timing );
|
builder_print( header, timing );
|
||||||
|
|
||||||
header.print_fmt( "\nGEN_NS_END\n" );
|
builder_print_fmt( header, "\nGEN_NS_END\n" );
|
||||||
header.write();
|
builder_write(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen_dep.cpp
|
// gen_dep.cpp
|
||||||
@ -120,24 +120,24 @@ int gen_main()
|
|||||||
Code filesystem = scan_file( "dependencies/filesystem.cpp" );
|
Code filesystem = scan_file( "dependencies/filesystem.cpp" );
|
||||||
Code timing = scan_file( "dependencies/timing.cpp" );
|
Code timing = scan_file( "dependencies/timing.cpp" );
|
||||||
|
|
||||||
Builder
|
Builder _src = builder_open( "gen/gen.dep.cpp" );
|
||||||
src = Builder::open( "gen/gen.dep.cpp" );
|
Builder* src = & _src;
|
||||||
src.print_fmt( generation_notice );
|
builder_print_fmt(src, generation_notice );
|
||||||
src.print_fmt( "// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n" );
|
builder_print_fmt( src, "// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n" );
|
||||||
src.print( src_start );
|
builder_print( src, src_start );
|
||||||
src.print_fmt( "\nGEN_NS_BEGIN\n" );
|
builder_print_fmt( src, "\nGEN_NS_BEGIN\n" );
|
||||||
|
|
||||||
src.print( debug );
|
builder_print( src, debug );
|
||||||
src.print( string_ops );
|
builder_print( src, string_ops );
|
||||||
src.print( printing );
|
builder_print( src, printing );
|
||||||
src.print( hashing );
|
builder_print( src, hashing );
|
||||||
src.print( memory );
|
builder_print( src, memory );
|
||||||
src.print( strings );
|
builder_print( src, strings );
|
||||||
src.print( filesystem );
|
builder_print( src, filesystem );
|
||||||
src.print( timing );
|
builder_print( src, timing );
|
||||||
|
|
||||||
src.print_fmt( "\nGEN_NS_END\n" );
|
builder_print_fmt( src, "\nGEN_NS_END\n" );
|
||||||
src.write();
|
builder_write(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeBody gen_component_header = def_global_body( args(
|
CodeBody gen_component_header = def_global_body( args(
|
||||||
@ -165,68 +165,64 @@ int gen_main()
|
|||||||
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
|
CodeBody especifier = gen_especifier( "enums/ESpecifier.csv" );
|
||||||
CodeBody ast_inlines = gen_ast_inlines();
|
CodeBody ast_inlines = gen_ast_inlines();
|
||||||
|
|
||||||
Builder
|
Builder _header = builder_open( "gen/gen.hpp" );
|
||||||
header = Builder::open( "gen/gen.hpp" );
|
Builder* header = & _header;
|
||||||
header.print_fmt( generation_notice );
|
builder_print_fmt( header, generation_notice );
|
||||||
header.print_fmt( "#pragma once\n\n" );
|
builder_print_fmt( header, "#pragma once\n\n" );
|
||||||
header.print( push_ignores );
|
builder_print( header, push_ignores );
|
||||||
header.print( header_start );
|
builder_print( header, header_start );
|
||||||
header.print_fmt( "\nGEN_NS_BEGIN\n\n" );
|
builder_print_fmt( header, "\nGEN_NS_BEGIN\n\n" );
|
||||||
|
|
||||||
header.print_fmt( "#pragma region Types\n" );
|
builder_print_fmt(header, "#pragma region Types\n" );
|
||||||
header.print( types );
|
builder_print( header, types );
|
||||||
header.print( fmt_newline);
|
builder_print( header, fmt_newline);
|
||||||
header.print( dump_to_scratch_and_retireve(ecode) );
|
builder_print( header, dump_to_scratch_and_retireve(ecode) );
|
||||||
header.print( fmt_newline);
|
builder_print( header, fmt_newline);
|
||||||
header.print( dump_to_scratch_and_retireve(eoperator) );
|
builder_print( header, dump_to_scratch_and_retireve(eoperator) );
|
||||||
header.print( fmt_newline);
|
builder_print( header, fmt_newline);
|
||||||
header.print( dump_to_scratch_and_retireve(especifier) );
|
builder_print( header, dump_to_scratch_and_retireve(especifier) );
|
||||||
header.print( fmt_newline);
|
builder_print( header, fmt_newline);
|
||||||
header.print_fmt( "#pragma endregion Types\n\n" );
|
builder_print_fmt( header, "#pragma endregion Types\n\n" );
|
||||||
|
|
||||||
header.print_fmt( "#pragma region AST\n" );
|
builder_print_fmt( header, "#pragma region AST\n" );
|
||||||
header.print( ast );
|
builder_print( header, ast );
|
||||||
header.print( code_types );
|
builder_print( header, code_types );
|
||||||
header.print( ast_types );
|
builder_print( header, ast_types );
|
||||||
header.print_fmt( "\n#pragma endregion AST\n" );
|
builder_print_fmt( header, "\n#pragma endregion AST\n" );
|
||||||
|
|
||||||
header.print( interface );
|
builder_print( header, interface );
|
||||||
|
|
||||||
header.print_fmt( "\n#pragma region Inlines\n" );
|
builder_print_fmt( header, "\n#pragma region Inlines\n" );
|
||||||
header.print( inlines );
|
builder_print( header, inlines );
|
||||||
header.print( fmt_newline );
|
builder_print( header, fmt_newline );
|
||||||
header.print( dump_to_scratch_and_retireve(ast_inlines) );
|
builder_print( header, dump_to_scratch_and_retireve(ast_inlines) );
|
||||||
header.print( fmt_newline );
|
builder_print( header, fmt_newline );
|
||||||
header.print_fmt( "#pragma endregion Inlines\n" );
|
builder_print_fmt( header, "#pragma endregion Inlines\n" );
|
||||||
|
|
||||||
header.print( header_end );
|
builder_print( header, header_end );
|
||||||
header.print_fmt( "GEN_NS_END\n\n" );
|
builder_print_fmt( header, "GEN_NS_END\n\n" );
|
||||||
header.print( pop_ignores );
|
builder_print( header, pop_ignores );
|
||||||
header.write();
|
builder_write(header);
|
||||||
|
|
||||||
Builder
|
Builder header_ecode = builder_open( "components/gen/ecode.hpp" );
|
||||||
header_ecode = Builder::open( "components/gen/ecode.hpp" );
|
builder_print( & header_ecode, gen_component_header );
|
||||||
header_ecode.print( gen_component_header );
|
builder_print( & header_ecode, ecode );
|
||||||
header_ecode.print( ecode );
|
builder_write( & header_ecode);
|
||||||
header_ecode.write();
|
|
||||||
|
|
||||||
Builder
|
Builder header_eoperator = builder_open( "components/gen/eoperator.hpp" );
|
||||||
header_eoperator = Builder::open( "components/gen/eoperator.hpp" );
|
builder_print( & header_eoperator, gen_component_header );
|
||||||
header_eoperator.print( gen_component_header );
|
builder_print( & header_eoperator, eoperator );
|
||||||
header_eoperator.print( eoperator );
|
builder_write( & header_eoperator );
|
||||||
header_eoperator.write();
|
|
||||||
|
|
||||||
Builder
|
Builder header_especifier = builder_open( "components/gen/especifier.hpp" );
|
||||||
header_especifier = Builder::open( "components/gen/especifier.hpp" );
|
builder_print( & header_especifier, gen_component_header );
|
||||||
header_especifier.print( gen_component_header );
|
builder_print( & header_especifier, especifier );
|
||||||
header_especifier.print( especifier );
|
builder_write( & header_especifier);
|
||||||
header_especifier.write();
|
|
||||||
|
|
||||||
Builder
|
Builder header_ast_inlines = builder_open( "components/gen/ast_inlines.hpp" );
|
||||||
header_ast_inlines = Builder::open( "components/gen/ast_inlines.hpp" );
|
builder_print( & header_ast_inlines, gen_component_header );
|
||||||
header_ast_inlines.print( gen_component_header );
|
builder_print( & header_ast_inlines, ast_inlines );
|
||||||
header_ast_inlines.print( ast_inlines );
|
builder_write( & header_ast_inlines);
|
||||||
header_ast_inlines.write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen.cpp
|
// gen.cpp
|
||||||
@ -249,88 +245,84 @@ int gen_main()
|
|||||||
etoktype
|
etoktype
|
||||||
));
|
));
|
||||||
|
|
||||||
Builder
|
Builder _src = builder_open( "gen/gen.cpp" );
|
||||||
src = Builder::open( "gen/gen.cpp" );
|
Builder* src = & _src;
|
||||||
src.print_fmt( generation_notice );
|
builder_print_fmt( src, generation_notice );
|
||||||
src.print( push_ignores );
|
builder_print( src, push_ignores );
|
||||||
src.print( src_start );
|
builder_print( src, src_start );
|
||||||
src.print_fmt( "\nGEN_NS_BEGIN\n");
|
builder_print_fmt( src, "\nGEN_NS_BEGIN\n");
|
||||||
|
|
||||||
src.print( static_data );
|
builder_print( src, static_data );
|
||||||
|
|
||||||
src.print_fmt( "\n#pragma region AST\n\n" );
|
builder_print_fmt( src, "\n#pragma region AST\n\n" );
|
||||||
src.print( ast_case_macros );
|
builder_print( src, ast_case_macros );
|
||||||
src.print( ast );
|
builder_print( src, ast );
|
||||||
src.print( code_serialization );
|
builder_print( src, code_serialization );
|
||||||
src.print_fmt( "\n#pragma endregion AST\n" );
|
builder_print_fmt( src, "\n#pragma endregion AST\n" );
|
||||||
|
|
||||||
src.print_fmt( "\n#pragma region Interface\n" );
|
builder_print_fmt( src, "\n#pragma region Interface\n" );
|
||||||
src.print( interface );
|
builder_print( src, interface );
|
||||||
src.print( upfront );
|
builder_print( src, upfront );
|
||||||
src.print_fmt( "\n#pragma region Parsing\n\n" );
|
builder_print_fmt( src, "\n#pragma region Parsing\n\n" );
|
||||||
src.print( dump_to_scratch_and_retireve(nspaced_etoktype) );
|
builder_print( src, dump_to_scratch_and_retireve(nspaced_etoktype) );
|
||||||
src.print( lexer );
|
builder_print( src, lexer );
|
||||||
src.print( parser );
|
builder_print( src, parser );
|
||||||
src.print( parsing_interface );
|
builder_print( src, parsing_interface );
|
||||||
src.print( untyped );
|
builder_print( src, untyped );
|
||||||
src.print_fmt( "\n#pragma endregion Parsing\n\n" );
|
builder_print_fmt( src, "\n#pragma endregion Parsing\n\n" );
|
||||||
src.print_fmt( "#pragma endregion Interface\n\n" );
|
builder_print_fmt( src, "#pragma endregion Interface\n\n" );
|
||||||
|
|
||||||
src.print_fmt( "GEN_NS_END\n\n");
|
builder_print_fmt( src, "GEN_NS_END\n\n");
|
||||||
src.print( pop_ignores );
|
builder_print( src, pop_ignores );
|
||||||
src.write();
|
builder_write(src);
|
||||||
|
|
||||||
Builder
|
Builder src_etoktype = builder_open( "components/gen/etoktype.cpp" );
|
||||||
src_etoktype = Builder::open( "components/gen/etoktype.cpp" );
|
builder_print( & src_etoktype, gen_component_header );
|
||||||
src_etoktype.print( gen_component_header );
|
builder_print( & src_etoktype, nspaced_etoktype );
|
||||||
src_etoktype.print( nspaced_etoktype );
|
builder_write( & src_etoktype);
|
||||||
src_etoktype.write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen_builder.hpp
|
// gen_builder.hpp
|
||||||
{
|
{
|
||||||
Code builder = scan_file( "auxillary/builder.hpp" );
|
Code builder = scan_file( "auxillary/builder.hpp" );
|
||||||
|
|
||||||
Builder
|
Builder header = builder_open( "gen/gen.builder.hpp" );
|
||||||
header = Builder::open( "gen/gen.builder.hpp" );
|
builder_print_fmt( & header, generation_notice );
|
||||||
header.print_fmt( generation_notice );
|
builder_print_fmt( & header, "#pragma once\n\n" );
|
||||||
header.print_fmt( "#pragma once\n\n" );
|
builder_print( & header, def_include( txt("gen.hpp") ));
|
||||||
header.print( def_include( txt("gen.hpp") ));
|
builder_print_fmt( & header, "\nGEN_NS_BEGIN\n" );
|
||||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
builder_print( & header, builder );
|
||||||
header.print( builder );
|
builder_print_fmt( & header, "GEN_NS_END\n" );
|
||||||
header.print_fmt( "GEN_NS_END\n" );
|
builder_write( & header);
|
||||||
header.write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen_builder.cpp
|
// gen_builder.cpp
|
||||||
{
|
|
||||||
Code builder = scan_file( "auxillary/builder.cpp" );
|
Code builder = scan_file( "auxillary/builder.cpp" );
|
||||||
|
|
||||||
Builder
|
Builder src = builder_open( "gen/gen.builder.cpp" );
|
||||||
src = Builder::open( "gen/gen.builder.cpp" );
|
builder_print_fmt( & src, generation_notice );
|
||||||
src.print_fmt( generation_notice );
|
builder_print( & src, def_include( txt("gen.builder.hpp") ) );
|
||||||
src.print( def_include( txt("gen.builder.hpp") ) );
|
builder_print_fmt( & src, "\nGEN_NS_BEGIN\n" );
|
||||||
src.print_fmt( "\nGEN_NS_BEGIN\n" );
|
builder_print( & src, builder );
|
||||||
src.print( builder );
|
builder_print_fmt( & src, "\nGEN_NS_END\n" );
|
||||||
src.print_fmt( "\nGEN_NS_END\n" );
|
builder_write( & src);
|
||||||
src.write();
|
|
||||||
}
|
|
||||||
|
|
||||||
// gen_scanner.hpp
|
// gen_scanner.hpp
|
||||||
{
|
{
|
||||||
Code parsing = scan_file( "dependencies/parsing.hpp" );
|
Code parsing = scan_file( "dependencies/parsing.hpp" );
|
||||||
Code scanner = scan_file( "auxillary/scanner.hpp" );
|
Code scanner = scan_file( "auxillary/scanner.hpp" );
|
||||||
|
|
||||||
Builder
|
Builder header = builder_open( "gen/gen.scanner.hpp" );
|
||||||
header = Builder::open( "gen/gen.scanner.hpp" );
|
builder_print_fmt( & header, generation_notice );
|
||||||
header.print_fmt( generation_notice );
|
builder_print_fmt( & header, "#pragma once\n\n" );
|
||||||
header.print_fmt( "#pragma once\n\n" );
|
builder_print( & header, def_include( txt("gen.hpp") ) );
|
||||||
header.print( def_include( txt("gen.hpp") ) );
|
builder_print_fmt( & header, "\nGEN_NS_BEGIN\n" );
|
||||||
header.print_fmt( "\nGEN_NS_BEGIN\n" );
|
builder_print( & header, parsing );
|
||||||
header.print( parsing );
|
builder_print( & header, scanner );
|
||||||
header.print( scanner );
|
builder_print_fmt( & header, "\nGEN_NS_END\n" );
|
||||||
header.print_fmt( "\nGEN_NS_END\n" );
|
builder_write(& header);
|
||||||
header.write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gen_scanner.cpp
|
// gen_scanner.cpp
|
||||||
@ -338,15 +330,14 @@ int gen_main()
|
|||||||
Code parsing = scan_file( "dependencies/parsing.cpp" );
|
Code parsing = scan_file( "dependencies/parsing.cpp" );
|
||||||
Code scanner = scan_file( "auxillary/scanner.cpp" );
|
Code scanner = scan_file( "auxillary/scanner.cpp" );
|
||||||
|
|
||||||
Builder
|
Builder src = builder_open( "gen/gen.scanner.cpp" );
|
||||||
src = Builder::open( "gen/gen.scanner.cpp" );
|
builder_print_fmt( & src, generation_notice );
|
||||||
src.print_fmt( generation_notice );
|
builder_print( & src, def_include( txt("gen.scanner.hpp") ) );
|
||||||
src.print( def_include( txt("gen.scanner.hpp") ) );
|
builder_print_fmt( & src, "\nGEN_NS_BEGIN\n" );
|
||||||
src.print_fmt( "\nGEN_NS_BEGIN\n" );
|
builder_print( & src, parsing );
|
||||||
src.print( parsing );
|
builder_print( & src, scanner );
|
||||||
// src.print( scanner );
|
builder_print_fmt( & src, "GEN_NS_END\n" );
|
||||||
src.print_fmt( "GEN_NS_END\n" );
|
builder_write( & src);
|
||||||
src.write();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gen::deinit();
|
gen::deinit();
|
||||||
|
@ -215,7 +215,7 @@ struct Arena
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if GEN_COMPILER_CPP
|
#if GEN_COMPILER_CPP && ! GEN_C_LIKECPP
|
||||||
forceinline AllocatorInfo allocator_info(Arena& arena ) { return arena_allocator_info(& arena); }
|
forceinline AllocatorInfo allocator_info(Arena& arena ) { return arena_allocator_info(& arena); }
|
||||||
forceinline Arena init_sub (Arena& parent, ssize size) { return arena_init_sub( & parent, size); }
|
forceinline Arena init_sub (Arena& parent, ssize size) { return arena_init_sub( & parent, size); }
|
||||||
forceinline ssize alignment_of (Arena& arena, ssize alignment) { return arena_alignment_of( & arena, alignment); }
|
forceinline ssize alignment_of (Arena& arena, ssize alignment) { return arena_alignment_of( & arena, alignment); }
|
||||||
|
Loading…
Reference in New Issue
Block a user