Skip to content

Commit

Permalink
Improve name of frobnicator.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Sep 22, 2023
1 parent 4da3d14 commit fa987b7
Show file tree
Hide file tree
Showing 25 changed files with 118 additions and 124 deletions.
14 changes: 7 additions & 7 deletions include/tao/pegtl/buffer_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "internal/action_input.hpp"
#include "internal/bump.hpp"
#include "internal/frobnicator.hpp"
#include "internal/inputerator.hpp"
#include "internal/rewind_guard.hpp"

namespace TAO_PEGTL_NAMESPACE
Expand All @@ -42,7 +42,7 @@ namespace TAO_PEGTL_NAMESPACE
using eol_t = Eol;
using source_t = Source;

using frobnicator_t = internal::frobnicator;
using inputerator_t = internal::inputerator;

using action_t = internal::action_input< buffer_input >;

Expand Down Expand Up @@ -170,17 +170,17 @@ namespace TAO_PEGTL_NAMESPACE
return internal::rewind_guard< M, buffer_input >( this );
}

[[nodiscard]] const frobnicator_t& rewind_save() noexcept
[[nodiscard]] const inputerator_t& rewind_save() noexcept
{
return m_current;
}

void rewind_restore( const frobnicator_t& data ) noexcept
void rewind_restore( const inputerator_t& data ) noexcept
{
m_current = data;
}

