Skip to content

Commit

Permalink
Small changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH committed Apr 4, 2024
1 parent 2614b21 commit 3616d33
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion include/tao/config/internal/debug_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ namespace tao::config::internal
c.string( "object" );
return;
case entry_kind::ASTERISK:
c.string( "concat" );
c.string( "asterisk" );
return;
case entry_kind::REFERENCE:
c.string( "reference" );
Expand Down
2 changes: 1 addition & 1 deletion include/tao/config/internal/phase2_additions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace tao::config::internal

[[noreturn]] static void throw_type_error( const entry& l, const entry& r )
{
throw pegtl::parse_error( strcat( "incompatible or invalid type(s) in addition ", l.kind(), "@", l.get_position(), " and ", r.kind(), "@", r.get_position() ), pegtl::position( 0, 0, 0, "(todo) location of '+'" ) );
throw pegtl::parse_error( strcat( "incompatible or invalid type(s) in addition ", l.kind(), "@", l.get_position(), " and ", r.kind(), "@", r.get_position() ), pegtl::position( 0, 0, 0, "TODO: location of '+'" ) );
}

static void process_object( object&& l, object& r )
Expand Down
2 changes: 1 addition & 1 deletion include/tao/config/internal/phase2_everything.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace tao::config::internal
inline void phase2_everything( state& st, const function_map& fm )
{
while( phase2_iteration( st, fm ) ) {
// This loop could do with some major optimisations; might or might not be worth the effort.
// This loop could do with some major optimisations; probably not worth the effort for config files.
}
}

Expand Down
12 changes: 2 additions & 10 deletions include/tao/config/internal/phase3_remove.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifndef TAO_CONFIG_INTERNAL_PHASE3_REMOVE_HPP
#define TAO_CONFIG_INTERNAL_PHASE3_REMOVE_HPP

#include <cassert>
#include <stdexcept>
#include <string>

Expand Down Expand Up @@ -42,21 +43,12 @@ namespace tao::config::internal
phase3_remove( e.get_object() );
continue;
case entry_kind::ASTERISK:
throw pegtl::parse_error( "asterisk could not be expanded", e.get_asterisk().position ); // Can happen when there are also unresolved references.
throw pegtl::parse_error( "asterisk could not be expanded", e.get_asterisk().position ); // Can happen when there are also unresolved references?
case entry_kind::REFERENCE:
throw pegtl::parse_error( "reference '" + e.get_reference().to_string() + "' could not be resolved", e.get_reference().at( 0 ).position );
}
throw std::logic_error( "code should be unreachable" ); // LCOV_EXCL_LINE
}
if( c.concat.size() > 1 ) {
auto i = c.concat.begin();
const auto lt = to_string( i->kind() );
const auto& lp = i->get_position();
++i;
const auto rt = to_string( i->kind() );
const auto& rp = i->get_position();
throw pegtl::parse_error( strcat( "incompatible types ", lt, "@", lp, " and ", rt, "@", rp ), c.position );
}
}

inline void phase3_remove( array& a )
Expand Down
10 changes: 6 additions & 4 deletions tests/complex_02.failure
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
a = {}
a.* = 42
a.a.b = (default (a.a.c) "foo")
a.a.c = (default (a.a.b) "bar")
x.* = 3
x.a += 1

a = 2
y.a = 1
y.* += (a)
2 changes: 2 additions & 0 deletions tests/complex_03.failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a = (default (b) "foo") + "a"
b = (default (a) "bar") + "b"

0 comments on commit 3616d33

Please sign in to comment.