From a6c657439003309bb31a21be50de41a6bb457891 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 22 Aug 2023 02:09:20 -0400 Subject: [PATCH] More formatting fixes --- project/bootstrap.cpp | 2 +- project/components/interface.parsing.cpp | 36 ++++++++++++++++-------- singleheader/singleheader.cpp | 6 ++-- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/project/bootstrap.cpp b/project/bootstrap.cpp index 1d37f23..229b888 100644 --- a/project/bootstrap.cpp +++ b/project/bootstrap.cpp @@ -136,7 +136,7 @@ int gen_main() header.print( interface ); - header.print_fmt( "\npragma region Inlines\n" ); + header.print_fmt( "\n#pragma region Inlines\n" ); header.print( inlines ); header.print( fmt_newline ); header.print( ast_inlines ); diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index f120a25..f9eea83 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -255,6 +255,25 @@ namespace Parser move_forward(); \ } + #define end_line() \ + do \ + { \ + while ( left && current == ' ' ) \ + { \ + move_forward(); \ + } \ + if ( left && current == '\r' ) \ + { \ + move_forward(); \ + move_forward(); \ + } \ + else if ( left && current == '\n' ) \ + { \ + move_forward(); \ + } \ + } \ + while (0) + s32 left = content.Len; char const* scanner = content.Ptr; @@ -303,7 +322,6 @@ namespace Parser token.Length++; Tokens.append( token ); - // log_fmt( "NewLine: %d\n", token.Line ); continue; } } @@ -401,11 +419,7 @@ namespace Parser if ( token.Type == TokType::Preprocess_Else || token.Type == TokType::Preprocess_EndIf ) { Tokens.append( token ); - while ( left && current != '\n' ) - { - move_forward(); - } - move_forward(); + end_line(); continue; } @@ -611,6 +625,8 @@ namespace Parser if (left) move_forward(); + + end_line(); goto FoundToken; case '[': @@ -714,6 +730,8 @@ namespace Parser if (left) move_forward(); + + end_line(); goto FoundToken; case '"': @@ -915,11 +933,7 @@ namespace Parser move_forward(); move_forward(); - while ( left && current != '\n' ) - { - move_forward(); - } - move_forward(); + end_line(); continue; } } diff --git a/singleheader/singleheader.cpp b/singleheader/singleheader.cpp index 57e9e16..a699613 100644 --- a/singleheader/singleheader.cpp +++ b/singleheader/singleheader.cpp @@ -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( "\njGEN_NS_BEGIN\n"); + header.print_fmt( "\nGEN_NS_BEGIN\n"); header.print( static_data ); header.print_fmt( "#pragma region AST\n\n" ); @@ -229,7 +229,7 @@ int gen_main() header.print_fmt( "\n#pragma region Parsing\n\n" ); header.print( parser_nspace ); header.print( parsing ); - header.print_fmt( "\npragma endregion Parsing\n" ); + header.print_fmt( "\n#pragma endregion Parsing\n" ); header.print( untyped ); header.print_fmt( "\n#pragma endregion Interface\n\n"); @@ -237,7 +237,7 @@ int gen_main() { header.print_fmt( "#pragma region Builder\n" ); header.print( scan_file( project_dir "auxillary/builder.cpp" ) ); - header.print_fmt( "\npragma endregion Builder\n\n" ); + header.print_fmt( "\n#pragma endregion Builder\n\n" ); } #if 0