From c4846dad264bc0e054c6afc1ee38994041f519bc Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 22 Aug 2023 01:51:59 -0400 Subject: [PATCH] Formatting fixes --- .vscode/c_cpp_properties.json | 6 ++- project/bootstrap.cpp | 55 ++++++++++++------------ project/components/ast_case_macros.cpp | 1 - project/components/ast_types.hpp | 1 + project/components/gen/ast_inlines.hpp | 2 +- project/components/gen/ecode.hpp | 4 +- project/components/gen/eoperator.hpp | 4 +- project/components/gen/especifier.hpp | 4 +- project/components/interface.parsing.cpp | 21 ++++++--- project/components/interface.upfront.cpp | 1 - project/helpers/helper.hpp | 6 +-- scripts/build.ci.ps1 | 2 +- singleheader/singleheader.cpp | 38 ++++++++-------- 13 files changed, 79 insertions(+), 66 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 6b1c561..fd5dbf0 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,7 +9,8 @@ "_DEBUG", "UNICODE", "_UNICODE", - "GEN_TIME" + "GEN_TIME", + "GEN_IMPLEMENTATION" // "GEN_DONT_USE_NAMESPACE" ], "windowsSdkVersion": "10.0.19041.0", @@ -26,7 +27,8 @@ "_DEBUG", "UNICODE", "_UNICODE", - "GEN_TIME" + "GEN_TIME", + "GEN_IMPLEMENTATION" // "GEN_DONT_USE_NAMESPACE" ], "windowsSdkVersion": "10.0.19041.0", diff --git a/project/bootstrap.cpp b/project/bootstrap.cpp index e36d202..1d37f23 100644 --- a/project/bootstrap.cpp +++ b/project/bootstrap.cpp @@ -63,7 +63,7 @@ int gen_main() header.print( filesystem ); header.print( timing ); - header.print_fmt( "GEN_NS_END\n" ); + header.print_fmt( "\nGEN_NS_END\n" ); header.write(); } @@ -84,7 +84,7 @@ int gen_main() src.print_fmt( generation_notice ); src.print_fmt( "// This file is intended to be included within gen.cpp (There is no pragma diagnostic ignores)\n\n" ); src.print( src_start ); - src.print_fmt( "GEN_NS_BEGIN\n\n" ); + src.print_fmt( "\nGEN_NS_BEGIN\n" ); src.print( debug ); src.print( string_ops ); @@ -95,7 +95,7 @@ int gen_main() src.print( filesystem ); src.print( timing ); - src.print_fmt( "GEN_NS_END\n\n" ); + src.print_fmt( "\nGEN_NS_END\n" ); src.write(); } @@ -120,26 +120,27 @@ int gen_main() header.print_fmt( "#pragma once\n\n" ); header.print( push_ignores ); header.print( header_start ); - header.print_fmt( "GEN_NS_BEGIN\n\n" ); + header.print_fmt( "\nGEN_NS_BEGIN\n\n" ); - header.print_fmt( "#pragma region Types\n\n" ); + header.print_fmt( "#pragma region Types\n" ); header.print( types ); header.print( ecode ); header.print( eoperator ); header.print( especifier ); header.print_fmt( "#pragma endregion Types\n\n" ); - header.print_fmt( "#pragma region AST\n\n" ); + header.print_fmt( "#pragma region AST\n" ); header.print( ast ); header.print( ast_types ); - header.print_fmt( "#pragma endregion AST\n\n" ); + header.print_fmt( "\n#pragma endregion AST\n" ); header.print( interface ); - header.print_fmt( "#pragma region Inlines\n\n" ); + header.print_fmt( "\npragma region Inlines\n" ); header.print( inlines ); + header.print( fmt_newline ); header.print( ast_inlines ); - header.print_fmt( "#pragma endregion Inlines\n\n" ); + header.print_fmt( "#pragma endregion Inlines\n" ); header.print( header_end ); header.print_fmt( "GEN_NS_END\n\n" ); @@ -148,29 +149,29 @@ int gen_main() Builder header_ecode = Builder::open( "components/gen/ecode.hpp" ); - header_ecode.print_fmt( generation_notice ); header_ecode.print( pragma_once ); + header_ecode.print_fmt( generation_notice ); header_ecode.print( ecode ); header_ecode.write(); Builder header_eoperator = Builder::open( "components/gen/eoperator.hpp" ); - header_eoperator.print_fmt( generation_notice ); header_eoperator.print( pragma_once ); + header_eoperator.print_fmt( generation_notice ); header_eoperator.print( eoperator ); header_eoperator.write(); Builder header_especifier = Builder::open( "components/gen/especifier.hpp" ); - header_especifier.print_fmt( generation_notice ); header_especifier.print( pragma_once ); + header_especifier.print_fmt( generation_notice ); header_especifier.print( especifier ); header_especifier.write(); Builder header_ast_inlines = Builder::open( "components/gen/ast_inlines.hpp" ); - header_ast_inlines.print_fmt( generation_notice ); header_ast_inlines.print( pragma_once ); + header_ast_inlines.print_fmt( generation_notice ); header_ast_inlines.print( ast_inlines ); header_ast_inlines.write(); } @@ -194,23 +195,23 @@ int gen_main() src.print_fmt( generation_notice ); src.print( push_ignores ); src.print( src_start ); - src.print_fmt( "\nGEN_NS_BEGIN\n\n"); + src.print_fmt( "GEN_NS_BEGIN\n"); src.print( static_data ); - src.print_fmt( "#pragma region AST\n\n" ); + src.print_fmt( "\n#pragma region AST\n\n" ); src.print( ast_case_macros ); src.print( ast ); - src.print_fmt( "#pragma endregion AST\n\n" ); + src.print_fmt( "\n#pragma endregion AST\n" ); - src.print_fmt( "#pragma region Interface\n\n" ); + src.print_fmt( "\n#pragma region Interface\n" ); src.print( interface ); src.print( upfront ); - src.print_fmt( "#pragma region Parsing\n\n" ); + src.print_fmt( "\n#pragma region Parsing\n\n" ); src.print( nspaced_etoktype ); src.print( parsing ); src.print( untyped ); - src.print_fmt( "#pragma endregion Parsing\n\n" ); + src.print_fmt( "\n#pragma endregion Parsing\n\n" ); src.print_fmt( "#pragma endregion Interface\n\n" ); src.print_fmt( "GEN_NS_END\n\n"); @@ -234,9 +235,9 @@ int gen_main() header.print_fmt( generation_notice ); header.print_fmt( "#pragma once\n\n" ); header.print( def_include( txt("gen.hpp") )); - header.print_fmt( "\nGEN_NS_BEGIN\n\n" ); + header.print_fmt( "\nGEN_NS_BEGIN\n" ); header.print( builder ); - header.print_fmt( "\nGEN_NS_END\n\n" ); + header.print_fmt( "GEN_NS_END\n" ); header.write(); } @@ -248,9 +249,9 @@ int gen_main() src = Builder::open( "gen/gen.builder.cpp" ); src.print_fmt( generation_notice ); src.print( def_include( txt("gen.builder.hpp") ) ); - src.print_fmt( "\nGEN_NS_BEGIN\n\n" ); + src.print_fmt( "\nGEN_NS_BEGIN\n" ); src.print( builder ); - src.print_fmt( "\nGEN_NS_END\n\n" ); + src.print_fmt( "\nGEN_NS_END\n" ); src.write(); } @@ -264,10 +265,10 @@ int gen_main() header.print_fmt( generation_notice ); header.print_fmt( "#pragma once\n\n" ); header.print( def_include( txt("gen.hpp") ) ); - header.print_fmt( "\nGEN_NS_BEGIN\n\n" ); + header.print_fmt( "\nGEN_NS_BEGIN\n" ); header.print( parsing ); header.print( scanner ); - header.print_fmt( "\nGEN_NS_END\n\n" ); + header.print_fmt( "GEN_NS_END\n" ); header.write(); } @@ -280,10 +281,10 @@ int gen_main() src = Builder::open( "gen/gen.scanner.cpp" ); src.print_fmt( generation_notice ); src.print( def_include( txt("gen.scanner.hpp") ) ); - src.print_fmt( "\nGEN_NS_BEGIN\n\n" ); + src.print_fmt( "\nGEN_NS_BEGIN\n" ); src.print( parsing ); src.print( scanner ); - src.print_fmt( "\nGEN_NS_END\n\n" ); + src.print_fmt( "GEN_NS_END\n" ); src.write(); } diff --git a/project/components/ast_case_macros.cpp b/project/components/ast_case_macros.cpp index 4ed2ad2..8d0abda 100644 --- a/project/components/ast_case_macros.cpp +++ b/project/components/ast_case_macros.cpp @@ -76,4 +76,3 @@ case Specifiers: \ case Struct_Body: \ case Typename: - diff --git a/project/components/ast_types.hpp b/project/components/ast_types.hpp index 8a8c54c..20d2f86 100644 --- a/project/components/ast_types.hpp +++ b/project/components/ast_types.hpp @@ -541,4 +541,5 @@ struct AST_Var char _PAD_UNUSED_[ sizeof(u32) ]; }; static_assert( sizeof(AST_Var) == sizeof(AST), "ERROR: AST_Var is not the same size as AST"); + #pragma endregion AST Types diff --git a/project/components/gen/ast_inlines.hpp b/project/components/gen/ast_inlines.hpp index 1cb8a45..aaed685 100644 --- a/project/components/gen/ast_inlines.hpp +++ b/project/components/gen/ast_inlines.hpp @@ -1,6 +1,6 @@ +#pragma once // This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) -#pragma once #pragma region generated code inline implementation char const* Code::debug_str( void ) diff --git a/project/components/gen/ecode.hpp b/project/components/gen/ecode.hpp index 80f749a..a1701b9 100644 --- a/project/components/gen/ecode.hpp +++ b/project/components/gen/ecode.hpp @@ -1,7 +1,7 @@ -// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) - #pragma once +// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) + namespace ECode { enum Type : u32 diff --git a/project/components/gen/eoperator.hpp b/project/components/gen/eoperator.hpp index b49b89e..dd40844 100644 --- a/project/components/gen/eoperator.hpp +++ b/project/components/gen/eoperator.hpp @@ -1,7 +1,7 @@ -// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) - #pragma once +// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) + namespace EOperator { enum Type : u32 diff --git a/project/components/gen/especifier.hpp b/project/components/gen/especifier.hpp index fccecae..b5f9d5e 100644 --- a/project/components/gen/especifier.hpp +++ b/project/components/gen/especifier.hpp @@ -1,7 +1,7 @@ -// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) - #pragma once +// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp) + namespace ESpecifier { enum Type : u32 diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index 8d641d7..f120a25 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -401,6 +401,11 @@ namespace Parser if ( token.Type == TokType::Preprocess_Else || token.Type == TokType::Preprocess_EndIf ) { Tokens.append( token ); + while ( left && current != '\n' ) + { + move_forward(); + } + move_forward(); continue; } @@ -882,13 +887,13 @@ namespace Parser } else if ( current == '*' ) { - token.Type = TokType::Comment_Start; + token.Type = TokType::Comment_Start; token.Length = 2; Tokens.append( token ); + Token content = { token.Text, 0, TokType::Comment, line, column, false }; move_forward(); - // move_forward(); - Token content = { scanner, 0, TokType::Comment, line, column, false }; + content.Length++; bool star = current == '*'; bool slash = scanner[1] == '/'; @@ -902,13 +907,19 @@ namespace Parser slash = scanner[1] == '/'; at_end = star && slash; } + content.Length += 3; Tokens.append( content ); Token end = { scanner, 2, TokType::Comment_End, line, column, false }; + Tokens.append( end ); move_forward(); move_forward(); - Tokens.append( end ); + while ( left && current != '\n' ) + { + move_forward(); + } + move_forward(); continue; } } @@ -2288,7 +2299,7 @@ Code parse_simple_preprocess( Parser::TokType which ) tok.Length = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)tok.Text; } - char const* content = str_fmt_buf( "%.*s\n", tok.Length, tok.Text ); + char const* content = str_fmt_buf( "%.*s ", tok.Length, tok.Text ); Code result = untyped_str( to_str( content ) ); Context.Scope->Name = tok; diff --git a/project/components/interface.upfront.cpp b/project/components/interface.upfront.cpp index 7edccd0..a69b7f7 100644 --- a/project/components/interface.upfront.cpp +++ b/project/components/interface.upfront.cpp @@ -2255,5 +2255,4 @@ CodeBody def_union_body( s32 num, CodeUnion* codes ) # undef def_body_start # undef def_body_code_array_start - #pragma endregion Upfront diff --git a/project/helpers/helper.hpp b/project/helpers/helper.hpp index cc492dd..2c80e9b 100644 --- a/project/helpers/helper.hpp +++ b/project/helpers/helper.hpp @@ -50,7 +50,7 @@ CodeBody gen_ecode( char const* path ) CodeNS nspace = def_namespace( name(ECode), def_namespace_body( args( enum_code, to_str ) ) ); CodeUsing code_t = def_using( name(CodeT), def_type( name(ECode::Type) ) ); - return def_global_body( args( nspace, code_t ) ); + return def_global_body( args( nspace, code_t, fmt_newline ) ); } CodeBody gen_eoperator( char const* path ) @@ -105,7 +105,7 @@ CodeBody gen_eoperator( char const* path ) CodeUsing operator_t = def_using( name(OperatorT), def_type( name(EOperator::Type) ) ); - return def_global_body( args( nspace, operator_t ) ); + return def_global_body( args( nspace, operator_t, fmt_newline ) ); } CodeBody gen_especifier( char const* path ) @@ -207,7 +207,7 @@ CodeBody gen_especifier( char const* path ) CodeUsing specifier_t = def_using( name(SpecifierT), def_type( name(ESpecifier::Type) ) ); - return def_global_body( args( nspace, specifier_t ) ); + return def_global_body( args( nspace, specifier_t, fmt_newline ) ); } CodeBody gen_etoktype( char const* etok_path, char const* attr_path ) diff --git a/scripts/build.ci.ps1 b/scripts/build.ci.ps1 index 6cedf58..f55a3e5 100644 --- a/scripts/build.ci.ps1 +++ b/scripts/build.ci.ps1 @@ -444,7 +444,7 @@ if ( $bootstrap -and (Test-Path (Join-Path $path_project "gen/gen.hpp")) ) 'gen.scanner.hpp', 'gen.scanner.cpp' ) $exclude = $null - format-cpp $path_gen $include $exclude + # format-cpp $path_gen $include $exclude format-cpp $path_comp_gen @( 'ast_inlines.hpp', 'ecode.hpp', 'especifier.hpp', 'eoperator.hpp', 'etoktype.cpp' ) $null } diff --git a/singleheader/singleheader.cpp b/singleheader/singleheader.cpp index 9b637a3..57e9e16 100644 --- a/singleheader/singleheader.cpp +++ b/singleheader/singleheader.cpp @@ -86,7 +86,7 @@ int gen_main() header.print_fmt( roll_own_dependencies_guard_start ); header.print( header_start ); - header.print_fmt( "GEN_NS_BEGIN\n\n" ); + header.print_fmt( "\nGEN_NS_BEGIN\n" ); header.print( macros ); header.print( basic_types ); @@ -102,7 +102,7 @@ int gen_main() if ( generate_scanner ) { - header.print_fmt( "#pragma region Parsing\n\n" ); + header.print_fmt( "\n#pragma region Parsing\n" ); header.print( scan_file( project_dir "dependencies/parsing.hpp" ) ); header.print_fmt( "#pragma endregion Parsing\n\n" ); } @@ -126,37 +126,37 @@ int gen_main() header.print_fmt( "GEN_NS_BEGIN\n\n" ); - header.print_fmt("#pragma region Types\n\n"); + header.print_fmt("#pragma region Types\n"); header.print( types ); header.print( ecode ); header.print( eoperator ); header.print( especifier ); header.print_fmt("#pragma endregion Types\n\n"); - header.print_fmt("#pragma region AST\n\n"); + header.print_fmt("#pragma region AST\n"); header.print( ast ); header.print( ast_types ); - header.print_fmt("#pragma endregion AST\n\n"); + header.print_fmt("\n#pragma endregion AST\n"); header.print( interface ); - header.print_fmt( "#pragma region Inlines\n\n" ); + header.print_fmt( "\n#pragma region Inlines\n" ); header.print( inlines ); header.print( ast_inlines ); - header.print_fmt( "#pragma endregion Inlines\n\n" ); + header.print_fmt( "#pragma endregion Inlines\n" ); header.print( header_end ); if ( generate_builder ) { - header.print_fmt( "#pragma region Builder\n\n" ); + header.print_fmt( "\n#pragma region Builder\n" ); header.print( scan_file( project_dir "auxillary/builder.hpp" ) ); - header.print_fmt( "#pragma endregion Builder\n\n" ); + header.print_fmt( "#pragma endregion Builder\n" ); } if ( generate_scanner ) { - header.print_fmt( "#pragma region Scanner\n\n" ); + header.print_fmt( "\n#pragma region Scanner\n" ); header.print( scan_file( project_dir "auxillary/scanner.hpp" ) ); header.print_fmt( "#pragma endregion Scanner\n\n" ); } @@ -195,8 +195,8 @@ int gen_main() if ( generate_scanner ) { - header.print_fmt( "#pragma region Parsing\n\n" ); - header.print( scan_file( project_dir "dependencies/parsing.cpp" ) ); + header.print_fmt( "\n#pragma region Parsing\n" ); + header.print( scan_file( project_dir "dependencies/parsing.cpp" ) ); header.print_fmt( "#pragma endregion Parsing\n\n" ); } @@ -215,7 +215,7 @@ int gen_main() CodeBody etoktype = gen_etoktype( project_dir "enums/ETokType.csv", project_dir "enums/AttributeTokens.csv" ); CodeNS parser_nspace = def_namespace( name(Parser), def_namespace_body( args(etoktype)) ); - header.print_fmt( "GEN_NS_BEGIN\n\n"); + header.print_fmt( "\njGEN_NS_BEGIN\n"); header.print( static_data ); header.print_fmt( "#pragma region AST\n\n" ); @@ -223,21 +223,21 @@ int gen_main() header.print( ast ); header.print_fmt( "#pragma endregion AST\n\n" ); - header.print_fmt( "#pragma region Interface\n\n" ); + header.print_fmt( "#pragma region Interface\n" ); header.print( interface ); header.print( upfront ); - header.print_fmt( "#pragma region Parsing\n\n" ); + header.print_fmt( "\n#pragma region Parsing\n\n" ); header.print( parser_nspace ); header.print( parsing ); - header.print_fmt( "#pragma endregion Parsing\n\n" ); + header.print_fmt( "\npragma endregion Parsing\n" ); header.print( untyped ); - header.print_fmt( "#pragma endregion Interface\n\n"); + header.print_fmt( "\n#pragma endregion Interface\n\n"); if ( generate_builder ) { - header.print_fmt( "#pragma region Builder\n\n" ); + header.print_fmt( "#pragma region Builder\n" ); header.print( scan_file( project_dir "auxillary/builder.cpp" ) ); - header.print_fmt( "#pragma endregion Builder\n\n" ); + header.print_fmt( "\npragma endregion Builder\n\n" ); } #if 0