Skip to content

Commit

Permalink
Small fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Nov 17, 2024
1 parent 227bcd1 commit 455ec4a
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 13 deletions.
4 changes: 4 additions & 0 deletions include/tao/pegtl/buffer/buffer_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include "../config.hpp"
#include "../count_position.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"

#include "buffer_common.hpp"
Expand All @@ -25,7 +27,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = count_position;
using offset_position_t = count_position;
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

using buffer_common< Buffer >::buffer_common;

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/buffer/buffer_input_with_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

#include "../config.hpp"
#include "../count_position.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"
#include "../position_with_source.hpp"

Expand All @@ -31,7 +33,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = position_with_source< ErrorSource, count_position >;
using offset_position_t = count_position;
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

static_assert( std::is_same_v< InputSource, ErrorSource >, "TODO?" );

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/buffer/text_buffer_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <cstddef>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../text_position.hpp"

#include "../internal/choose_text_traits.hpp"
Expand All @@ -26,7 +28,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = text_position;
using offset_position_t = text_position;
using rewind_position_t = text_position;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

using eol_rule = Eol;

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/buffer/text_buffer_input_with_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <utility>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../position_with_source.hpp"
#include "../text_position.hpp"

Expand All @@ -32,7 +34,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = position_with_source< ErrorSource, text_position >;
using offset_position_t = text_position;
using rewind_position_t = text_position;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

using eol_rule = Eol;

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/contrib/input_with_offset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <utility>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif

