Skip to content

Commit

Permalink
Update embedded PEGTL
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Nov 21, 2020
1 parent f357d72 commit d7ece90
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 42 deletions.
90 changes: 53 additions & 37 deletions include/tao/json/external/pegtl/contrib/icu/internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,77 @@

#include <unicode/uchar.h>

#include "../analyze_traits.hpp"

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

#include "../../internal/enable_control.hpp"

namespace TAO_JSON_PEGTL_NAMESPACE::internal
namespace TAO_JSON_PEGTL_NAMESPACE
{
namespace icu
namespace internal
{
template< typename Peek, UProperty P, bool V = true >
struct binary_property
namespace icu
{
using rule_t = binary_property;
using subs_t = empty_list;

template< typename ParseInput >
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
template< typename Peek, UProperty P, bool V = true >
struct binary_property
{
if( const auto r = Peek::peek( in ) ) {
if( u_hasBinaryProperty( r.data, P ) == V ) {
in.bump( r.size );
return true;
using rule_t = binary_property;
using subs_t = empty_list;

template< typename ParseInput >
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
{
if( const auto r = Peek::peek( in ) ) {
if( u_hasBinaryProperty( r.data, P ) == V ) {
in.bump( r.size );
return true;
}
}
return false;
}
return false;
}
};

template< typename Peek, UProperty P, int V >
struct property_value
{
using rule_t = property_value;
using subs_t = empty_list;
};

template< typename ParseInput >
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
template< typename Peek, UProperty P, int V >
struct property_value
{
if( const auto r = Peek::peek( in ) ) {
if( u_getIntPropertyValue( r.data, P ) == V ) {
in.bump( r.size );
return true;
using rule_t = property_value;
using subs_t = empty_list;

template< typename ParseInput >
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
{
if( const auto r = Peek::peek( in ) ) {
if( u_getIntPropertyValue( r.data, P ) == V ) {
in.bump( r.size );
return true;
}
}
return false;
}
return false;
}
};
};

} // namespace icu

template< typename Peek, UProperty P, bool V >
inline constexpr bool enable_control< icu::binary_property< Peek, P, V > > = false;

template< typename Peek, UProperty P, int V >
inline constexpr bool enable_control< icu::property_value< Peek, P, V > > = false;

} // namespace icu
} // namespace internal

template< typename Peek, UProperty P, bool V >
inline constexpr bool enable_control< icu::binary_property< Peek, P, V > > = false;
template< typename Name, typename Peek, UProperty P, bool V >
struct analyze_traits< Name, internal::icu::binary_property< Peek, P, V > >
: analyze_any_traits<>
{};

template< typename Peek, UProperty P, int V >
inline constexpr bool enable_control< icu::property_value< Peek, P, V > > = false;
template< typename Name, typename Peek, UProperty P, int V >
struct analyze_traits< Name, internal::icu::property_value< Peek, P, V > >
: analyze_any_traits<>
{};

} // namespace TAO_JSON_PEGTL_NAMESPACE::internal
} // namespace TAO_JSON_PEGTL_NAMESPACE

#endif
9 changes: 5 additions & 4 deletions include/tao/json/external/pegtl/contrib/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ namespace TAO_JSON_PEGTL_NAMESPACE::json
using content = array_content;
};

struct member : if_must< key, name_separator, value > {};
struct member_value : padr< value > {};
struct member : if_must< key, name_separator, member_value > {};
struct object_content : opt< list_must< member, value_separator > > {};
struct object : seq< begin_object, object_content, must< end_object > >
{
Expand All @@ -77,10 +78,10 @@ namespace TAO_JSON_PEGTL_NAMESPACE::json
using content = object_content;
};

struct value : padr< sor< string, number, object, array, false_, true_, null > > {};
struct array_element : seq< value > {};
struct value : sor< string, number, object, array, false_, true_, null > {};
struct array_element : padr< value > {};

struct text : seq< star< ws >, value > {};
struct text : pad< value, ws > {};
// clang-format on

} // namespace TAO_JSON_PEGTL_NAMESPACE::json
Expand Down
2 changes: 2 additions & 0 deletions include/tao/json/external/pegtl/contrib/parse_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ namespace TAO_JSON_PEGTL_NAMESPACE::parse_tree
struct make_control< Node, Selector, Control >::state_handler< Rule, false, false >
: remove_first_state< Control< Rule > >
{
static constexpr bool enable = true;

template< typename ParseInput, typename... States >
static void start( const ParseInput& /*unused*/, state< Node >& state, States&&... /*unused*/ )
{
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/external/pegtl/internal/file_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace TAO_JSON_PEGTL_NAMESPACE::internal
throw std::filesystem::filesystem_error( "_wfopen_s() failed", path, ec );
#else
#if defined( __MINGW32__ )
if( auto* file = std::fopen( path.c_str(), "rb" ) )
if( auto* file = std::fopen( path.string().c_str(), "rb" ) )
#else
if( auto* file = std::fopen( path.c_str(), "rbe" ) )
#endif
Expand Down

0 comments on commit d7ece90

Please sign in to comment.