Sha256: c4328c010431907b380baa18bf94f54be7336862304b5aad17db5969ff81fa8e

Contents?: true

Size: 1.74 KB

Versions: 13

Compression:

Stored size: 1.74 KB

Contents

// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#ifndef TAO_PEGTL_CONTRIB_PRINT_HPP
#define TAO_PEGTL_CONTRIB_PRINT_HPP

#include <ostream>

#include "../config.hpp"
#include "../demangle.hpp"
#include "../type_list.hpp"
#include "../visit.hpp"

namespace TAO_PEGTL_NAMESPACE
{
   namespace internal
   {
      template< typename Name >
      struct print_names
      {
         static void visit( std::ostream& os )
         {
            os << demangle< Name >() << '\n';
         }
      };

      template< typename Name >
      struct print_debug
      {
         static void visit( std::ostream& os )
         {
            const auto first = demangle< Name >();
            os << first << '\n';

            const auto second = demangle< typename Name::rule_t >();
            if( first != second ) {
               os << " (aka) " << second << '\n';
            }

            print_subs( os, typename Name::subs_t() );

            os << '\n';
         }

      private:
         template< typename... Rules >
         static void print_subs( std::ostream& os, type_list< Rules... > /*unused*/ )
         {
            ( print_sub< Rules >( os ), ... );
         }

         template< typename Rule >
         static void print_sub( std::ostream& os )
         {
            os << " (sub) " << demangle< Rule >() << '\n';
         }
      };

   }  // namespace internal

   template< typename Grammar >
   void print_names( std::ostream& os )
   {
      visit< Grammar, internal::print_names >( os );
   }

   template< typename Grammar >
   void print_debug( std::ostream& os )
   {
      visit< Grammar, internal::print_debug >( os );
   }

}  // namespace TAO_PEGTL_NAMESPACE

#endif

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
couchbase-3.5.6 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.5.5 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.5.4 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.5.3 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.5.2 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.5.1 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.5.0 ext/cache/json/4c7c23ac69aa1d72b3a9295ac9aceac10d32d9a1/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.4.5 ext/couchbase/third_party/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.4.4 ext/couchbase/third_party/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.4.3 ext/couchbase/third_party/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.4.2 ext/couchbase/third_party/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.4.1 ext/couchbase/third_party/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp
couchbase-3.4.0 ext/couchbase/third_party/json/external/PEGTL/include/tao/pegtl/contrib/print.hpp