[[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const frobnicator_t& it ) const
[[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const inputerator_t& it ) const
{
return TAO_PEGTL_NAMESPACE::position( it, m_source );
}
Expand All @@ -195,7 +195,7 @@ namespace TAO_PEGTL_NAMESPACE
return position( m_current );
}

[[nodiscard]] const frobnicator_t& frobnicator() const noexcept
[[nodiscard]] const inputerator_t& inputerator() const noexcept
{
return m_current;
}
Expand Down Expand Up @@ -227,7 +227,7 @@ namespace TAO_PEGTL_NAMESPACE
Reader m_reader;
std::size_t m_maximum;
std::unique_ptr< char[] > m_buffer;
frobnicator_t m_current;
inputerator_t m_current;
char* m_end;
const Source m_source;

Expand Down
12 changes: 6 additions & 6 deletions include/tao/pegtl/contrib/parse_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../rewind_mode.hpp"

#include "../internal/enable_control.hpp"
#include "../internal/frobnicator.hpp"
#include "../internal/inputerator.hpp"
#include "../internal/has_unwind.hpp"

namespace TAO_PEGTL_NAMESPACE::parse_tree
Expand All @@ -43,8 +43,8 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree
std::string_view type;
Source source;

TAO_PEGTL_NAMESPACE::internal::frobnicator m_begin;
TAO_PEGTL_NAMESPACE::internal::frobnicator m_end;
TAO_PEGTL_NAMESPACE::internal::inputerator m_begin;
TAO_PEGTL_NAMESPACE::internal::inputerator m_end;

// each node will be default constructed
basic_node() = default;
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree
template< typename... States >
void remove_content( States&&... /*unused*/ ) noexcept
{
m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator();
m_end = TAO_PEGTL_NAMESPACE::internal::inputerator();
}

// all non-root nodes are initialized by calling this method
Expand All @@ -124,14 +124,14 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree
{
set_type< Rule >();
source = in.source();
m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator( in.frobnicator() );
m_begin = TAO_PEGTL_NAMESPACE::internal::inputerator( in.inputerator() );
}

// if parsing of the rule succeeded, this method is called
template< typename Rule, typename ParseInput, typename... States >
void success( const ParseInput& in, States&&... /*unused*/ ) noexcept
{
m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator( in.frobnicator() );
m_end = TAO_PEGTL_NAMESPACE::internal::inputerator( in.inputerator() );
}

// if parsing of the rule failed, this method is called
Expand Down
4 changes: 2 additions & 2 deletions include/tao/pegtl/contrib/remove_first_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ namespace TAO_PEGTL_NAMESPACE
Base::unwind( in, st... );
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename State, typename... States >
static auto apply( const Frobnicator& begin, const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st... ) ) )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename State, typename... States >
static auto apply( const Inputerator& begin, const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st... ) ) )
-> decltype( Base::template apply< Action >( begin, in, st... ) )
{
return Base::template apply< Action >( begin, in, st... );
Expand Down
8 changes: 4 additions & 4 deletions include/tao/pegtl/contrib/remove_last_states.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ namespace TAO_PEGTL_NAMESPACE
unwind_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename Tuple, std::size_t... Is >
static auto apply_impl( const Frobnicator& begin, const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename Tuple, std::size_t... Is >
static auto apply_impl( const Inputerator& begin, const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) )
-> decltype( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) )
{
return Base::template apply< Action >( begin, in, std::get< Is >( t )... );
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename... States >
static auto apply( const Frobnicator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename... States >
static auto apply( const Inputerator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
-> decltype( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) )
{
return apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
Expand Down
12 changes: 6 additions & 6 deletions include/tao/pegtl/contrib/shuffle_states.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,22 @@ namespace TAO_PEGTL_NAMESPACE
Base::unwind( in, st );
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename Tuple, std::size_t... Is >
static auto apply_impl( const Frobnicator& begin, const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename Tuple, std::size_t... Is >
static auto apply_impl( const Inputerator& begin, const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
-> decltype( Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) )
{
return Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename... States >
static auto apply( const Frobnicator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename... States >
static auto apply( const Inputerator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
-> decltype( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) )
{
return apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename State >
static auto apply( const Frobnicator& begin, const ParseInput& in, State&& st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st ) ) )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename State >
static auto apply( const Inputerator& begin, const ParseInput& in, State&& st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st ) ) )
-> decltype( Base::template apply< Action >( begin, in, st ) )
{
return Base::template apply< Action >( begin, in, st );
Expand Down
4 changes: 2 additions & 2 deletions include/tao/pegtl/contrib/state_control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ namespace TAO_PEGTL_NAMESPACE
#endif
}

template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename State, typename... States >
static auto apply( const Frobnicator& begin, const ParseInput& in, [[maybe_unused]] State& state, States&&... st )
template< template< typename... > class Action, typename Inputerator, typename ParseInput, typename State, typename... States >
static auto apply( const Inputerator& begin, const ParseInput& in, [[maybe_unused]] State& state, States&&... st )
-> decltype( Control< Rule >::template apply< Action >( begin, in, st... ) )
{
if constexpr( State::template enable< Rule > ) {
Expand Down
20 changes: 10 additions & 10 deletions include/tao/pegtl/internal/action_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <string>
#include <string_view>

#include "frobnicator.hpp"
#include "inputerator.hpp"

#include "../config.hpp"
#include "../position.hpp"
Expand All @@ -22,9 +22,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
{
public:
using input_t = ParseInput;
using frobnicator_t = typename ParseInput::frobnicator_t;
using inputerator_t = typename ParseInput::inputerator_t;

action_input( const frobnicator_t& in_begin, const ParseInput& in_input ) noexcept
action_input( const inputerator_t& in_begin, const ParseInput& in_input ) noexcept
: m_begin( in_begin ),
m_input( in_input )
{}
Expand All @@ -37,7 +37,7 @@ namespace TAO_PEGTL_NAMESPACE::internal
action_input& operator=( const action_input& ) = delete;
action_input& operator=( action_input&& ) = delete;

[[nodiscard]] const frobnicator_t& frobnicator() const noexcept
[[nodiscard]] const inputerator_t& inputerator() const noexcept
{
return m_begin;
}
Expand All @@ -54,11 +54,11 @@ namespace TAO_PEGTL_NAMESPACE::internal

[[nodiscard]] const char* begin() const noexcept
{
if constexpr( std::is_same_v< frobnicator_t, const char* > ) {
return frobnicator();
if constexpr( std::is_same_v< inputerator_t, const char* > ) {
return inputerator();
}
else {
return frobnicator().data;
return inputerator().data;
}
}

Expand Down Expand Up @@ -99,16 +99,16 @@ namespace TAO_PEGTL_NAMESPACE::internal

[[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const
{
return input().position( frobnicator() ); // NOTE: Not efficient with lazy inputs.
return input().position( inputerator() ); // NOTE: Not efficient with lazy inputs.
}

[[nodiscard]] TAO_PEGTL_NAMESPACE::position current_position() const
{
return input().position( frobnicator() ); // NOTE: Not efficient with lazy inputs.
return input().position( inputerator() ); // NOTE: Not efficient with lazy inputs.
}

protected:
const frobnicator_t m_begin;
const inputerator_t m_begin;
const ParseInput& m_input;
};

Expand Down
2 changes: 1 addition & 1 deletion include/tao/pegtl/internal/apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace TAO_PEGTL_NAMESPACE::internal
{
if constexpr( ( A == apply_mode::action ) && ( sizeof...( Actions ) > 0 ) ) {
using action_t = typename ParseInput::action_t;
const action_t i2( in.frobnicator(), in ); // No data -- range is from begin to begin.
const action_t i2( in.inputerator(), in ); // No data -- range is from begin to begin.
return ( apply_single< Actions >::match( i2, st... ) && ... );
}
else {
Expand Down
8 changes: 4 additions & 4 deletions include/tao/pegtl/internal/bump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#ifndef TAO_PEGTL_INTERNAL_BUMP_HPP
#define TAO_PEGTL_INTERNAL_BUMP_HPP

#include "frobnicator.hpp"
#include "inputerator.hpp"

#include "../config.hpp"

namespace TAO_PEGTL_NAMESPACE::internal
{
inline void bump( frobnicator& iter, const std::size_t count, const int ch ) noexcept
inline void bump( inputerator& iter, const std::size_t count, const int ch ) noexcept
{
for( std::size_t i = 0; i < count; ++i ) {
if( iter.data[ i ] == ch ) {
Expand All @@ -26,14 +26,14 @@ namespace TAO_PEGTL_NAMESPACE::internal
iter.data += count;
}

inline void bump_in_this_line( frobnicator& iter, const std::size_t count ) noexcept
inline void bump_in_this_line( inputerator& iter, const std::size_t count ) noexcept
{
iter.data += count;
iter.byte += count;
iter.column += count;
}

inline void bump_to_next_line( frobnicator& iter, const std::size_t count ) noexcept
inline void bump_to_next_line( inputerator& iter, const std::size_t count ) noexcept
{
++iter.line;
iter.byte += count;
Expand Down
2 changes: 1 addition & 1 deletion include/tao/pegtl/internal/if_apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace TAO_PEGTL_NAMESPACE::internal
using action_t = typename ParseInput::action_t;
auto m = in.template auto_rewind< rewind_mode::required >();
if( Control< Rule >::template match< apply_mode::action, rewind_mode::optional, Action, Control >( in, st... ) ) {
const action_t i2( m.frobnicator(), in );
const action_t i2( m.inputerator(), in );
return m( ( apply_single< Actions >::match( i2, st... ) && ... ) );
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// 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_INTERNAL_FROBNICATOR_HPP
#define TAO_PEGTL_INTERNAL_FROBNICATOR_HPP
#ifndef TAO_PEGTL_INTERNAL_INPUTERATOR_HPP
#define TAO_PEGTL_INTERNAL_INPUTERATOR_HPP

#include <cassert>
#include <cstdlib>
Expand All @@ -12,15 +12,15 @@

namespace TAO_PEGTL_NAMESPACE::internal
{
struct frobnicator
struct inputerator
{
frobnicator() = default;
inputerator() noexcept = default;

explicit frobnicator( const char* in_data ) noexcept
explicit inputerator( const char* in_data ) noexcept
: data( in_data )
{}

frobnicator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_column ) noexcept
inputerator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_column ) noexcept
: data( in_data ),
byte( in_byte ),
line( in_line ),
Expand All @@ -30,13 +30,13 @@ namespace TAO_PEGTL_NAMESPACE::internal
assert( in_column != 0 );
}

frobnicator( const frobnicator& ) = default;
frobnicator( frobnicator&& ) = default;
inputerator( const inputerator& ) = default;
inputerator( inputerator&& ) = default;

~frobnicator() = default;
~inputerator() = default;

frobnicator& operator=( const frobnicator& ) = default;
frobnicator& operator=( frobnicator&& ) = default;
inputerator& operator=( const inputerator& ) = default;
inputerator& operator=( inputerator&& ) = default;

const char* data = nullptr;

Expand Down
2 changes: 1 addition & 1 deletion include/tao/pegtl/internal/missing_apply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace TAO_PEGTL_NAMESPACE::internal
// This function only exists for better error messages, which means that it is only called when we know that it won't compile.
// LCOV_EXCL_START
auto m = in.template auto_rewind< rewind_mode::required >();
(void)Control::template apply< Action >( m.frobnicator(), in, st... );
(void)Control::template apply< Action >( m.inputerator(), in, st... );
// LCOV_EXCL_STOP
}

Expand Down
9 changes: 3 additions & 6 deletions include/tao/pegtl/internal/mmap_file_posix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,17 @@ namespace TAO_PEGTL_NAMESPACE::internal
return m_size;
}

using iterator = const char*;
using const_iterator = const char*;

[[nodiscard]] iterator data() const noexcept
[[nodiscard]] const char* data() const noexcept
{
return m_data;
}

[[nodiscard]] iterator begin() const noexcept
[[nodiscard]] const char* begin() const noexcept
{
return m_data;
}

[[nodiscard]] iterator end() const noexcept
[[nodiscard]] const char* end() const noexcept
{
return m_data + m_size;
}
Expand Down
9 changes: 3 additions & 6 deletions include/tao/pegtl/internal/mmap_file_win32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,17 @@ namespace TAO_PEGTL_NAMESPACE::internal
return m_size;
}

using iterator = const char*;
using const_iterator = const char*;

[[nodiscard]] iterator data() const noexcept
[[nodiscard]] const char* data() const noexcept
{
return m_data;
}

[[nodiscard]] iterator begin() const noexcept
[[nodiscard]] const char* begin() const noexcept
{
return m_data;
}

[[nodiscard]] iterator end() const noexcept
[[nodiscard]] const char* end() const noexcept
{
return m_data + m_size;
}
Expand Down
Loading

0 comments on commit fa987b7

Please sign in to comment.