2023-07-24 15:56:15 -07:00
|
|
|
#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS
|
|
|
|
#define GEN_ENFORCE_STRONG_CODE_TYPES
|
|
|
|
#define GEN_EXPOSE_BACKEND
|
|
|
|
#include "gen.cpp"
|
2023-07-24 19:19:21 -07:00
|
|
|
#include "filesystem/gen.scanner.hpp"
|
2023-07-26 11:21:20 -07:00
|
|
|
#include "helpers/gen.helper.hpp"
|
2023-07-24 15:56:15 -07:00
|
|
|
|
|
|
|
using namespace gen;
|
|
|
|
|
2023-07-24 19:19:21 -07:00
|
|
|
bool namespace_by_default = true;
|
|
|
|
|
|
|
|
constexpr StrC nspace_default = txt_StrC(R"(
|
|
|
|
#if defined(GEN_DONT_USE_NAMESPACE) && ! defined(GEN_NS_BEGIN)
|
|
|
|
# define GEN_NS_BEGIN
|
|
|
|
# define GEN_NS_END
|
|
|
|
#elif ! defined(GEN_NS_BEGIN)
|
|
|
|
# define GEN_NS_BEGIN namespace gen {
|
|
|
|
# define GEN_NS_END }
|
|
|
|
#endif
|
|
|
|
)");
|
|
|
|
|
|
|
|
constexpr StrC nspace_non_default = txt_StrC(R"(
|
|
|
|
#if ! defined(GEN_USE_NAMESPACE) && ! defined(GEN_NS_BEGIN)
|
|
|
|
# define GEN_NS_BEGIN
|
|
|
|
# define GEN_NS_END
|
|
|
|
#elif ! defined(GEN_NS_BEGIN)
|
|
|
|
# define GEN_NS_BEGIN namespace gen {
|
|
|
|
# define GEN_NS_END }
|
|
|
|
#endif
|
|
|
|
)");
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
constexpr StrC implementation_guard_start = txt_StrC(R"(
|
2023-07-24 19:19:21 -07:00
|
|
|
#pragma region GENCPP IMPLEMENTATION GUARD
|
2023-07-25 14:46:00 -07:00
|
|
|
#if defined(GEN_IMPLEMENTATION) && ! defined(GEN_IMPLEMENTED)
|
|
|
|
# define GEN_IMPLEMENTED
|
2023-07-24 19:19:21 -07:00
|
|
|
)");
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
constexpr StrC implementation_guard_end = txt_StrC(R"(
|
2023-07-24 19:19:21 -07:00
|
|
|
#endif
|
|
|
|
#pragma endregion GENCPP IMPLEMENTATION GUARD
|
|
|
|
)");
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
constexpr StrC roll_own_dependencies_guard_start = txt_StrC(R"(
|
|
|
|
//! If its desired to roll your own dependencies, define GEN_ROLL_OWN_DEPENDENCIES before including this file.
|
|
|
|
// Dependencies are derived from the c-zpl library: https://github.com/zpl-c/zpl
|
|
|
|
#ifndef GEN_ROLL_OWN_DEPENDENCIES
|
|
|
|
|
|
|
|
)");
|
|
|
|
|
|
|
|
constexpr StrC roll_own_dependencies_guard_end = txt_StrC(R"(
|
|
|
|
// GEN_ROLL_OWN_DEPENDENCIES
|
|
|
|
#endif
|
|
|
|
|
|
|
|
)");
|
|
|
|
|
2023-07-24 15:56:15 -07:00
|
|
|
int gen_main()
|
|
|
|
{
|
2023-07-24 19:19:21 -07:00
|
|
|
gen::init();
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
#define project_dir "../project/"
|
|
|
|
|
|
|
|
Code push_ignores = scan_file( project_dir "helpers/gen.push_ignores.inline.hpp" );
|
|
|
|
Code pop_ignores = scan_file( project_dir "helpers/gen.pop_ignores.inline.hpp" );
|
2023-07-24 19:19:21 -07:00
|
|
|
|
|
|
|
Code header_start = scan_file( "components/gen.header_start.hpp" );
|
|
|
|
Code nspace_macro = untyped_str( namespace_by_default ? nspace_default : nspace_non_default );
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
Builder
|
|
|
|
header;
|
|
|
|
header.open( "gen/gen.hpp" );
|
|
|
|
header.print( push_ignores );
|
2023-07-24 19:19:21 -07:00
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt("#pragma once\n\n");
|
2023-07-24 19:19:21 -07:00
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
// Headers
|
|
|
|
{
|
|
|
|
header.print( header_start );
|
|
|
|
header.print( nspace_macro );
|
|
|
|
|
|
|
|
{
|
|
|
|
header.print_fmt( roll_own_dependencies_guard_start );
|
|
|
|
|
|
|
|
Code header_start = scan_file( project_dir "dependencies/gen.header_start.hpp" );
|
|
|
|
Code macros = scan_file( project_dir "dependencies/gen.macros.hpp" );
|
|
|
|
Code basic_types = scan_file( project_dir "dependencies/gen.basic_types.hpp" );
|
|
|
|
Code debug = scan_file( project_dir "dependencies/gen.debug.hpp" );
|
|
|
|
Code memory = scan_file( project_dir "dependencies/gen.memory.hpp" );
|
|
|
|
Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.hpp" );
|
|
|
|
Code printing = scan_file( project_dir "dependencies/gen.printing.hpp" );
|
|
|
|
Code containers = scan_file( project_dir "dependencies/gen.containers.hpp" );
|
2023-07-26 11:21:20 -07:00
|
|
|
Code hashing = scan_file( project_dir "dependencies/gen.hashing.hpp" );
|
2023-07-25 12:12:51 -07:00
|
|
|
Code string = scan_file( project_dir "dependencies/gen.string.hpp" );
|
|
|
|
Code file_handling = scan_file( project_dir "dependencies/gen.file_handling.hpp" );
|
|
|
|
Code parsing = scan_file( project_dir "dependencies/gen.parsing.hpp" );
|
|
|
|
Code timing = scan_file( project_dir "dependencies/gen.timing.hpp" );
|
|
|
|
|
|
|
|
header.print( header_start );
|
2023-07-25 14:46:00 -07:00
|
|
|
header.print_fmt( "GEN_NS_BEGIN\n\n" );
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print( macros );
|
|
|
|
header.print( basic_types );
|
|
|
|
header.print( debug );
|
|
|
|
header.print( memory );
|
|
|
|
header.print( string_ops );
|
|
|
|
header.print( printing );
|
|
|
|
header.print( containers );
|
2023-07-26 11:21:20 -07:00
|
|
|
header.print( hashing );
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print( string );
|
|
|
|
header.print( file_handling );
|
|
|
|
header.print( parsing );
|
|
|
|
header.print( timing );
|
|
|
|
header.print_fmt( "GEN_NS_END\n" );
|
|
|
|
|
|
|
|
header.print_fmt( roll_own_dependencies_guard_end );
|
|
|
|
}
|
|
|
|
|
|
|
|
Code types = scan_file( project_dir "components/gen.types.hpp" );
|
|
|
|
Code data_structs = scan_file( project_dir "components/gen.data_structures.hpp" );
|
|
|
|
Code interface = scan_file( project_dir "components/gen.interface.hpp" );
|
|
|
|
Code header_end = scan_file( project_dir "components/gen.header_end.hpp" );
|
|
|
|
|
2023-07-26 11:21:20 -07:00
|
|
|
CodeBody ecode = gen_ecode( project_dir "components/ECode.csv" );
|
|
|
|
CodeBody eoperator = gen_eoperator( project_dir "components/EOperator.csv" );
|
|
|
|
CodeBody especifier = gen_especifier( project_dir "components/ESpecifier.csv" );
|
|
|
|
|
2023-07-25 14:46:00 -07:00
|
|
|
Code builder = scan_file( project_dir "filesystem/gen.builder.hpp" );
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt( "GEN_NS_BEGIN\n\n" );
|
2023-07-26 11:21:20 -07:00
|
|
|
|
2023-07-27 14:12:58 -07:00
|
|
|
header.print_fmt("#pragma region Types\n\n");
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print( types );
|
2023-07-26 11:21:20 -07:00
|
|
|
header.print( ecode );
|
|
|
|
header.print( eoperator );
|
|
|
|
header.print( especifier );
|
2023-07-27 14:12:58 -07:00
|
|
|
header.print_fmt("#pragma endregion Types\n\n");
|
2023-07-26 11:21:20 -07:00
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print( data_structs );
|
|
|
|
header.print( interface );
|
|
|
|
header.print( header_end );
|
2023-07-25 14:46:00 -07:00
|
|
|
header.print( builder );
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt( "GEN_NS_END\n" );
|
|
|
|
}
|
2023-07-24 19:19:21 -07:00
|
|
|
|
|
|
|
// Implementation
|
2023-07-25 12:12:51 -07:00
|
|
|
{
|
|
|
|
header.print_fmt( "%s\n", (char const*) implementation_guard_start );
|
|
|
|
{
|
|
|
|
header.print_fmt( roll_own_dependencies_guard_start );
|
|
|
|
|
|
|
|
Code impl_start = scan_file( project_dir "dependencies/gen.impl_start.cpp" );
|
|
|
|
Code debug = scan_file( project_dir "dependencies/gen.debug.cpp" );
|
|
|
|
Code string_ops = scan_file( project_dir "dependencies/gen.string_ops.cpp" );
|
|
|
|
Code printing = scan_file( project_dir "dependencies/gen.printing.cpp" );
|
|
|
|
Code memory = scan_file( project_dir "dependencies/gen.memory.cpp" );
|
|
|
|
Code parsing = scan_file( project_dir "dependencies/gen.parsing.cpp" );
|
|
|
|
Code hashing = scan_file( project_dir "dependencies/gen.hashing.cpp" );
|
|
|
|
Code string = scan_file( project_dir "dependencies/gen.string.cpp" );
|
|
|
|
Code timing = scan_file( project_dir "dependencies/gen.timing.cpp" );
|
|
|
|
|
2023-07-25 14:46:00 -07:00
|
|
|
Code file_handling = scan_file( project_dir "dependencies/gen.file_handling.cpp" );
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
|
|
|
header.print( impl_start );
|
|
|
|
header.print( debug );
|
|
|
|
header.print( string_ops );
|
|
|
|
header.print( printing );
|
|
|
|
header.print( memory );
|
|
|
|
header.print( parsing );
|
|
|
|
header.print( hashing );
|
|
|
|
header.print( string );
|
|
|
|
header.print( timing );
|
2023-07-25 14:46:00 -07:00
|
|
|
|
|
|
|
header.print( file_handling );
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt( "GEN_NS_END\n");
|
|
|
|
|
|
|
|
header.print_fmt( roll_own_dependencies_guard_end );
|
|
|
|
}
|
|
|
|
|
|
|
|
Code data = scan_file( project_dir "components/gen.data.cpp" );
|
|
|
|
Code ast_case_macros = scan_file( project_dir "components/gen.ast_case_macros.cpp" );
|
|
|
|
Code ast = scan_file( project_dir "components/gen.ast.cpp" );
|
|
|
|
Code interface = scan_file( project_dir "components/gen.interface.cpp" );
|
|
|
|
Code upfront = scan_file( project_dir "components/gen.interface.upfront.cpp" );
|
|
|
|
Code parsing = scan_file( project_dir "components/gen.interface.parsing.cpp" );
|
|
|
|
Code untyped = scan_file( project_dir "components/gen.untyped.cpp" );
|
|
|
|
|
2023-07-27 14:12:58 -07:00
|
|
|
CodeBody etoktype = gen_etoktype( project_dir "components/ETokType.csv", project_dir "components/AttributeTokens.csv" );
|
2023-07-26 23:51:36 -07:00
|
|
|
CodeNamespace parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) );
|
|
|
|
|
2023-07-25 14:46:00 -07:00
|
|
|
Code builder = scan_file( project_dir "filesystem/gen.builder.cpp" );
|
|
|
|
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt( "GEN_NS_BEGIN\n\n");
|
|
|
|
header.print( data );
|
|
|
|
header.print( ast_case_macros );
|
|
|
|
header.print( ast );
|
|
|
|
header.print( interface );
|
|
|
|
header.print( upfront );
|
2023-07-26 23:51:36 -07:00
|
|
|
header.print( parser_nspace );
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print( parsing );
|
|
|
|
header.print( untyped );
|
2023-07-25 14:46:00 -07:00
|
|
|
header.print( builder );
|
2023-07-25 12:12:51 -07:00
|
|
|
header.print_fmt( "GEN_NS_END\n");
|
|
|
|
|
|
|
|
header.print_fmt( "%s\n", (char const*) implementation_guard_end );
|
|
|
|
}
|
|
|
|
|
|
|
|
header.print( pop_ignores );
|
|
|
|
header.write();
|
2023-07-24 19:19:21 -07:00
|
|
|
|
|
|
|
gen::deinit();
|
2023-07-24 15:56:15 -07:00
|
|
|
return 0;
|
2023-07-24 19:19:21 -07:00
|
|
|
}
|