From fe5aac98df7124029043659e5e21bd85dbf4783f Mon Sep 17 00:00:00 2001 From: Ploo <239304139+xinitrcn1@users.noreply.github.com> Date: Tue, 9 Dec 2025 08:47:32 +0000 Subject: [PATCH 1/3] uint128_t usage on parsergenerator --- ParserGenerator/parser_generator.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ParserGenerator/parser_generator.cpp b/ParserGenerator/parser_generator.cpp index 9de7c8d9e..ecfeff5d8 100644 --- a/ParserGenerator/parser_generator.cpp +++ b/ParserGenerator/parser_generator.cpp @@ -381,6 +381,13 @@ std::string final_match_condition_internal(std::string_view const key, int32_t s if(starting_position >= ending_position) return ""; +#if defined(__GNUC__) || defined(__clang__) + if(ending_position - starting_position >= 8) { + return + " && (*(uint128_t const*)(&cur.content[" + std::to_string(starting_position) + "]) | ((uint128_t(0x2020202020202020)) << 64 | uint128_t(0x2020202020202020))) == ((uint128_t(" + string_to_hex(key, starting_position + 8, 8) + ")) << 64 | uint128_t(" + string_to_hex(key, starting_position, 8) + ")))" + + final_match_condition_internal(key, starting_position + 8, ending_position); + } +#endif if(ending_position - starting_position >= 8) { return " && (*(uint64_t const*)(&cur.content[" + std::to_string(starting_position) + "]) | uint64_t(0x2020202020202020) ) == uint64_t(" + string_to_hex(key, starting_position, 8) + ")" @@ -593,13 +600,18 @@ std::string construct_match_tree_outer(auto const& vector, auto const& generator void file_write_out(std::fstream& stream, std::vector& groups) { // process the parsed content into the generated file - std::string output; - output += "#include \"parsers.hpp\"\n"; - // output += "#pragma warning( push )\n"; - // output += "#pragma warning( disable : 4065 )\n"; - // output += "#pragma warning( disable : 4189 )\n"; - output += "\n"; - output += "namespace parsers {\n"; + std::string output = + "#include \"parsers.hpp\"\n" + //"#pragma warning( push )\n" + //"#pragma warning( disable : 4065 )\n" + //"#pragma warning( disable : 4189 )\n" + "\n" + "namespace parsers {\n" +#if defined(__GNUC__) || defined(__clang__) + "typedef __int128 int128_t;\n" + "typedef unsigned __int128 uint128_t;\n" +#endif + ; // fn bodies std::vector declared_groups(groups.size(), false); for(size_t i = 0; i < groups.size(); i++) { From 3a1eee92776328e98163cba362f76d40759cc2e9 Mon Sep 17 00:00:00 2001 From: Ploo <239304139+xinitrcn1@users.noreply.github.com> Date: Tue, 9 Dec 2025 08:48:55 +0000 Subject: [PATCH 2/3] Update parser_generator.cpp --- ParserGenerator/parser_generator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParserGenerator/parser_generator.cpp b/ParserGenerator/parser_generator.cpp index ecfeff5d8..c091b9979 100644 --- a/ParserGenerator/parser_generator.cpp +++ b/ParserGenerator/parser_generator.cpp @@ -382,7 +382,7 @@ std::string final_match_condition_internal(std::string_view const key, int32_t s return ""; #if defined(__GNUC__) || defined(__clang__) - if(ending_position - starting_position >= 8) { + if(ending_position - starting_position >= 16) { return " && (*(uint128_t const*)(&cur.content[" + std::to_string(starting_position) + "]) | ((uint128_t(0x2020202020202020)) << 64 | uint128_t(0x2020202020202020))) == ((uint128_t(" + string_to_hex(key, starting_position + 8, 8) + ")) << 64 | uint128_t(" + string_to_hex(key, starting_position, 8) + ")))" + final_match_condition_internal(key, starting_position + 8, ending_position); From 61c6cbd441f3a96860ac415822018e3da712b98e Mon Sep 17 00:00:00 2001 From: Ploo <239304139+xinitrcn1@users.noreply.github.com> Date: Tue, 9 Dec 2025 09:07:38 +0000 Subject: [PATCH 3/3] Update parser_generator.cpp --- ParserGenerator/parser_generator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ParserGenerator/parser_generator.cpp b/ParserGenerator/parser_generator.cpp index c091b9979..f9ad27c9e 100644 --- a/ParserGenerator/parser_generator.cpp +++ b/ParserGenerator/parser_generator.cpp @@ -384,7 +384,7 @@ std::string final_match_condition_internal(std::string_view const key, int32_t s #if defined(__GNUC__) || defined(__clang__) if(ending_position - starting_position >= 16) { return - " && (*(uint128_t const*)(&cur.content[" + std::to_string(starting_position) + "]) | ((uint128_t(0x2020202020202020)) << 64 | uint128_t(0x2020202020202020))) == ((uint128_t(" + string_to_hex(key, starting_position + 8, 8) + ")) << 64 | uint128_t(" + string_to_hex(key, starting_position, 8) + ")))" + " && (*(uint128_t const*)(&cur.content[" + std::to_string(starting_position) + "]) | (uint128_t(0x2020202020202020) << 64 | uint128_t(0x2020202020202020)) == uint128_t(" + string_to_hex(key, starting_position + 8, 8) + ") << 64 | uint128_t(" + string_to_hex(key, starting_position, 8) + "))" + final_match_condition_internal(key, starting_position + 8, ending_position); } #endif