namespace TAO_PEGTL_NAMESPACE
{
Expand All @@ -21,7 +23,9 @@ namespace TAO_PEGTL_NAMESPACE
using error_position_t = typename Input::error_position_t;
using offset_position_t = typename Input::offset_position_t;
using rewind_position_t = typename Input::rewind_position_t;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

template< typename... Ts >
explicit input_with_offset( offset_position_t&& s, Ts&&... ts )
Expand Down
1 change: 1 addition & 0 deletions include/tao/pegtl/contrib/parse_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "../nothing.hpp"
#include "../parse.hpp"
#include "../rewind_mode.hpp"
#include "../type_list.hpp"

#include "../control/remove_first_state.hpp"
#include "../control/shuffle_states.hpp"
Expand Down
5 changes: 4 additions & 1 deletion include/tao/pegtl/internal/action_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#include <cstddef>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"

#endif
#include "input_with_funcs.hpp"

namespace TAO_PEGTL_NAMESPACE::internal
Expand All @@ -22,7 +23,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using input_t = ParseInput;
using error_position_t = typename ParseInput::error_position_t;
using rewind_position_t = typename ParseInput::rewind_position_t;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

action_input_impl( const rewind_position_t& begin, const ParseInput& input ) noexcept
: m_saved( begin ),
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/argv_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <cstring>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif

#include "input_with_start.hpp"
#include "view_input.hpp"
Expand All @@ -24,7 +26,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
{}

using error_position_t = typename input_with_start< view_input< char > >::error_position_t;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

[[nodiscard]] const char* begin_of_line( const error_position_t& pos, const std::size_t max = 135 ) const noexcept
{
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/argv_input_with_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#include <string>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif

#include "argv_input.hpp"
#include "input_with_source.hpp"
Expand All @@ -29,7 +31,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
{}

using error_position_t = typename input_with_source< std::string, std::string, argv_input >::error_position_t;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

[[nodiscard]] const char* begin_of_line( const error_position_t& pos, const std::size_t max = 135 ) const noexcept
{
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/copy_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

#include "../config.hpp"
#include "../count_position.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"

namespace TAO_PEGTL_NAMESPACE::internal
Expand All @@ -26,7 +28,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = count_position;
using offset_position_t = count_position;
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

copy_input( const data_t* in_begin, const data_t* in_end )
: m_container( in_begin, in_end ),
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/input_with_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <utility>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../position_with_source.hpp"

#include "dependent_false.hpp"
Expand All @@ -26,7 +28,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = position_with_source< ErrorSource, typename Input::error_position_t >;
using offset_position_t = typename Input::offset_position_t;
using rewind_position_t = typename Input::rewind_position_t;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

template< typename S, typename... Ts >
explicit input_with_source( S&& s, Ts&&... ts )
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/input_with_start.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include "../config.hpp"
#include "../count_position.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"

namespace TAO_PEGTL_NAMESPACE::internal
Expand All @@ -23,7 +25,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = count_position;
using offset_position_t = count_position;
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

template< typename... As >
explicit input_with_start( As&&... as ) noexcept
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/lazy_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include "../config.hpp"
#include "../normal.hpp"
#include "../nothing.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../rewind_mode.hpp"
#include "../text_position.hpp"

Expand All @@ -35,7 +37,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = text_position;
using offset_position_t = text_position;
using rewind_position_t = typename Input::rewind_position_t;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

using eol_rule = Eol;

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/mmap_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include "../config.hpp"
#include "../count_position.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"

#include "mmap_file_base.hpp"
Expand All @@ -26,7 +28,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = count_position;
using offset_position_t = count_position;
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

explicit mmap_input( const std::filesystem::path& path )
: mmap_file_base( path ),
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/rematch_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include <cstddef>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"

#include "input_with_fakes.hpp"
Expand All @@ -27,7 +29,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = typename Input::error_position_t;
// offset_position_t
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

rematch_input_impl( Guard& m, Input& in ) noexcept
: m_guard( m ),
Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/text_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include "../config.hpp"
#include "../normal.hpp"
#include "../nothing.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"
#include "../rewind_mode.hpp"
#include "../text_position.hpp"
Expand All @@ -35,7 +37,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = text_position;
using offset_position_t = text_position;
using rewind_position_t = text_position;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

using eol_rule = Eol;

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/text_input_with_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#include "../config.hpp"
#include "../normal.hpp"
#include "../nothing.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../position_with_source.hpp"
#include "../rewind_mode.hpp"
#include "../text_position.hpp"
Expand All @@ -39,7 +41,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = position_with_source< ErrorSource, text_position >;
using offset_position_t = text_position;
using rewind_position_t = text_position;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

using eol_rule = Eol;

Expand Down
4 changes: 4 additions & 0 deletions include/tao/pegtl/internal/view_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include <vector>

#include "../config.hpp"
#if defined( __cpp_exceptions )
#include "../parse_error.hpp"
#endif
#include "../pointer_position.hpp"

#include "type_traits.hpp"
Expand All @@ -28,7 +30,9 @@ namespace TAO_PEGTL_NAMESPACE::internal
using error_position_t = pointer_position< data_t >;
using offset_position_t = void;
using rewind_position_t = pointer_position< data_t >;
#if defined( __cpp_exceptions )
using parse_error_t = parse_error< error_position_t >;
#endif

view_input( const data_t* b, const data_t* e ) noexcept
: m_current( b ),
Expand Down
21 changes: 9 additions & 12 deletions src/test/pegtl/buffer_cstream_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "test.hpp"

#include <tao/pegtl/buffer.hpp>
#include <tao/pegtl/internal/read_file_stdio.hpp>

namespace TAO_PEGTL_NAMESPACE
{
Expand All @@ -23,25 +24,21 @@ namespace TAO_PEGTL_NAMESPACE
{
const char* const filename = "src/test/pegtl/file_data.txt";
{
#if defined( _MSC_VER )
std::FILE* stream;
::fopen_s( &stream, filename, "rb" );
#else
std::FILE* stream = std::fopen( filename, "rb" );
#endif
std::FILE* stream = internal::read_file_open( filename );
TAO_PEGTL_TEST_ASSERT( stream != nullptr );
const std::string content = internal::read_file_stdio( stream, filename ).read_string(); // Closes stream unless c'tor throws while copying filename -- not a problem here.
TAO_PEGTL_TEST_ASSERT( content.size() == 154 );
}
{
std::FILE* stream = internal::read_file_open( filename );
TAO_PEGTL_TEST_ASSERT( stream != nullptr );
static_cstream_input< void > in( stream );
TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in ) );
TAO_PEGTL_TEST_ASSERT( in.empty() );
std::fclose( stream );
}
{
#if defined( _MSC_VER )
std::FILE* stream;
::fopen_s( &stream, filename, "rb" );
#else
std::FILE* stream = std::fopen( filename, "rb" );
#endif
std::FILE* stream = internal::read_file_open( filename );
TAO_PEGTL_TEST_ASSERT( stream != nullptr );
dynamic_cstream_input< void > in( 500, 10, stream );
TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in ) );
Expand Down

0 comments on commit 455ec4a

Please sign in to comment.