mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 11:21:41 +00:00
PEGTL 2.x->3.x
This commit is contained in:
parent
d5faac7614
commit
dcab2833b8
common
include
thirdparty/pegtl
LICENSELICENSE_1_0.txtpegtl.hpp
pegtl
apply_mode.hppargv_input.hppascii.hppbuffer_input.hppchange_action.hppchange_action_and_state.hppchange_action_and_states.hppchange_control.hppchange_state.hppchange_states.hppconfig.hpp
contrib
abnf.hppadd_state.hppalphabet.hppanalyze.hppanalyze_traits.hppcheck_bytes.hppcontrol_action.hppcoverage.hppforward.hppfunction.hpphttp.hpp
cstream_input.hppdemangle.hppdisable_action.hppdiscard_input.hppdiscard_input_on_failure.hppdiscard_input_on_success.hppenable_action.hppeol.hppfile_input.hppicu
if_then.hppinstantiate.hppinteger.hppinternal
endian.hppendian_gcc.hppendian_win.hpppeek_mask_uint.hpppeek_mask_uint8.hpppeek_uint.hpppeek_uint8.hpppeek_utf16.hpppeek_utf32.hppread_uint.hppset_stack_guard.hppvector_stack_guard.hpp
iri.hppjson.hppjson_pointer.hpplimit_bytes.hpplimit_depth.hppparse_tree.hppparse_tree_to_dot.hpppredicates.hppprint.hppprint_coverage.hppproto3.hppraw_string.hppremove_first_state.hppremove_last_states.hpprep_one_min_max.hpprep_string.hppseparated_seq.hppshuffle_states.hppstate_control.hppto_string.hpptrace.hppuint16.hppuint32.hppuint64.hppuint8.hppunescape.hppuri.hpputf16.hpputf32.hppinternal
action.hppaction_input.hppany.hppapply.hppapply0.hppapply0_single.hppapply_single.hppat.hppbof.hppbol.hppbump.hppbump_help.hppbytes.hppcontrol.hppcr_crlf_eol.hppcr_eol.hppcrlf_eol.hppcstream_reader.hppcstring_reader.hppdependent_false.hppdisable.hppdiscard.hppenable.hppenable_control.hppeof.hppeol.hppeol_pair.hppeolf.hppfailure.hppfile_mapper_posix.hppfile_mapper_win32.hppfile_reader.hppfilesystem.hpphas_apply.hpphas_apply0.hpphas_error_message.hpphas_match.hpphas_unwind.hppidentifier.hppif_apply.hppif_must.hppif_must_else.hppif_then_else.hppinput_pair.hppistream_reader.hppistring.hppiterator.hpplf_crlf_eol.hpplf_eol.hpplist.hpplist_must.hpplist_tail.hpplist_tail_pad.hppmarker.hppminus.hppmissing_apply.hppmissing_apply0.hppmust.hppnot_at.hppone.hppopt.hpppad.hpppad_opt.hpppath_to_string.hpppeek_char.hpppeek_utf8.hpppegtl_string.hppplus.hppraise.hpprange.hppranges.hpprematch.hpprep.hpprep_min.hpprep_min_max.hpprep_opt.hpprequire.hppresult_on_found.hpprules.hppseq.hppsor.hppstar.hppstar_must.hppstate.hppstring.hppsuccess.hpptry_catch_type.hppuntil.hpp
istream_input.hppmatch.hppmemory_input.hppmmap_input.hppmust_if.hppnormal.hppnothing.hppparse.hppparse_error.hppposition.hppread_input.hpprequire_apply.hpprequire_apply0.hpprewind_mode.hpprules.hppstring_input.hpptracking_mode.hpptype_list.hpputf8.hppversion.hppvisit.hpp@ -37,13 +37,13 @@ std::string NODE::typeString() const
|
||||
{
|
||||
std::stringstream os;
|
||||
|
||||
if( is<MARKUP::subscript>() ) os << "SUBSCRIPT";
|
||||
else if( is<MARKUP::superscript>() ) os << "SUPERSCRIPT";
|
||||
else if( is<MARKUP::anyString>() ) os << "ANYSTRING";
|
||||
else if( is<MARKUP::anyStringWithinBraces>() ) os << "ANYSTRINGWITHINBRACES";
|
||||
else if( is<MARKUP::varNamespaceName>() ) os << "VARNAMESPACENAME";
|
||||
else if( is<MARKUP::varName>() ) os << "VARNAME";
|
||||
else os << "other";
|
||||
if( is_type<MARKUP::subscript>() ) os << "SUBSCRIPT";
|
||||
else if( is_type<MARKUP::superscript>() ) os << "SUPERSCRIPT";
|
||||
else if( is_type<MARKUP::anyString>() ) os << "ANYSTRING";
|
||||
else if( is_type<MARKUP::anyStringWithinBraces>() ) os << "ANYSTRINGWITHINBRACES";
|
||||
else if( is_type<MARKUP::varNamespaceName>() ) os << "VARNAMESPACENAME";
|
||||
else if( is_type<MARKUP::varName>() ) os << "VARNAME";
|
||||
else os << "other";
|
||||
|
||||
return os.str();
|
||||
}
|
||||
@ -53,7 +53,7 @@ std::string NODE::asString() const
|
||||
{
|
||||
std::stringstream os;
|
||||
|
||||
os << name(); // << "{" << typeString() << "}";
|
||||
os << type;
|
||||
|
||||
if( has_content() )
|
||||
os << " \"" << string() << "\"";
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define MARKUP_PARSER_H
|
||||
|
||||
#include <pegtl.hpp>
|
||||
#include <pegtl/contrib/parse_tree.hpp>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utf8.h>
|
||||
@ -41,9 +42,9 @@ struct NODE : parse_tree::basic_node<NODE>
|
||||
|
||||
std::string typeString() const;
|
||||
|
||||
bool isOverbar() const { return is<MARKUP::overbar>(); }
|
||||
bool isSubscript() const { return is<MARKUP::subscript>(); }
|
||||
bool isSuperscript() const { return is<MARKUP::superscript>(); }
|
||||
bool isOverbar() const { return is_type<MARKUP::overbar>(); }
|
||||
bool isSubscript() const { return is_type<MARKUP::subscript>(); }
|
||||
bool isSuperscript() const { return is_type<MARKUP::superscript>(); }
|
||||
};
|
||||
|
||||
struct varPrefix : string<'$', '{'> {};
|
||||
|
21
thirdparty/pegtl/LICENSE
vendored
21
thirdparty/pegtl/LICENSE
vendored
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007-2020 Dr. Colin Hirsch and Daniel Frey
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
23
thirdparty/pegtl/LICENSE_1_0.txt
vendored
Normal file
23
thirdparty/pegtl/LICENSE_1_0.txt
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
12481
thirdparty/pegtl/pegtl.hpp
vendored
12481
thirdparty/pegtl/pegtl.hpp
vendored
File diff suppressed because it is too large
Load Diff
20
thirdparty/pegtl/pegtl/apply_mode.hpp
vendored
Normal file
20
thirdparty/pegtl/pegtl/apply_mode.hpp
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_APPLY_MODE_HPP
|
||||
#define TAO_PEGTL_APPLY_MODE_HPP
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
enum class apply_mode : bool
|
||||
{
|
||||
action = true,
|
||||
nothing = false
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
50
thirdparty/pegtl/pegtl/argv_input.hpp
vendored
Normal file
50
thirdparty/pegtl/pegtl/argv_input.hpp
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_ARGV_INPUT_HPP
|
||||
#define TAO_PEGTL_ARGV_INPUT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "eol.hpp"
|
||||
#include "memory_input.hpp"
|
||||
#include "tracking_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
[[nodiscard]] inline std::string make_argv_source( const std::size_t argn )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "argv[" << argn << ']';
|
||||
return std::move( oss ).str();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf >
|
||||
struct argv_input
|
||||
: memory_input< P, Eol >
|
||||
{
|
||||
template< typename T >
|
||||
argv_input( char** argv, const std::size_t argn, T&& in_source )
|
||||
: memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) )
|
||||
{}
|
||||
|
||||
argv_input( char** argv, const std::size_t argn )
|
||||
: argv_input( argv, argn, internal::make_argv_source( argn ) )
|
||||
{}
|
||||
};
|
||||
|
||||
template< typename... Ts >
|
||||
argv_input( Ts&&... ) -> argv_input<>;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
55
thirdparty/pegtl/pegtl/ascii.hpp
vendored
Normal file
55
thirdparty/pegtl/pegtl/ascii.hpp
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_ASCII_HPP
|
||||
#define TAO_PEGTL_ASCII_HPP
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
#include "internal/result_on_found.hpp"
|
||||
#include "internal/rules.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
inline namespace ascii
|
||||
{
|
||||
// clang-format off
|
||||
struct alnum : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z', '0', '9' > {};
|
||||
struct alpha : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {};
|
||||
struct any : internal::any< internal::peek_char > {};
|
||||
struct blank : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {};
|
||||
struct digit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {};
|
||||
struct ellipsis : internal::string< '.', '.', '.' > {};
|
||||
template< char... Cs > struct forty_two : internal::rep< 42, internal::one< internal::result_on_found::success, internal::peek_char, Cs... > > {};
|
||||
struct identifier_first : internal::identifier_first {};
|
||||
struct identifier_other : internal::identifier_other {};
|
||||
struct identifier : internal::identifier {};
|
||||
template< char... Cs > struct istring : internal::istring< Cs... > {};
|
||||
template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > { static_assert( sizeof...( Cs ) > 0 ); };
|
||||
struct lower : internal::range< internal::result_on_found::success, internal::peek_char, 'a', 'z' > {};
|
||||
template< char... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_char, Cs... > {};
|
||||
template< char Lo, char Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_char, Lo, Hi > {};
|
||||
struct nul : internal::one< internal::result_on_found::success, internal::peek_char, char( 0 ) > {};
|
||||
struct odigit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '7' > {};
|
||||
template< char... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_char, Cs... > {};
|
||||
struct print : internal::range< internal::result_on_found::success, internal::peek_char, char( 32 ), char( 126 ) > {};
|
||||
template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_char, Lo, Hi > {};
|
||||
template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {};
|
||||
struct seven : internal::range< internal::result_on_found::success, internal::peek_char, char( 0 ), char( 127 ) > {};
|
||||
struct shebang : internal::seq< internal::string< '#', '!' >, internal::until< internal::eolf > > {};
|
||||
struct space : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {};
|
||||
template< char... Cs > struct string : internal::string< Cs... > {};
|
||||
template< char C > struct three : internal::string< C, C, C > {};
|
||||
template< char C > struct two : internal::string< C, C > {};
|
||||
struct upper : internal::range< internal::result_on_found::success, internal::peek_char, 'A', 'Z' > {};
|
||||
struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace ascii
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#include "internal/pegtl_string.hpp"
|
||||
|
||||
#endif
|
227
thirdparty/pegtl/pegtl/buffer_input.hpp
vendored
Normal file
227
thirdparty/pegtl/pegtl/buffer_input.hpp
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_BUFFER_INPUT_HPP
|
||||
#define TAO_PEGTL_BUFFER_INPUT_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include <stdexcept>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
#include "config.hpp"
|
||||
#include "eol.hpp"
|
||||
#include "memory_input.hpp"
|
||||
#include "position.hpp"
|
||||
#include "tracking_mode.hpp"
|
||||
|
||||
#include "internal/action_input.hpp"
|
||||
#include "internal/bump.hpp"
|
||||
#include "internal/iterator.hpp"
|
||||
#include "internal/marker.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string, std::size_t Chunk = 64 >
|
||||
class buffer_input
|
||||
{
|
||||
public:
|
||||
using reader_t = Reader;
|
||||
|
||||
using eol_t = Eol;
|
||||
using source_t = Source;
|
||||
|
||||
using iterator_t = internal::iterator;
|
||||
|
||||
using action_t = internal::action_input< buffer_input >;
|
||||
|
||||
static constexpr std::size_t chunk_size = Chunk;
|
||||
static constexpr tracking_mode tracking_mode_v = tracking_mode::eager;
|
||||
|
||||
template< typename T, typename... As >
|
||||
buffer_input( T&& in_source, const std::size_t maximum, As&&... as )
|
||||
: m_reader( std::forward< As >( as )... ),
|
||||
m_maximum( maximum + Chunk ),
|
||||
m_buffer( new char[ maximum + Chunk ] ),
|
||||
m_current( m_buffer.get() ),
|
||||
m_end( m_buffer.get() ),
|
||||
m_source( std::forward< T >( in_source ) )
|
||||
{
|
||||
static_assert( Chunk, "zero chunk size not implemented" );
|
||||
assert( m_maximum > maximum ); // Catches overflow; change to >= when zero chunk size is implemented.
|
||||
}
|
||||
|
||||
buffer_input( const buffer_input& ) = delete;
|
||||
buffer_input( buffer_input&& ) = delete;
|
||||
|
||||
~buffer_input() = default;
|
||||
|
||||
buffer_input& operator=( const buffer_input& ) = delete;
|
||||
buffer_input& operator=( buffer_input&& ) = delete;
|
||||
|
||||
[[nodiscard]] bool empty()
|
||||
{
|
||||
require( 1 );
|
||||
return m_current.data == m_end;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t size( const std::size_t amount )
|
||||
{
|
||||
require( amount );
|
||||
return buffer_occupied();
|
||||
}
|
||||
|
||||
[[nodiscard]] const char* current() const noexcept
|
||||
{
|
||||
return m_current.data;
|
||||
}
|
||||
|
||||
[[nodiscard]] const char* end( const std::size_t amount )
|
||||
{
|
||||
require( amount );
|
||||
return m_end;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t byte() const noexcept
|
||||
{
|
||||
return m_current.byte;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t line() const noexcept
|
||||
{
|
||||
return m_current.line;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t column() const noexcept
|
||||
{
|
||||
return m_current.column;
|
||||
}
|
||||
|
||||
[[nodiscard]] const Source& source() const noexcept
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
[[nodiscard]] char peek_char( const std::size_t offset = 0 ) const noexcept
|
||||
{
|
||||
return m_current.data[ offset ];
|
||||
}
|
||||
|
||||
[[nodiscard]] std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept
|
||||
{
|
||||
return static_cast< std::uint8_t >( peek_char( offset ) );
|
||||
}
|
||||
|
||||
void bump( const std::size_t in_count = 1 ) noexcept
|
||||
{
|
||||
internal::bump( m_current, in_count, Eol::ch );
|
||||
}
|
||||
|
||||
void bump_in_this_line( const std::size_t in_count = 1 ) noexcept
|
||||
{
|
||||
internal::bump_in_this_line( m_current, in_count );
|
||||
}
|
||||
|
||||
void bump_to_next_line( const std::size_t in_count = 1 ) noexcept
|
||||
{
|
||||
internal::bump_to_next_line( m_current, in_count );
|
||||
}
|
||||
|
||||
void discard() noexcept
|
||||
{
|
||||
if( m_current.data > m_buffer.get() + Chunk ) {
|
||||
const auto s = m_end - m_current.data;
|
||||
std::memmove( m_buffer.get(), m_current.data, s );
|
||||
m_current.data = m_buffer.get();
|
||||
m_end = m_buffer.get() + s;
|
||||
}
|
||||
}
|
||||
|
||||
void require( const std::size_t amount )
|
||||
{
|
||||
if( m_current.data + amount <= m_end ) {
|
||||
return;
|
||||
}
|
||||
if( m_current.data + amount > m_buffer.get() + m_maximum ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw std::overflow_error( "require() beyond end of buffer" );
|
||||
#else
|
||||
std::fputs( "overflow error: require() beyond end of buffer\n", stderr );
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
if( const auto r = m_reader( m_end, ( std::min )( buffer_free_after_end(), ( std::max )( amount - buffer_occupied(), Chunk ) ) ) ) {
|
||||
m_end += r;
|
||||
}
|
||||
}
|
||||
|
||||
template< rewind_mode M >
|
||||
[[nodiscard]] internal::marker< iterator_t, M > mark() noexcept
|
||||
{
|
||||
return internal::marker< iterator_t, M >( m_current );
|
||||
}
|
||||
|
||||
[[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::position( it, m_source );
|
||||
}
|
||||
|
||||
[[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const
|
||||
{
|
||||
return position( m_current );
|
||||
}
|
||||
|
||||
[[nodiscard]] const iterator_t& iterator() const noexcept
|
||||
{
|
||||
return m_current;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_capacity() const noexcept
|
||||
{
|
||||
return m_maximum;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_occupied() const noexcept
|
||||
{
|
||||
assert( m_end >= m_current.data );
|
||||
return std::size_t( m_end - m_current.data );
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_free_before_current() const noexcept
|
||||
{
|
||||
assert( m_current.data >= m_buffer.get() );
|
||||
return std::size_t( m_current.data - m_buffer.get() );
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_free_after_end() const noexcept
|
||||
{
|
||||
assert( m_buffer.get() + m_maximum >= m_end );
|
||||
return std::size_t( m_buffer.get() + m_maximum - m_end );
|
||||
}
|
||||
|
||||
private:
|
||||
Reader m_reader;
|
||||
std::size_t m_maximum;
|
||||
std::unique_ptr< char[] > m_buffer;
|
||||
iterator_t m_current;
|
||||
char* m_end;
|
||||
const Source m_source;
|
||||
|
||||
public:
|
||||
std::size_t private_depth = 0;
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
39
thirdparty/pegtl/pegtl/change_action.hpp
vendored
Normal file
39
thirdparty/pegtl/pegtl/change_action.hpp
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CHANGE_ACTION_HPP
|
||||
#define TAO_PEGTL_CHANGE_ACTION_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewAction >
|
||||
struct change_action
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" );
|
||||
return Control< Rule >::template match< A, M, NewAction, Control >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
72
thirdparty/pegtl/pegtl/change_action_and_state.hpp
vendored
Normal file
72
thirdparty/pegtl/pegtl/change_action_and_state.hpp
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CHANGE_ACTION_AND_STATE_HPP
|
||||
#define TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
#include "internal/dependent_false.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewAction, typename NewState >
|
||||
struct change_action_and_state
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" );
|
||||
|
||||
if constexpr( std::is_constructible_v< NewState, const ParseInput&, States... > ) {
|
||||
NewState s( static_cast< const ParseInput& >( in ), st... );
|
||||
if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if constexpr( std::is_default_constructible_v< NewState > ) {
|
||||
NewState s;
|
||||
if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
static_assert( internal::dependent_false< NewState >, "unable to instantiate new state" );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename... States >
|
||||
static void success( const ParseInput& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) )
|
||||
{
|
||||
s.success( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
63
thirdparty/pegtl/pegtl/change_action_and_states.hpp
vendored
Normal file
63
thirdparty/pegtl/pegtl/change_action_and_states.hpp
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CHANGE_ACTION_AND_STATES_HPP
|
||||
#define TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewAction, typename... NewStates >
|
||||
struct change_action_and_states
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
std::size_t... Ns,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( std::index_sequence< Ns... > /*unused*/, ParseInput& in, States&&... st )
|
||||
{
|
||||
auto t = std::tie( st... );
|
||||
if( Control< Rule >::template match< A, M, NewAction, Control >( in, std::get< Ns >( t )... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" );
|
||||
return match< Rule, A, M, Action, Control >( std::index_sequence_for< NewStates... >(), in, NewStates()..., st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
37
thirdparty/pegtl/pegtl/change_control.hpp
vendored
Normal file
37
thirdparty/pegtl/pegtl/change_control.hpp
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CHANGE_CONTROL_HPP
|
||||
#define TAO_PEGTL_CHANGE_CONTROL_HPP
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewControl >
|
||||
struct change_control
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, NewControl >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
70
thirdparty/pegtl/pegtl/change_state.hpp
vendored
Normal file
70
thirdparty/pegtl/pegtl/change_state.hpp
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CHANGE_STATE_HPP
|
||||
#define TAO_PEGTL_CHANGE_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
#include "internal/dependent_false.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename NewState >
|
||||
struct change_state
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
if constexpr( std::is_constructible_v< NewState, const ParseInput&, States... > ) {
|
||||
NewState s( static_cast< const ParseInput& >( in ), st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if constexpr( std::is_default_constructible_v< NewState > ) {
|
||||
NewState s;
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
static_assert( internal::dependent_false< NewState >, "unable to instantiate new state" );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename... States >
|
||||
static void success( const ParseInput& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) )
|
||||
{
|
||||
s.success( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
62
thirdparty/pegtl/pegtl/change_states.hpp
vendored
Normal file
62
thirdparty/pegtl/pegtl/change_states.hpp
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CHANGE_STATES_HPP
|
||||
#define TAO_PEGTL_CHANGE_STATES_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename... NewStates >
|
||||
struct change_states
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
std::size_t... Ns,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( std::index_sequence< Ns... > /*unused*/, ParseInput& in, States&&... st )
|
||||
{
|
||||
auto t = std::tie( st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, std::get< Ns >( t )... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
return match< Rule, A, M, Action, Control >( std::index_sequence_for< NewStates... >(), in, NewStates()..., st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
14
thirdparty/pegtl/pegtl/config.hpp
vendored
Normal file
14
thirdparty/pegtl/pegtl/config.hpp
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONFIG_HPP
|
||||
#define TAO_PEGTL_CONFIG_HPP
|
||||
|
||||
#if defined( TAO_PEGTL_NAMESPACE )
|
||||
#pragma message( "TAO_PEGTL_NAMESPACE is deprecated" )
|
||||
#else
|
||||
#define TAO_PEGTL_NAMESPACE tao::pegtl
|
||||
#endif
|
||||
|
||||
#endif
|
36
thirdparty/pegtl/pegtl/contrib/abnf.hpp
vendored
Normal file
36
thirdparty/pegtl/pegtl/contrib/abnf.hpp
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_ABNF_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ABNF_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::abnf
|
||||
{
|
||||
// Core ABNF rules according to RFC 5234, Appendix B
|
||||
|
||||
// clang-format off
|
||||
struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {};
|
||||
struct BIT : internal::one< internal::result_on_found::success, internal::peek_char, '0', '1' > {};
|
||||
struct CHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 1 ), char( 127 ) > {};
|
||||
struct CR : internal::one< internal::result_on_found::success, internal::peek_char, '\r' > {};
|
||||
struct CRLF : internal::string< '\r', '\n' > {};
|
||||
struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {};
|
||||
struct DIGIT : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {};
|
||||
struct DQUOTE : internal::one< internal::result_on_found::success, internal::peek_char, '"' > {};
|
||||
struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};
|
||||
struct HTAB : internal::one< internal::result_on_found::success, internal::peek_char, '\t' > {};
|
||||
struct LF : internal::one< internal::result_on_found::success, internal::peek_char, '\n' > {};
|
||||
struct LWSP : internal::star< internal::sor< internal::string< '\r', '\n' >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > > {};
|
||||
struct OCTET : internal::any< internal::peek_char > {};
|
||||
struct SP : internal::one< internal::result_on_found::success, internal::peek_char, ' ' > {};
|
||||
struct VCHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 33 ), char( 126 ) > {};
|
||||
struct WSP : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::abnf
|
||||
|
||||
#endif
|
70
thirdparty/pegtl/pegtl/contrib/add_state.hpp
vendored
Normal file
70
thirdparty/pegtl/pegtl/contrib/add_state.hpp
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_ADD_STATE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ADD_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#include "../internal/dependent_false.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename AddState >
|
||||
struct add_state
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
if constexpr( std::is_constructible_v< AddState, const ParseInput&, States... > ) {
|
||||
AddState s( static_cast< const ParseInput& >( in ), st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s, st... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if constexpr( std::is_default_constructible_v< AddState > ) {
|
||||
AddState s;
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s, st... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
static_assert( internal::dependent_false< AddState >, "unable to instantiate new state" );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename... States >
|
||||
static void success( const ParseInput& in, AddState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) )
|
||||
{
|
||||
s.success( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
68
thirdparty/pegtl/pegtl/contrib/alphabet.hpp
vendored
Normal file
68
thirdparty/pegtl/pegtl/contrib/alphabet.hpp
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_ALPHABET_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ALPHABET_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::alphabet
|
||||
{
|
||||
static const char a = 'a';
|
||||
static const char b = 'b';
|
||||
static const char c = 'c';
|
||||
static const char d = 'd';
|
||||
static const char e = 'e';
|
||||
static const char f = 'f';
|
||||
static const char g = 'g';
|
||||
static const char h = 'h';
|
||||
static const char i = 'i';
|
||||
static const char j = 'j';
|
||||
static const char k = 'k';
|
||||
static const char l = 'l';
|
||||
static const char m = 'm';
|
||||
static const char n = 'n';
|
||||
static const char o = 'o';
|
||||
static const char p = 'p';
|
||||
static const char q = 'q';
|
||||
static const char r = 'r';
|
||||
static const char s = 's';
|
||||
static const char t = 't';
|
||||
static const char u = 'u';
|
||||
static const char v = 'v';
|
||||
static const char w = 'w';
|
||||
static const char x = 'x';
|
||||
static const char y = 'y';
|
||||
static const char z = 'z';
|
||||
|
||||
static const char A = 'A'; // NOLINT(readability-identifier-naming)
|
||||
static const char B = 'B'; // NOLINT(readability-identifier-naming)
|
||||
static const char C = 'C'; // NOLINT(readability-identifier-naming)
|
||||
static const char D = 'D'; // NOLINT(readability-identifier-naming)
|
||||
static const char E = 'E'; // NOLINT(readability-identifier-naming)
|
||||
static const char F = 'F'; // NOLINT(readability-identifier-naming)
|
||||
static const char G = 'G'; // NOLINT(readability-identifier-naming)
|
||||
static const char H = 'H'; // NOLINT(readability-identifier-naming)
|
||||
static const char I = 'I'; // NOLINT(readability-identifier-naming)
|
||||
static const char J = 'J'; // NOLINT(readability-identifier-naming)
|
||||
static const char K = 'K'; // NOLINT(readability-identifier-naming)
|
||||
static const char L = 'L'; // NOLINT(readability-identifier-naming)
|
||||
static const char M = 'M'; // NOLINT(readability-identifier-naming)
|
||||
static const char N = 'N'; // NOLINT(readability-identifier-naming)
|
||||
static const char O = 'O'; // NOLINT(readability-identifier-naming)
|
||||
static const char P = 'P'; // NOLINT(readability-identifier-naming)
|
||||
static const char Q = 'Q'; // NOLINT(readability-identifier-naming)
|
||||
static const char R = 'R'; // NOLINT(readability-identifier-naming)
|
||||
static const char S = 'S'; // NOLINT(readability-identifier-naming)
|
||||
static const char T = 'T'; // NOLINT(readability-identifier-naming)
|
||||
static const char U = 'U'; // NOLINT(readability-identifier-naming)
|
||||
static const char V = 'V'; // NOLINT(readability-identifier-naming)
|
||||
static const char W = 'W'; // NOLINT(readability-identifier-naming)
|
||||
static const char X = 'X'; // NOLINT(readability-identifier-naming)
|
||||
static const char Y = 'Y'; // NOLINT(readability-identifier-naming)
|
||||
static const char Z = 'Z'; // NOLINT(readability-identifier-naming)
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::alphabet
|
||||
|
||||
#endif
|
190
thirdparty/pegtl/pegtl/contrib/analyze.hpp
vendored
Normal file
190
thirdparty/pegtl/pegtl/contrib/analyze.hpp
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_ANALYZE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ANALYZE_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
|
||||
#include "analyze_traits.hpp"
|
||||
|
||||
#include "internal/set_stack_guard.hpp"
|
||||
#include "internal/vector_stack_guard.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
struct analyze_entry
|
||||
{
|
||||
explicit analyze_entry( const analyze_type in_type ) noexcept
|
||||
: type( in_type )
|
||||
{}
|
||||
|
||||
const analyze_type type;
|
||||
std::vector< std::string_view > subs;
|
||||
};
|
||||
|
||||
class analyze_cycles_impl
|
||||
{
|
||||
public:
|
||||
analyze_cycles_impl( analyze_cycles_impl&& ) = delete;
|
||||
analyze_cycles_impl( const analyze_cycles_impl& ) = delete;
|
||||
|
||||
~analyze_cycles_impl() = default;
|
||||
|
||||
analyze_cycles_impl& operator=( analyze_cycles_impl&& ) = delete;
|
||||
analyze_cycles_impl& operator=( const analyze_cycles_impl& ) = delete;
|
||||
|
||||
[[nodiscard]] std::size_t problems()
|
||||
{
|
||||
for( auto& i : m_entries ) {
|
||||
assert( m_trace.empty() );
|
||||
assert( m_stack.empty() );
|
||||
m_results[ i.first ] = work( i, false );
|
||||
}
|
||||
// The number of problems returned is not very informative as some problems will be found multiple times.
|
||||
return m_problems;
|
||||
}
|
||||
|
||||
template< typename Rule >
|
||||
[[nodiscard]] bool consumes() const
|
||||
{
|
||||
// The name "consumes" is a shortcut for "the analyze cycles algorithm could prove that this rule always consumes when it succeeds".
|
||||
return m_results.at( demangle< Rule >() );
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit analyze_cycles_impl( const int verbose ) noexcept
|
||||
: m_verbose( verbose ),
|
||||
m_problems( 0 )
|
||||
{}
|
||||
|
||||
[[nodiscard]] const std::pair< const std::string_view, analyze_entry >& find( const std::string_view name ) const noexcept
|
||||
{
|
||||
const auto iter = m_entries.find( name );
|
||||
assert( iter != m_entries.end() );
|
||||
return *iter;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool work( const std::pair< const std::string_view, analyze_entry >& entry, const bool accum )
|
||||
{
|
||||
if( const auto g = set_stack_guard( m_stack, entry.first ) ) {
|
||||
const auto v = vector_stack_guard( m_trace, entry.first );
|
||||
switch( entry.second.type ) {
|
||||
case analyze_type::any: {
|
||||
bool a = false;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a || work( find( r ), accum || a );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case analyze_type::opt: {
|
||||
bool a = false;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a || work( find( r ), accum || a );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case analyze_type::seq: {
|
||||
bool a = false;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a || work( find( r ), accum || a );
|
||||
}
|
||||
return a;
|
||||
}
|
||||
case analyze_type::sor: {
|
||||
bool a = true;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a && work( find( r ), accum );
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
assert( false ); // LCOV_EXCL_LINE
|
||||
}
|
||||
assert( !m_trace.empty() );
|
||||
|
||||
if( !accum ) {
|
||||
++m_problems;
|
||||
// LCOV_EXCL_START
|
||||
if( ( m_verbose >= 0 ) && ( m_trace.front() == entry.first ) ) {
|
||||
for( const auto& r : m_trace ) {
|
||||
if( r < entry.first ) {
|
||||
return accum;
|
||||
}
|
||||
}
|
||||
std::cerr << "WARNING: Possible cycle without progress at rule " << entry.first << std::endl;
|
||||
if( m_verbose > 0 ) {
|
||||
for( const auto& r : m_trace ) {
|
||||
std::cerr << "- involved (transformed) rule: " << r << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
return accum;
|
||||
}
|
||||
|
||||
const int m_verbose;
|
||||
|
||||
std::size_t m_problems;
|
||||
|
||||
std::set< std::string_view > m_stack;
|
||||
std::vector< std::string_view > m_trace;
|
||||
std::map< std::string_view, bool > m_results;
|
||||
std::map< std::string_view, analyze_entry > m_entries;
|
||||
};
|
||||
|
||||
template< typename Name >
|
||||
std::string_view analyze_insert( std::map< std::string_view, analyze_entry >& entry )
|
||||
{
|
||||
using Traits = analyze_traits< Name, typename Name::rule_t >;
|
||||
|
||||
const auto [ i, b ] = entry.try_emplace( demangle< Name >(), Traits::type_v );
|
||||
if( b ) {
|
||||
analyze_insert_impl( typename Traits::subs_t(), i->second.subs, entry );
|
||||
}
|
||||
return i->first;
|
||||
}
|
||||
|
||||
template< typename... Subs >
|
||||
void analyze_insert_impl( type_list< Subs... > /*unused*/, std::vector< std::string_view >& subs, std::map< std::string_view, analyze_entry >& entry )
|
||||
{
|
||||
( subs.emplace_back( analyze_insert< Subs >( entry ) ), ... );
|
||||
}
|
||||
|
||||
template< typename Grammar >
|
||||
struct analyze_cycles
|
||||
: analyze_cycles_impl
|
||||
{
|
||||
explicit analyze_cycles( const int verbose )
|
||||
: analyze_cycles_impl( verbose )
|
||||
{
|
||||
analyze_insert< Grammar >( m_entries );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Grammar >
|
||||
[[nodiscard]] std::size_t analyze( const int verbose = 1 )
|
||||
{
|
||||
return internal::analyze_cycles< Grammar >( verbose ).problems();
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
278
thirdparty/pegtl/pegtl/contrib/analyze_traits.hpp
vendored
Normal file
278
thirdparty/pegtl/pegtl/contrib/analyze_traits.hpp
vendored
Normal file
@ -0,0 +1,278 @@
|
||||
// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_ANALYZE_TRAITS_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ANALYZE_TRAITS_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../type_list.hpp"
|
||||
|
||||
#include "forward.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
enum class analyze_type
|
||||
{
|
||||
any, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules.
|
||||
opt, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules.
|
||||
seq, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules.
|
||||
sor // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules.
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_any_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::any;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_opt_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::opt;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_seq_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::seq;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_sor_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::sor;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename Name, template< typename... > class Action, typename... Rules >
|
||||
struct analyze_traits< Name, internal::action< Action, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Peek >
|
||||
struct analyze_traits< Name, internal::any< Peek > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Actions >
|
||||
struct analyze_traits< Name, internal::apply< Actions... > >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Actions >
|
||||
struct analyze_traits< Name, internal::apply0< Actions... > >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::at< Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::bof >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::bol >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Cnt >
|
||||
struct analyze_traits< Name, internal::bytes< Cnt > >
|
||||
: std::conditional_t< ( Cnt != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
template< typename Name, template< typename... > class Control, typename... Rules >
|
||||
struct analyze_traits< Name, internal::control< Control, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::disable< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::discard >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::enable< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::eof >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::eol >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::eolf >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::failure >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Actions >
|
||||
struct analyze_traits< Name, internal::if_apply< Rule, Actions... > >
|
||||
: analyze_traits< Name, typename Rule::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond, typename Then, typename Else >
|
||||
struct analyze_traits< Name, internal::if_then_else< Cond, Then, Else > >
|
||||
: analyze_traits< Name, typename sor< seq< Cond, Then >, Else >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, char... Cs >
|
||||
struct analyze_traits< Name, internal::istring< Cs... > >
|
||||
: std::conditional_t< ( sizeof...( Cs ) != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::not_at< Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, internal::result_on_found R, typename Peek, typename Peek::data_t... Cs >
|
||||
struct analyze_traits< Name, internal::one< R, Peek, Cs... > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Rules >
|
||||
struct analyze_traits< Name, internal::opt< Rule, Rules... > >
|
||||
: analyze_opt_traits< Rule, Rules... >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::plus< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules..., opt< Name > >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, internal::result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi >
|
||||
struct analyze_traits< Name, internal::range< R, Peek, Lo, Hi > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Peek, typename Peek::data_t... Cs >
|
||||
struct analyze_traits< Name, internal::ranges< Peek, Cs... > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Head, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rematch< Head, Rules... > >
|
||||
: analyze_traits< Name, typename sor< Head, sor< seq< Rules, any >... > >::rule_t > // TODO: Correct (enough)?
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Cnt, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rep< Cnt, Rules... > >
|
||||
: analyze_traits< Name, std::conditional_t< ( Cnt != 0 ), typename seq< Rules... >::rule_t, typename opt< Rules... >::rule_t > >
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Min, unsigned Max, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rep_min_max< Min, Max, Rules... > >
|
||||
: analyze_traits< Name, std::conditional_t< ( Min != 0 ), typename seq< Rules... >::rule_t, typename opt< Rules... >::rule_t > >
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Max, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rep_opt< Max, Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Amount >
|
||||
struct analyze_traits< Name, internal::require< Amount > >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Rules >
|
||||
struct analyze_traits< Name, internal::seq< Rule, Rules... > >
|
||||
: analyze_seq_traits< Rule, Rules... >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Rules >
|
||||
struct analyze_traits< Name, internal::sor< Rule, Rules... > >
|
||||
: analyze_sor_traits< Rule, Rules... >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::star< Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules..., Name >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename State, typename... Rules >
|
||||
struct analyze_traits< Name, internal::state< State, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, char... Cs >
|
||||
struct analyze_traits< Name, internal::string< Cs... > >
|
||||
: std::conditional_t< ( sizeof...( Cs ) != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::success >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond >
|
||||
struct analyze_traits< Name, internal::until< Cond > >
|
||||
: analyze_traits< Name, typename Cond::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond, typename... Rules >
|
||||
struct analyze_traits< Name, internal::until< Cond, Rules... > >
|
||||
: analyze_traits< Name, typename seq< star< Rules... >, Cond >::rule_t >
|
||||
{};
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
template< typename Name, typename Cond, typename... Rules >
|
||||
struct analyze_traits< Name, internal::if_must< true, Cond, Rules... > >
|
||||
: analyze_traits< Name, typename opt< Cond, Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond, typename... Rules >
|
||||
struct analyze_traits< Name, internal::if_must< false, Cond, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Cond, Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::must< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename T >
|
||||
struct analyze_traits< Name, internal::raise< T > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Exception, typename... Rules >
|
||||
struct analyze_traits< Name, internal::try_catch_type< Exception, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
#endif
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
56
thirdparty/pegtl/pegtl/contrib/check_bytes.hpp
vendored
Normal file
56
thirdparty/pegtl/pegtl/contrib/check_bytes.hpp
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_CHECK_BYTES_HPP
|
||||
#define TAO_PEGTL_CONTRIB_CHECK_BYTES_HPP
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include "../parse_error.hpp"
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< std::size_t Maximum >
|
||||
struct check_bytes
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
const auto* start = in.current();
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ) ) {
|
||||
if( std::size_t( in.current() - start ) > Maximum ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw TAO_PEGTL_NAMESPACE::parse_error( "maximum allowed rule consumption exceeded", in );
|
||||
#else
|
||||
std::fputs( "maximum allowed rule consumption exceeded\n", stderr );
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
94
thirdparty/pegtl/pegtl/contrib/control_action.hpp
vendored
Normal file
94
thirdparty/pegtl/pegtl/contrib/control_action.hpp
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_CONTROL_ACTION_HPP
|
||||
#define TAO_PEGTL_CONTRIB_CONTROL_ACTION_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename, typename Rule, template< typename... > class Action, typename ParseInput, typename... States >
|
||||
inline constexpr bool action_has_unwind = false;
|
||||
|
||||
template< typename Rule, template< typename... > class Action, typename ParseInput, typename... States >
|
||||
inline constexpr bool action_has_unwind< decltype( (void)Action< Rule >::unwind( std::declval< const ParseInput& >(), std::declval< States&& >()... ) ), Rule, Action, ParseInput, States... > = true;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
struct control_action
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
#if defined( __cpp_exceptions )
|
||||
if constexpr( internal::action_has_unwind< void, Rule, Action, ParseInput, States... > ) {
|
||||
try {
|
||||
return control_action::match_impl< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
catch( ... ) {
|
||||
Action< Rule >::unwind( const_cast< const ParseInput& >( in ), st... );
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return control_action::match_impl< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
#else
|
||||
return control_action::match_impl< Rule, A, M, Action, Control >( in, st... );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void start( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void success( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void failure( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
private:
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match_impl( ParseInput& in, States&&... st )
|
||||
{
|
||||
Action< Rule >::start( const_cast< const ParseInput& >( in ), st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ) ) {
|
||||
Action< Rule >::success( const_cast< const ParseInput& >( in ), st... );
|
||||
return true;
|
||||
}
|
||||
Action< Rule >::failure( const_cast< const ParseInput& >( in ), st... );
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
152
thirdparty/pegtl/pegtl/contrib/coverage.hpp
vendored
Normal file
152
thirdparty/pegtl/pegtl/contrib/coverage.hpp
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_COVERAGE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_COVERAGE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "state_control.hpp"
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
#include "../normal.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../parse.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
#include "../type_list.hpp"
|
||||
#include "../visit.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
struct coverage_info
|
||||
{
|
||||
std::size_t start = 0;
|
||||
std::size_t success = 0;
|
||||
std::size_t failure = 0;
|
||||
std::size_t unwind = 0;
|
||||
std::size_t raise = 0;
|
||||
};
|
||||
|
||||
struct coverage_entry
|
||||
: coverage_info
|
||||
{
|
||||
std::map< std::string_view, coverage_info > branches;
|
||||
};
|
||||
|
||||
using coverage_result = std::map< std::string_view, coverage_entry >;
|
||||
|
||||
namespace internal
|
||||
{
|
||||
template< typename Rule >
|
||||
struct coverage_insert
|
||||
{
|
||||
static void visit( std::map< std::string_view, coverage_entry >& map )
|
||||
{
|
||||
visit_branches( map.try_emplace( demangle< Rule >() ).first->second.branches, typename Rule::subs_t() );
|
||||
}
|
||||
|
||||
template< typename... Ts >
|
||||
static void visit_branches( std::map< std::string_view, coverage_info >& branches, type_list< Ts... > /*unused*/ )
|
||||
{
|
||||
( branches.try_emplace( demangle< Ts >() ), ... );
|
||||
}
|
||||
};
|
||||
|
||||
struct coverage_state
|
||||
{
|
||||
template< typename Rule >
|
||||
static constexpr bool enable = true;
|
||||
|
||||
explicit coverage_state( coverage_result& in_result )
|
||||
: result( in_result )
|
||||
{}
|
||||
|
||||
coverage_result& result;
|
||||
std::vector< std::string_view > stack;
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void start( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).start;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).start;
|
||||
}
|
||||
stack.push_back( name );
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void success( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
stack.pop_back();
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).success;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).success;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void failure( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
stack.pop_back();
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).failure;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).failure;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void raise( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).raise;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).raise;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void unwind( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
stack.pop_back();
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).unwind;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).unwind;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void apply( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void apply0( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Rule,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
bool coverage( ParseInput&& in, coverage_result& result, States&&... st )
|
||||
{
|
||||
internal::coverage_state state( result );
|
||||
visit< Rule, internal::coverage_insert >( state.result ); // Fill map with all sub-rules of the grammar.
|
||||
return parse< Rule, Action, state_control< Control >::template type >( in, st..., state );
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
17
thirdparty/pegtl/pegtl/contrib/forward.hpp
vendored
Normal file
17
thirdparty/pegtl/pegtl/contrib/forward.hpp
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey
|
||||
// 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_CONTRIB_FORWARD_HPP
|
||||
#define TAO_PEGTL_CONTRIB_FORWARD_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename Name, typename Rule, typename = void >
|
||||
struct analyze_traits;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user