Skip to content

Commit 7f37826

Browse files
committed
Update PEGTL.
1 parent 6d62612 commit 7f37826

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1233
-1101
lines changed

include/tao/json/external/pegtl.hpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@
1313
#include "pegtl/utf32.hpp"
1414
#include "pegtl/utf8.hpp"
1515

16+
#include "pegtl/parse.hpp"
17+
18+
#include "pegtl/buffer_input.hpp"
19+
#include "pegtl/file_input.hpp"
20+
#include "pegtl/memory_input.hpp"
21+
#include "pegtl/read_input.hpp"
22+
#include "pegtl/stream_input.hpp"
23+
#include "pegtl/string_input.hpp"
24+
1625
// The following files can be included whenever needed; they
17-
// are not included by default because they include <iostream>.
18-
// #include "pegtl/trace.hpp"
19-
// #include "pegtl/analyze.hpp"
26+
// are not included by default because they include a stream header
27+
// like <iostream> or <sstream>.
2028

21-
#include "pegtl/file_parser.hpp"
22-
#include "pegtl/string_parser.hpp"
29+
// #include "pegtl/argv_input.hpp"
30+
// #include "pegtl/analyze.hpp"
31+
// #include "pegtl/tracer.hpp"
2332

2433
#endif

include/tao/json/external/pegtl/analysis/analyze_cycles.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace tao
2626
class analyze_cycles_impl
2727
{
2828
protected:
29-
explicit analyze_cycles_impl( const bool verbose )
29+
explicit analyze_cycles_impl( const bool verbose ) noexcept
3030
: m_verbose( verbose ),
3131
m_problems( 0 )
3232
{
@@ -39,7 +39,7 @@ namespace tao
3939
std::map< std::string, bool > m_cache;
4040
std::map< std::string, bool > m_results;
4141

42-
const std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const
42+
const std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const noexcept
4343
{
4444
const auto iter = m_info.map.find( name );
4545
assert( iter != m_info.map.end() );
@@ -117,7 +117,7 @@ namespace tao
117117
}
118118

119119
template< typename Rule >
120-
bool consumes() const
120+
bool consumes() const noexcept
121121
{
122122
const auto i = m_results.find( internal::demangle< Rule >() );
123123
assert( i != m_results.end() );

include/tao/json/external/pegtl/analysis/insert_guard.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace tao
4141
insert_guard( const insert_guard& ) = delete;
4242
void operator=( const insert_guard& ) = delete;
4343

44-
explicit operator bool() const
44+
explicit operator bool() const noexcept
4545
{
4646
return m_i.second;
4747
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2+
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3+
4+
#ifndef TAOCPP_JSON_PEGTL_INCLUDE_ARGV_INPUT_HPP
5+
#define TAOCPP_JSON_PEGTL_INCLUDE_ARGV_INPUT_HPP
6+
7+
#include <cstddef>
8+
#include <sstream>
9+
#include <string>
10+
#include <utility>
11+
12+
#include "config.hpp"
13+
#include "eol.hpp"
14+
#include "memory_input.hpp"
15+
#include "tracking_mode.hpp"
16+
17+
namespace tao
18+
{
19+
namespace TAOCPP_JSON_PEGTL_NAMESPACE
20+
{
21+
namespace internal
22+
{
23+
inline std::string make_argv_source( const std::size_t argn )
24+
{
25+
std::ostringstream os;
26+
os << "argv[" << argn << ']';
27+
return os.str();
28+
}
29+
30+
struct argv_holder
31+
{
32+
const std::string argv_source;
33+
34+
template< typename T >
35+
explicit argv_holder( T&& in_argv_source )
36+
: argv_source( std::forward< T >( in_argv_source ) )
37+
{
38+
}
39+
};
40+
41+
} // namespace internal
42+
43+
template< typename Eol = lf_crlf_eol, tracking_mode P = tracking_mode::IMMEDIATE >
44+
struct argv_input
45+
: private internal::argv_holder,
46+
public memory_input< Eol, P >
47+
{
48+
template< typename T >
49+
argv_input( char** argv, const std::size_t argn, T&& in_source )
50+
: internal::argv_holder( std::forward< T >( in_source ) ),
51+
memory_input< Eol, P >( static_cast< const char* >( argv[ argn ] ), argv_source )
52+
{
53+
}
54+
55+
argv_input( char** argv, const std::size_t argn )
56+
: argv_input( argv, argn, internal::make_argv_source( argn ) )
57+
{
58+
}
59+
};
60+
61+
} // namespace TAOCPP_JSON_PEGTL_NAMESPACE
62+
63+
} // namespace tao
64+
65+
#endif

include/tao/json/external/pegtl/ascii.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,30 @@ namespace tao
1515
inline namespace ascii
1616
{
1717
// clang-format off
18-
struct alnum : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z', '0', '9' > {};
19-
struct alpha : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {};
18+
struct alnum : internal::alnum {};
19+
struct alpha : internal::alpha {};
2020
struct any : internal::any< internal::peek_char > {};
2121
struct blank : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > {};
2222
struct digit : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, '0', '9' > {};
2323
struct eol : internal::eol {};
2424
struct eolf : internal::eolf {};
25-
struct identifier_first : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z', '_' > {};
26-
struct identifier_other : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z', '0', '9', '_' > {};
27-
struct identifier : internal::seq< identifier_first, internal::star< identifier_other > > {};
28-
template< char ... Cs > struct istring : internal::istring< Cs ... > {};
25+
struct identifier_first : internal::identifier_first {};
26+
struct identifier_other : internal::identifier_other {};
27+
struct identifier : internal::identifier {};
28+
template< char... Cs > struct istring : internal::istring< Cs... > {};
29+
template< char C, char... Cs > struct keyword : internal::seq< internal::string< C, Cs... >, internal::not_at< internal::identifier_other > > {};
2930
struct lower : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, 'a', 'z' > {};
30-
template< char ... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_char, Cs ... > {};
31+
template< char... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_char, Cs... > {};
3132
template< char Lo, char Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_char, Lo, Hi > {};
3233
struct nul : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, char( 0 ) > {};
33-
template< char ... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, Cs ... > {};
34+
template< char... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, Cs... > {};
3435
struct print : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 32 ), char( 126 ) > {};
3536
template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, Lo, Hi > {};
36-
template< char ... Cs > struct ranges : internal::ranges< internal::peek_char, Cs ... > {};
37+
template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {};
3738
struct seven : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 0 ), char( 127 ) > {};
3839
struct shebang : internal::if_must< internal::string< '#', '!' >, internal::until< internal::eolf > > {};
3940
struct space : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {};
40-
template< char ... Cs > struct string : internal::string< Cs ... > {};
41+
template< char... Cs > struct string : internal::string< Cs... > {};
4142
template< char C > struct two : internal::string< C, C > {};
4243
struct upper : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, 'A', 'Z' > {};
4344
struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};

include/tao/json/external/pegtl/buffer_input.hpp

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,32 @@
99
#include <memory>
1010

1111
#include "config.hpp"
12-
#include "count_data.hpp"
1312
#include "eol.hpp"
13+
#include "memory_input.hpp"
14+
#include "position.hpp"
15+
#include "tracking_mode.hpp"
16+
1417
#include "internal/action_input.hpp"
1518
#include "internal/bump_impl.hpp"
16-
#include "internal/input_mark.hpp"
17-
#include "position_info.hpp"
19+
#include "internal/iterator.hpp"
20+
#include "internal/marker.hpp"
1821

1922
namespace tao
2023
{
2124
namespace TAOCPP_JSON_PEGTL_NAMESPACE
2225
{
23-
template< typename Eol >
24-
class basic_memory_input;
25-
26-
template< typename Eol, typename Reader >
27-
class basic_buffer_input
26+
template< typename Reader, typename Eol = lf_crlf_eol >
27+
class buffer_input
2828
{
2929
public:
30-
using eol_t = Eol;
3130
using reader_t = Reader;
32-
using action_t = internal::basic_action_input< Eol >;
33-
using memory_t = basic_memory_input< Eol >;
31+
using eol_t = Eol;
32+
33+
using memory_t = memory_input< Eol >;
34+
using action_t = internal::action_input< Eol, tracking_mode::IMMEDIATE >;
3435

3536
template< typename... As >
36-
basic_buffer_input( const char* in_source, const std::size_t maximum, As&&... as )
37+
buffer_input( const char* in_source, const std::size_t maximum, As&&... as )
3738
: m_reader( std::forward< As >( as )... ),
3839
m_maximum( maximum ),
3940
m_buffer( new char[ maximum ] ),
@@ -43,8 +44,14 @@ namespace tao
4344
{
4445
}
4546

46-
basic_buffer_input( const basic_buffer_input& ) = delete;
47-
void operator=( const basic_buffer_input& ) = delete;
47+
template< typename... As >
48+
buffer_input( const std::string& in_source, As&&... as )
49+
: buffer_input( in_source.c_str(), std::forward< As >( as )... )
50+
{
51+
}
52+
53+
buffer_input( const buffer_input& ) = delete;
54+
void operator=( const buffer_input& ) = delete;
4855

4956
bool empty()
5057
{
@@ -58,7 +65,7 @@ namespace tao
5865
return std::size_t( m_end - m_data.data );
5966
}
6067

61-
const char* begin() const
68+
const char* begin() const noexcept
6269
{
6370
return m_data.data;
6471
}
@@ -69,52 +76,52 @@ namespace tao
6976
return m_end;
7077
}
7178

72-
std::size_t byte() const
79+
std::size_t byte() const noexcept
7380
{
7481
return m_data.byte;
7582
}
7683

77-
std::size_t line() const
84+
std::size_t line() const noexcept
7885
{
7986
return m_data.line;
8087
}
8188

82-
std::size_t byte_in_line() const
89+
std::size_t byte_in_line() const noexcept
8390
{
8491
return m_data.byte_in_line;
8592
}
8693

87-
const char* source() const
94+
const char* source() const noexcept
8895
{
8996
return m_source;
9097
}
9198

92-
char peek_char( const std::size_t offset = 0 ) const
99+
char peek_char( const std::size_t offset = 0 ) const noexcept
93100
{
94101
return m_data.data[ offset ];
95102
}
96103

97-
unsigned char peek_byte( const std::size_t offset = 0 ) const
104+
unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept
98105
{
99106
return static_cast< unsigned char >( peek_char( offset ) );
100107
}
101108

102-
void bump( const std::size_t in_count = 1 )
109+
void bump( const std::size_t in_count = 1 ) noexcept
103110
{
104111
internal::bump( m_data, in_count, Eol::ch );
105112
}
106113

107-
void bump_in_this_line( const std::size_t in_count = 1 )
114+
void bump_in_this_line( const std::size_t in_count = 1 ) noexcept
108115
{
109116
internal::bump_in_this_line( m_data, in_count );
110117
}
111118

112-
void bump_to_next_line( const std::size_t in_count = 1 )
119+
void bump_to_next_line( const std::size_t in_count = 1 ) noexcept
113120
{
114121
internal::bump_to_next_line( m_data, in_count );
115122
}
116123

117-
void discard()
124+
void discard() noexcept
118125
{
119126
const auto s = m_end - m_data.data;
120127
std::memmove( m_buffer.get(), m_data.data, s );
@@ -137,17 +144,17 @@ namespace tao
137144
}
138145

139146
template< rewind_mode M >
140-
internal::input_mark< M > mark()
147+
internal::marker< internal::iterator, M > mark() noexcept
141148
{
142-
return internal::input_mark< M >( m_data );
149+
return internal::marker< internal::iterator, M >( m_data );
143150
}
144151

145-
position_info position() const
152+
TAOCPP_JSON_PEGTL_NAMESPACE::position position() const noexcept
146153
{
147-
return position_info( m_data, m_source );
154+
return TAOCPP_JSON_PEGTL_NAMESPACE::position( m_data, m_source );
148155
}
149156

150-
const count_data& count() const
157+
const internal::iterator& iterator() const noexcept
151158
{
152159
return m_data;
153160
}
@@ -156,14 +163,11 @@ namespace tao
156163
Reader m_reader;
157164
std::size_t m_maximum;
158165
std::unique_ptr< char[] > m_buffer;
159-
count_data m_data;
166+
internal::iterator m_data;
160167
const char* m_end;
161-
const char* m_source;
168+
const char* const m_source;
162169
};
163170

164-
template< typename Reader >
165-
using buffer_input = basic_buffer_input< lf_crlf_eol, Reader >;
166-
167171
} // namespace TAOCPP_JSON_PEGTL_NAMESPACE
168172

169173
} // namespace tao

include/tao/json/external/pegtl/contrib/changes.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace tao
1818
struct dummy_disabled_state
1919
{
2020
template< typename... Ts >
21-
void success( Ts&&... )
21+
void success( Ts&&... ) const noexcept
2222
{
2323
}
2424
};

0 commit comments

Comments
 (0)