From 82176db082f8275701b8aaf985b911a93b1de0f4 Mon Sep 17 00:00:00 2001 From: "Dr. Colin Hirsch" Date: Thu, 18 Apr 2024 22:30:00 +0200 Subject: [PATCH] Some style fixes. --- include/tao/pegtl/buffer/endless_reader.hpp | 1 + include/tao/pegtl/contrib/rep_string.hpp | 2 +- include/tao/pegtl/debug/coverage.hpp | 2 +- include/tao/pegtl/debug/trace_action.hpp | 5 +- include/tao/pegtl/debug/trace_traits.hpp | 2 + include/tao/pegtl/internal/action_input.hpp | 2 + include/tao/pegtl/internal/dummy_guard.hpp | 2 + include/tao/pegtl/internal/ione.hpp | 2 +- .../tao/pegtl/internal/lazy_scan_traits.hpp | 2 +- include/tao/pegtl/internal/mmap_input.hpp | 2 + include/tao/pegtl/internal/not_ione.hpp | 2 +- include/tao/pegtl/internal/not_one.hpp | 2 +- include/tao/pegtl/internal/not_range.hpp | 2 +- include/tao/pegtl/internal/peek_seven.hpp | 6 +- .../tao/pegtl/internal/rematch_position.hpp | 2 +- include/tao/pegtl/internal/unicode_string.hpp | 3 + include/tao/pegtl/internal/utf16_decode.hpp | 10 +-- include/tao/pegtl/internal/utf32_decode.hpp | 4 +- include/tao/pegtl/internal/utf8_decode.hpp | 10 +-- include/tao/pegtl/member.hpp | 1 + src/example/pegtl/cst.cpp | 90 ------------------- src/example/pegtl/token_input_1.cpp | 2 +- src/example/pegtl/token_input_2.cpp | 2 +- src/test/pegtl/icu_utf16_base.cpp | 2 +- src/test/pegtl/icu_utf32_base.cpp | 2 +- src/test/pegtl/icu_utf8_base.cpp | 2 +- 26 files changed, 44 insertions(+), 120 deletions(-) delete mode 100644 src/example/pegtl/cst.cpp diff --git a/include/tao/pegtl/buffer/endless_reader.hpp b/include/tao/pegtl/buffer/endless_reader.hpp index 006ad0582..e197efef2 100644 --- a/include/tao/pegtl/buffer/endless_reader.hpp +++ b/include/tao/pegtl/buffer/endless_reader.hpp @@ -5,6 +5,7 @@ #ifndef TAO_PEGTL_BUFFER_ENDLESS_READER_HPP #define TAO_PEGTL_BUFFER_ENDLESS_READER_HPP +#include #include #include #include diff --git a/include/tao/pegtl/contrib/rep_string.hpp b/include/tao/pegtl/contrib/rep_string.hpp index 277536d32..2b7ad4235 100644 --- a/include/tao/pegtl/contrib/rep_string.hpp +++ b/include/tao/pegtl/contrib/rep_string.hpp @@ -21,7 +21,7 @@ namespace TAO_PEGTL_NAMESPACE template< char... Ss, char... Cs > struct make_rep_string< 0, ascii_string< Ss... >, Cs... > { - using type = string< Ss... >; + using type = ascii_string< Ss... >; }; template< std::size_t N, char... Ss, char... Cs > diff --git a/include/tao/pegtl/debug/coverage.hpp b/include/tao/pegtl/debug/coverage.hpp index 82ea0f727..12f9c008e 100644 --- a/include/tao/pegtl/debug/coverage.hpp +++ b/include/tao/pegtl/debug/coverage.hpp @@ -36,7 +36,7 @@ namespace TAO_PEGTL_NAMESPACE [[nodiscard]] explicit operator bool() const noexcept { - return start || success || failure || unwind || raise || raise_nested; + return ( start != 0 ) || ( success != 0 ) || ( failure != 0 ) || ( unwind != 0 ) || ( raise != 0 ) || ( raise_nested != 0 ); } }; diff --git a/include/tao/pegtl/debug/trace_action.hpp b/include/tao/pegtl/debug/trace_action.hpp index 13f9fa2cf..3a59ae4c8 100644 --- a/include/tao/pegtl/debug/trace_action.hpp +++ b/include/tao/pegtl/debug/trace_action.hpp @@ -2,8 +2,8 @@ // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#ifndef TAO_PEGTL_DEBUG_TRACE_HPP -#define TAO_PEGTL_DEBUG_TRACE_HPP +#ifndef TAO_PEGTL_DEBUG_TRACE_ACTION_HPP +#define TAO_PEGTL_DEBUG_TRACE_ACTION_HPP #include #include @@ -11,6 +11,7 @@ #include "../apply_mode.hpp" #include "../config.hpp" +#include "../match.hpp" #include "../nothing.hpp" #include "../rewind_mode.hpp" diff --git a/include/tao/pegtl/debug/trace_traits.hpp b/include/tao/pegtl/debug/trace_traits.hpp index f81b90589..ab76abda3 100644 --- a/include/tao/pegtl/debug/trace_traits.hpp +++ b/include/tao/pegtl/debug/trace_traits.hpp @@ -8,6 +8,8 @@ #include #include +#include "../normal.hpp" + namespace TAO_PEGTL_NAMESPACE { template< bool HideInternal = true, diff --git a/include/tao/pegtl/internal/action_input.hpp b/include/tao/pegtl/internal/action_input.hpp index 4b1a5051f..64e62f692 100644 --- a/include/tao/pegtl/internal/action_input.hpp +++ b/include/tao/pegtl/internal/action_input.hpp @@ -30,6 +30,8 @@ namespace TAO_PEGTL_NAMESPACE::internal action_input_impl( action_input_impl&& ) = delete; action_input_impl( const action_input_impl& ) = delete; + ~action_input_impl() = default; + void operator=( action_input_impl&& ) = delete; void operator=( const action_input_impl& ) = delete; diff --git a/include/tao/pegtl/internal/dummy_guard.hpp b/include/tao/pegtl/internal/dummy_guard.hpp index aac44fab0..b16f8a693 100644 --- a/include/tao/pegtl/internal/dummy_guard.hpp +++ b/include/tao/pegtl/internal/dummy_guard.hpp @@ -17,6 +17,8 @@ namespace TAO_PEGTL_NAMESPACE::internal dummy_guard( dummy_guard&& ) = delete; dummy_guard( const dummy_guard& ) = delete; + ~dummy_guard() = default; + void operator=( dummy_guard&& ) = delete; void operator=( const dummy_guard& ) = delete; diff --git a/include/tao/pegtl/internal/ione.hpp b/include/tao/pegtl/internal/ione.hpp index fc2b66fe3..1e67c36cc 100644 --- a/include/tao/pegtl/internal/ione.hpp +++ b/include/tao/pegtl/internal/ione.hpp @@ -21,7 +21,7 @@ namespace TAO_PEGTL_NAMESPACE::internal template< typename Data > [[nodiscard]] static constexpr bool test( const Data c ) noexcept { - return ( ascii_ichar_equal< Cs >( c ) || ... ) == true; + return ( ascii_ichar_equal< Cs >( c ) || ... ); } }; diff --git a/include/tao/pegtl/internal/lazy_scan_traits.hpp b/include/tao/pegtl/internal/lazy_scan_traits.hpp index fdf66056a..5a3ab5cf3 100644 --- a/include/tao/pegtl/internal/lazy_scan_traits.hpp +++ b/include/tao/pegtl/internal/lazy_scan_traits.hpp @@ -30,7 +30,7 @@ namespace TAO_PEGTL_NAMESPACE::internal pos.column = 1; continue; } - else if( const auto pair = Peek::peek( in ) ) { + if( const auto pair = Peek::peek( in ) ) { pos.column += pair.size(); in.template consume< void >( pair.size() ); continue; diff --git a/include/tao/pegtl/internal/mmap_input.hpp b/include/tao/pegtl/internal/mmap_input.hpp index b16a5dceb..c335cb42d 100644 --- a/include/tao/pegtl/internal/mmap_input.hpp +++ b/include/tao/pegtl/internal/mmap_input.hpp @@ -8,6 +8,8 @@ #include #include "../config.hpp" +#include "../count_position.hpp" +#include "../pointer_position.hpp" #include "mmap_file_base.hpp" #include "view_input.hpp" diff --git a/include/tao/pegtl/internal/not_ione.hpp b/include/tao/pegtl/internal/not_ione.hpp index 82cac1fc8..de5770103 100644 --- a/include/tao/pegtl/internal/not_ione.hpp +++ b/include/tao/pegtl/internal/not_ione.hpp @@ -23,7 +23,7 @@ namespace TAO_PEGTL_NAMESPACE::internal { using data_t = typename Peek::data_t; static_assert( sizeof( Data ) <= sizeof( data_t ) ); - return ( ascii_ichar_equal< Cs >( c ) || ... ) == false; + return !( ascii_ichar_equal< Cs >( c ) || ... ); } }; diff --git a/include/tao/pegtl/internal/not_one.hpp b/include/tao/pegtl/internal/not_one.hpp index 108da573c..2944b6142 100644 --- a/include/tao/pegtl/internal/not_one.hpp +++ b/include/tao/pegtl/internal/not_one.hpp @@ -22,7 +22,7 @@ namespace TAO_PEGTL_NAMESPACE::internal { using data_t = typename Peek::data_t; static_assert( sizeof( Data ) <= sizeof( data_t ) ); - return ( ( data_t( c ) == Cs ) || ... ) == false; + return !( ( data_t( c ) == Cs ) || ... ); } }; diff --git a/include/tao/pegtl/internal/not_range.hpp b/include/tao/pegtl/internal/not_range.hpp index b182d4cb8..dd1f038b7 100644 --- a/include/tao/pegtl/internal/not_range.hpp +++ b/include/tao/pegtl/internal/not_range.hpp @@ -24,7 +24,7 @@ namespace TAO_PEGTL_NAMESPACE::internal { using data_t = typename Peek::data_t; static_assert( sizeof( Data ) <= sizeof( data_t ) ); - return ( ( Lo <= data_t( c ) ) && ( data_t( c ) <= Hi ) ) == false; + return ( Lo > data_t( c ) ) || ( data_t( c ) > Hi ); } }; diff --git a/include/tao/pegtl/internal/peek_seven.hpp b/include/tao/pegtl/internal/peek_seven.hpp index f876bc1e1..a7774d26f 100644 --- a/include/tao/pegtl/internal/peek_seven.hpp +++ b/include/tao/pegtl/internal/peek_seven.hpp @@ -41,12 +41,12 @@ namespace TAO_PEGTL_NAMESPACE::internal static_assert( sizeof( data_t ) == sizeof( raw_t ) ); if( in.size( 1 + offset ) >= ( 1 + offset ) ) { - const data_t c = static_cast< data_t >( *in.current( offset ) ); + const auto c = static_cast< data_t >( *in.current( offset ) ); if( is_seven_value( c ) ) { - return pair_t( c, 1 ); + return { c, 1 }; } } - return pair_t(); + return {}; } }; diff --git a/include/tao/pegtl/internal/rematch_position.hpp b/include/tao/pegtl/internal/rematch_position.hpp index 883854692..0d7cd5460 100644 --- a/include/tao/pegtl/internal/rematch_position.hpp +++ b/include/tao/pegtl/internal/rematch_position.hpp @@ -11,7 +11,7 @@ namespace TAO_PEGTL_NAMESPACE::internal { template< typename Guard, typename Input, typename Data > - [[nodiscard]] auto rematch_position( Guard&, Input& in, const pointer_position< Data > saved ) + [[nodiscard]] auto rematch_position( Guard& /*unused*/, Input& in, const pointer_position< Data > saved ) { return in.previous_position( saved ); } diff --git a/include/tao/pegtl/internal/unicode_string.hpp b/include/tao/pegtl/internal/unicode_string.hpp index 143ac16ba..c6de8ab41 100644 --- a/include/tao/pegtl/internal/unicode_string.hpp +++ b/include/tao/pegtl/internal/unicode_string.hpp @@ -7,7 +7,9 @@ #include +#include "../apply_mode.hpp" #include "../config.hpp" +#include "../rewind_mode.hpp" #include "../type_list.hpp" #include "dependent_false.hpp" @@ -16,6 +18,7 @@ #include "peek_unicode.hpp" #include "peek_utf16.hpp" #include "peek_utf32.hpp" +#include "seq.hpp" #include "success.hpp" #include "utf32_to_utf8.hpp" diff --git a/include/tao/pegtl/internal/utf16_decode.hpp b/include/tao/pegtl/internal/utf16_decode.hpp index c794fae31..af16c8707 100644 --- a/include/tao/pegtl/internal/utf16_decode.hpp +++ b/include/tao/pegtl/internal/utf16_decode.hpp @@ -22,20 +22,20 @@ namespace TAO_PEGTL_NAMESPACE::internal const std::size_t size = in.size( s + s + offset ); if( size >= ( offset + s ) ) { - const char16_t t = Endian::template get< char16_t >( in.current( offset ) ); + const auto t = Endian::template get< char16_t >( in.current( offset ) ); if( !is_utf16_surrogate( t ) ) { - return char32_and_size( t, s ); + return { t, s }; } if( is_utf16_high_surrogate( t ) ) { if( size >= ( offset + s + s ) ) { - const char16_t u = Endian::template get< char16_t >( in.current( offset + s ) ); + const auto u = Endian::template get< char16_t >( in.current( offset + s ) ); if( is_utf16_low_surrogate( u ) ) { - return char32_and_size( utf16_compose( t, u ), s + s ); + return { utf16_compose( t, u ), s + s }; } } } } - return char32_and_size(); + return {}; } } // namespace TAO_PEGTL_NAMESPACE::internal diff --git a/include/tao/pegtl/internal/utf32_decode.hpp b/include/tao/pegtl/internal/utf32_decode.hpp index fa9db0123..9620401ca 100644 --- a/include/tao/pegtl/internal/utf32_decode.hpp +++ b/include/tao/pegtl/internal/utf32_decode.hpp @@ -24,10 +24,10 @@ namespace TAO_PEGTL_NAMESPACE::internal const char32_t t = Endian::template get< char32_t >( in.current( offset ) ); if( is_utf32( t ) ) { - return char32_and_size( t, s ); + return { t, s }; } } - return char32_and_size(); + return {}; } } // namespace TAO_PEGTL_NAMESPACE::internal diff --git a/include/tao/pegtl/internal/utf8_decode.hpp b/include/tao/pegtl/internal/utf8_decode.hpp index da864cffa..d6b8e116f 100644 --- a/include/tao/pegtl/internal/utf8_decode.hpp +++ b/include/tao/pegtl/internal/utf8_decode.hpp @@ -25,7 +25,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( size >= ( offset + 1 ) ) { const char32_t c0 = integer_adapt< std::uint8_t >( in.current( offset ) ); if( is_utf8_byte_1_of_1( c0 ) ) { - return char32_and_size( c0, 1 ); + return { c0, 1 }; } if( is_utf8_byte_1_of_2( c0 ) ) { if( size >= ( offset + 2 ) ) { @@ -33,7 +33,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( is_utf8_continuation( c1 ) ) { const char32_t c = utf8_compose( c0, c1 ); if( c >= 0x80 ) { - return char32_and_size( c, 2 ); + return { c, 2 }; } } } @@ -45,7 +45,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( is_utf8_continuation( c1 ) && is_utf8_continuation( c2 ) ) { const char32_t c = utf8_compose( c0, c1, c2 ); if( ( c >= 0x800 ) && ( !is_utf16_surrogate( c ) ) ) { - return char32_and_size( c, 3 ); + return { c, 3 }; } } } @@ -58,13 +58,13 @@ namespace TAO_PEGTL_NAMESPACE::internal if( is_utf8_continuation( c1 ) && is_utf8_continuation( c2 ) && is_utf8_continuation( c3 ) ) { const char32_t c = utf8_compose( c0, c1, c2, c3 ); if( ( c >= 0x10000 ) && ( c <= 0x10ffff ) ) { - return char32_and_size( c, 4 ); + return { c, 4 }; } } } } } - return char32_and_size(); + return {}; } } // namespace TAO_PEGTL_NAMESPACE::internal diff --git a/include/tao/pegtl/member.hpp b/include/tao/pegtl/member.hpp index c1e203e31..ef9540c0a 100644 --- a/include/tao/pegtl/member.hpp +++ b/include/tao/pegtl/member.hpp @@ -9,6 +9,7 @@ #include "internal/peek_member.hpp" #include "internal/rules.hpp" +#include "internal/using.hpp" namespace TAO_PEGTL_NAMESPACE::member { diff --git a/src/example/pegtl/cst.cpp b/src/example/pegtl/cst.cpp deleted file mode 100644 index bb099f708..000000000 --- a/src/example/pegtl/cst.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include -#include -#include - -#include -#include - -namespace TAO_PEGTL_NAMESPACE -{ - namespace cst - { - template< typename Data, typename Position > - struct node - { - Position pos; - std::string_view rule; - std::span< const Data > data; - std::vector< std::unique_ptr< node > > children; - }; - - namespace internal - { - template< typename Data, typename Position > - struct state - { - state() - { - stack.emplace_back( new node ); - } - - std::vector< std::size_t > rewind; - std::vector< std::unique_ptr< node > > stack; - }; - - template< typename Rule > - struct control - { - template< typename ParseInput, typename State > - static void prep_rewind( const ParseInput& /*unused*/, State& st ) - { - st.rewind.emplace_back( st.stack.size() ); - } - - template< typename ParseInput, typename State > - static void will_rewind( const ParseInput& /*unused*/, State& st ) - { - assert( !st.rewind.empty() ); - assert( st.stack.size() >= st.rewind.back() ); - st.stack.resize( st.rewind.back() ); - st.rewind.pop_back(); - } - - template< typename ParseInput, typename State > - static void wont_rewind( const ParseInput& /*unused*/, State& st ) - { - assert( !st.rewind.empty() ); - st.rewind.pop_back(); - } - }; - - } // namespace internal - - template< typename Rule, typename ParseInput > - [[nodiscard]] std::unique_ptr< typename ParseInput::data_t > parse( ParseInput& in ) - { - internal::state< typename ParseInput::data_t, typename ParseInput::error_position_t > st; - if( !TAO_PEGTL_NAMESPACE::parse< Rule, ..., rewind_control< control >::type >( in, st ) ) { - return nullptr; - } - assert( st.rewind.empty() ); - assert( st.stack.size() == 1 ); - return std::move( st.stack.back() ); - } - - } // namespace cst - - namespace ast - { - } // namespace ast - - namespace tst - { - } // namespace tst - -} // namespace TAO_PEGTL_NAMESPACE - -int main( int argc, char** argv ) -{ - return 0; -} diff --git a/src/example/pegtl/token_input_1.cpp b/src/example/pegtl/token_input_1.cpp index 2f517fb11..c359b0e06 100644 --- a/src/example/pegtl/token_input_1.cpp +++ b/src/example/pegtl/token_input_1.cpp @@ -11,7 +11,7 @@ #include -enum my_type +enum class my_type { alpha, beta, diff --git a/src/example/pegtl/token_input_2.cpp b/src/example/pegtl/token_input_2.cpp index 554fa0251..da5999038 100644 --- a/src/example/pegtl/token_input_2.cpp +++ b/src/example/pegtl/token_input_2.cpp @@ -10,7 +10,7 @@ #include #include -enum my_type +enum class my_type { alpha, beta, diff --git a/src/test/pegtl/icu_utf16_base.cpp b/src/test/pegtl/icu_utf16_base.cpp index 2e83514b9..cb47d969a 100644 --- a/src/test/pegtl/icu_utf16_base.cpp +++ b/src/test/pegtl/icu_utf16_base.cpp @@ -6,7 +6,7 @@ #include "verify_meta.hpp" #include "verify_rule.hpp" -#include +// #include namespace TAO_PEGTL_NAMESPACE { diff --git a/src/test/pegtl/icu_utf32_base.cpp b/src/test/pegtl/icu_utf32_base.cpp index 8e7ee67c7..a23285327 100644 --- a/src/test/pegtl/icu_utf32_base.cpp +++ b/src/test/pegtl/icu_utf32_base.cpp @@ -6,7 +6,7 @@ #include "verify_meta.hpp" #include "verify_rule.hpp" -#include +// #include namespace TAO_PEGTL_NAMESPACE { diff --git a/src/test/pegtl/icu_utf8_base.cpp b/src/test/pegtl/icu_utf8_base.cpp index 59365fd7a..4eb95bf07 100644 --- a/src/test/pegtl/icu_utf8_base.cpp +++ b/src/test/pegtl/icu_utf8_base.cpp @@ -6,7 +6,7 @@ #include "verify_meta.hpp" #include "verify_rule.hpp" -#include +// #include namespace TAO_PEGTL_NAMESPACE {