Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed May 19, 2017
1 parent 4094371 commit 9ecebfe
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
5 changes: 3 additions & 2 deletions include/tao/json/internal/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef TAOCPP_JSON_INCLUDE_INTERNAL_ACTION_HPP
#define TAOCPP_JSON_INCLUDE_INTERNAL_ACTION_HPP

#include "../external/pegtl/contrib/changes.hpp"
#include "../external/pegtl/nothing.hpp"

#include "errors.hpp"
#include "grammar.hpp"
Expand All @@ -18,7 +18,8 @@ namespace tao
namespace internal
{
template< typename Rule >
struct action : json_pegtl::nothing< Rule >
struct action
: json_pegtl::nothing< Rule >
{
};

Expand Down
12 changes: 8 additions & 4 deletions include/tao/json/internal/control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@ namespace tao
namespace internal
{
template< typename Rule >
struct control : errors< Rule >
struct control
: errors< Rule >
{
};

template<>
struct control< rules::number > : json_pegtl::change_state< rules::number, number_state, errors >
struct control< rules::number >
: json_pegtl::change_state< rules::number, number_state, errors >
{
};

template<>
struct control< rules::string::content > : json_pegtl::change_state_and_action< rules::string::content, string_state, unescape_action, errors >
struct control< rules::string::content >
: json_pegtl::change_state_and_action< rules::string::content, string_state, unescape_action, errors >
{
};

template<>
struct control< rules::key::content > : json_pegtl::change_state_and_action< rules::key::content, key_state, unescape_action, errors >
struct control< rules::key::content >
: json_pegtl::change_state_and_action< rules::key::content, key_state, unescape_action, errors >
{
};

Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/internal/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace tao
{
template< typename Rule >
struct errors
: public json_pegtl::normal< Rule >
: json_pegtl::normal< Rule >
{
static const std::string error_message;

Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/sax/from_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ namespace tao
template< typename Consumer >
inline void from_stream( std::istream& stream, Consumer& consumer, const char* source = nullptr, const std::size_t maximum_buffer_size = 4000 )
{
json_pegtl::istream_input<> input( stream, maximum_buffer_size, source ? source : "tao::json::sax::from_stream" );
json_pegtl::parse< internal::grammar, internal::action, internal::control >( input, consumer );
json_pegtl::istream_input<> in( stream, maximum_buffer_size, source ? source : "tao::json::sax::from_stream" );
json_pegtl::parse< internal::grammar, internal::action, internal::control >( in, consumer );
}

template< typename Consumer >
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/sax/from_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace tao
template< typename Consumer >
inline void from_string( const char* data, const std::size_t size, Consumer& consumer, const char* source = nullptr, const std::size_t byte = 0, const std::size_t line = 1, const std::size_t column = 0 )
{
json_pegtl::memory_input< json_pegtl::tracking_mode::LAZY, json_pegtl::eol::lf_crlf, const char* > input( data, data + size, source ? source : "tao::json::sax::from_string", byte, line, column );
json_pegtl::parse< internal::grammar, internal::action, internal::control >( input, consumer );
json_pegtl::memory_input< json_pegtl::tracking_mode::LAZY, json_pegtl::eol::lf_crlf, const char* > in( data, data + size, source ? source : "tao::json::sax::from_string", byte, line, column );
json_pegtl::parse< internal::grammar, internal::action, internal::control >( in, consumer );
}

template< typename Consumer >
Expand Down
21 changes: 14 additions & 7 deletions include/tao/json/schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,36 @@ namespace tao
namespace internal
{
// TODO: Check if these grammars are correct.
struct local_part_label : json_pegtl::plus< json_pegtl::sor< json_pegtl::alnum, json_pegtl::one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '/', '=', '?', '^', '_', '`', '{', '|', '}', '~' > > >
struct local_part_label
: json_pegtl::plus< json_pegtl::sor< json_pegtl::alnum, json_pegtl::one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '/', '=', '?', '^', '_', '`', '{', '|', '}', '~' > > >
{
};
struct local_part : json_pegtl::list_must< local_part_label, json_pegtl::one< '.' > >

struct local_part
: json_pegtl::list_must< local_part_label, json_pegtl::one< '.' > >
{
};

struct hostname_label : json_pegtl::seq< json_pegtl::alnum, json_pegtl::rep_max< 62, json_pegtl::ranges< 'a', 'z', 'A', 'Z', '0', '9', '-' > > >
struct hostname_label
: json_pegtl::seq< json_pegtl::alnum, json_pegtl::rep_max< 62, json_pegtl::ranges< 'a', 'z', 'A', 'Z', '0', '9', '-' > > >
{
};
struct hostname : json_pegtl::list_must< hostname_label, json_pegtl::one< '.' > >

struct hostname
: json_pegtl::list_must< hostname_label, json_pegtl::one< '.' > >
{
};

struct email : json_pegtl::seq< local_part, json_pegtl::one< '@' >, hostname >
struct email
: json_pegtl::seq< local_part, json_pegtl::one< '@' >, hostname >
{
};

template< typename Rule >
bool parse( const std::string& v )
{
json_pegtl::memory_input<> input( v, "" );
return json_pegtl::parse< json_pegtl::seq< Rule, json_pegtl::eof > >( input );
json_pegtl::memory_input<> in( v, "" );
return json_pegtl::parse< json_pegtl::seq< Rule, json_pegtl::eof > >( in );
}

inline bool parse_date_time( const std::string& v )
Expand Down

0 comments on commit 9ecebfe

Please sign in to comment.