diff --git a/project/components/ast.cpp b/project/components/ast.cpp index d4c964d..703fde2 100644 --- a/project/components/ast.cpp +++ b/project/components/ast.cpp @@ -4,6 +4,36 @@ Code Code::Global; Code Code::Invalid; +char const* AST::debug_str() +{ + if ( Parent ) + { + String + result = String::make_reserve( GlobalAllocator, kilobytes(1) ); + result.append_fmt( + "\nType : %s" + "\nParent : %s %s" + "\nName : %s" + , type_str() + , Parent->type_str() + , Parent->Name, Name ? Name : "" + ); + + return result; + } + + String + result = String::make_reserve( GlobalAllocator, kilobytes(1) ); + result.append_fmt( + "\nType : %s" + "\nName : %s" + , type_str() + , Name ? Name : "" + ); + + return result; +} + AST* AST::duplicate() { using namespace ECode; @@ -952,10 +982,9 @@ bool AST::is_equal( AST* other ) #define check_member_val( val ) \ if ( val != other->val ) \ { \ - log_fmt("AST::is_equal: Member - " #val "\n failed" \ + log_fmt("AST::is_equal: Member - " #val " failed\n" \ "AST : %S\n" \ "Other: %S\n" \ - "For val member: " #val \ , debug_str() \ , other->debug_str() \ ); \ @@ -963,18 +992,17 @@ bool AST::is_equal( AST* other ) return false; \ } - #define check_member_str( str ) \ - if ( str != other->str ) \ - { \ - log_fmt("AST::is_equal: Member string check failure with other\n" \ - "AST : %S\n" \ - "Other: %S\n" \ - "For str member: " #str \ - , debug_str() \ - , other->debug_str() \ - ); \ - \ - return false; \ + #define check_member_str( str ) \ + if ( str != other->str ) \ + { \ + log_fmt("AST::is_equal: Member string - "#str " failed\n" \ + "AST : %S\n" \ + "Other: %S\n" \ + , debug_str() \ + , other->debug_str() \ + ); \ + \ + return false; \ } #define check_member_ast( ast ) \ @@ -983,9 +1011,9 @@ bool AST::is_equal( AST* other ) if ( other->ast == nullptr ) \ { \ log_fmt("AST::is_equal: Failed for member " #ast " other equivalent param is null\n" \ - "AST : %S\n" \ - "Other: %S\n" \ - "For ast member: %S\n" \ + "AST : %s\n" \ + "Other: %s\n" \ + "For ast member: %s\n" \ , debug_str() \ , other->debug_str() \ , ast->debug_str() \ @@ -1000,7 +1028,7 @@ bool AST::is_equal( AST* other ) "AST : %S\n" \ "Other: %S\n" \ "For ast member: %S\n" \ - "other's ast member: %S\n" \ + "other ast member: %S\n" \ , debug_str() \ , other->debug_str() \ , ast->debug_str() \ diff --git a/project/components/inlines.hpp b/project/components/inlines.hpp index 06b0d51..20aac3d 100644 --- a/project/components/inlines.hpp +++ b/project/components/inlines.hpp @@ -25,43 +25,6 @@ void AST::append( AST* other ) NumEntries++; } -char const* AST::debug_str() -{ - if ( Parent ) - { - char const* fmt = stringize( - \nType : %s - \nParent : %s %s - \nName : %s - ); - - // These should be used immediately in a log. - // Thus if its desired to keep the debug str - // for multiple calls to bprintf, - // allocate this to proper string. - return str_fmt_buf( fmt - , type_str() - , Parent->Name - , Parent->type_str() - , Name ? Name : "" - ); - } - - char const* fmt = stringize( - \nType : %s - \nName : %s - ); - - // These should be used immediately in a log. - // Thus if its desired to keep the debug str - // for multiple calls to bprintf, - // allocate this to proper string. - return str_fmt_buf( fmt - , type_str() - , Name ? Name : "" - ); -} - Code& AST::entry( u32 idx ) { AST** current = & Front; diff --git a/project/components/interface.parsing.cpp b/project/components/interface.parsing.cpp index 8245673..720ade6 100644 --- a/project/components/interface.parsing.cpp +++ b/project/components/interface.parsing.cpp @@ -523,10 +523,10 @@ namespace Parser s32 within_char = false; while ( left ) { - if ( current == '"' ) + if ( current == '"' && ! within_char ) within_string ^= true; - if ( current == '\'' ) + if ( current == '\'' && ! within_string ) within_char ^= true; if ( current == '\\' && ! within_string && ! within_char ) diff --git a/test/validate.singleheader.cpp b/test/validate.singleheader.cpp index f92130c..fbfef34 100644 --- a/test/validate.singleheader.cpp +++ b/test/validate.singleheader.cpp @@ -35,7 +35,7 @@ void check_singleheader_ast() time_start = time_rel_ms(); CodeBody ast_gen = parse_global_body( { file_gen.size, (char const*)file_gen.data } ); - log_fmt("\nAst generated. Time taken: %llu ms\n", time_rel_ms() - time_start); + log_fmt("\nAst generated. Time taken: %llu ms\n\n", time_rel_ms() - time_start); time_start = time_rel_ms();