Skip to content

Commit

Permalink
Update PEGTL.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Sep 23, 2023
1 parent 75032c5 commit d243d30
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/tao/config/internal/json_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace tao::config::internal
pegtl::position position;

json_base()
: position( pegtl::internal::frobnicator{ nullptr, 1, 1, 1 }, "TODO: Delete the default c'tor!" )
: position( pegtl::internal::inputerator{ nullptr, 1, 1, 1 }, "TODO: Delete the default c'tor!" )
{}
// json_base() = delete;

Expand Down
9 changes: 5 additions & 4 deletions include/tao/config/internal/try_catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <iostream>
#include <stdexcept>

#include <tao/pegtl/contrib/nested_exceptions.hpp>

#include "pegtl.hpp"
#include "reverse.hpp"

Expand All @@ -18,12 +20,11 @@ namespace tao::config::internal
try {
f();
}
catch( const pegtl::parse_error& e ) {
catch( const pegtl::parse_error& ) {
std::cerr << "*** config parse error ***" << std::endl;
for( const auto& p : reverse( e.positions() ) ) {
std::cerr << " at " << p << std::endl;
for( const auto& e : pegtl::nested::flatten() ) {
std::cerr << e.message() << ": " << e.position_string() << std::endl;
}
std::cerr << e.message() << std::endl;
}
catch( const std::exception& e ) {
std::cerr << "*** config error ***" << std::endl;
Expand Down
11 changes: 5 additions & 6 deletions src/test/config/failure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include <tao/config.hpp>

#include <tao/pegtl/contrib/nested_exceptions.hpp>

const char* ansi_reset = "\033[0m";
const char* ansi_message = "\033[1;31m";
const char* ansi_source = "\033[36m";
Expand All @@ -29,12 +31,9 @@ namespace tao
std::cerr << ccs << std::endl;
std::cerr << ">>> Config parsed as config >>>" << std::endl;
}
catch( const pegtl::parse_error& e ) {
const auto& pos = e.positions();
auto it = pos.begin();
std::cout << ansi_text << "pegtl::parse_error: " << ansi_source << *it << ": " << ansi_message << e.message() << ansi_reset << std::endl;
while( ++it != pos.end() ) {
std::cout << ansi_text << " from: " << ansi_source << *it << ansi_reset << std::endl;
catch( const pegtl::parse_error& ) {
for( const auto& e : pegtl::nested::flatten() ) {
std::cout << ansi_text << "pegtl::parse_error: " << ansi_message << e.message() << ": " << ansi_source << e.position_string() << ansi_reset << std::endl;
}
}
catch( const std::exception& e ) {
Expand Down

0 comments on commit d243d30

Please sign in to comment.