From 3616d330de7c3388fd2f35409fed9fbd06d180db Mon Sep 17 00:00:00 2001 From: "Dr. Colin Hirsch" Date: Thu, 4 Apr 2024 19:51:30 +0200 Subject: [PATCH] Small changes. --- include/tao/config/internal/debug_traits.hpp | 2 +- include/tao/config/internal/phase2_additions.hpp | 2 +- include/tao/config/internal/phase2_everything.hpp | 2 +- include/tao/config/internal/phase3_remove.hpp | 12 ++---------- tests/complex_02.failure | 10 ++++++---- tests/complex_03.failure | 2 ++ 6 files changed, 13 insertions(+), 17 deletions(-) create mode 100644 tests/complex_03.failure diff --git a/include/tao/config/internal/debug_traits.hpp b/include/tao/config/internal/debug_traits.hpp index 9c20db3..7f01e83 100644 --- a/include/tao/config/internal/debug_traits.hpp +++ b/include/tao/config/internal/debug_traits.hpp @@ -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" ); diff --git a/include/tao/config/internal/phase2_additions.hpp b/include/tao/config/internal/phase2_additions.hpp index 93fcc7b..7200a8a 100644 --- a/include/tao/config/internal/phase2_additions.hpp +++ b/include/tao/config/internal/phase2_additions.hpp @@ -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 ) diff --git a/include/tao/config/internal/phase2_everything.hpp b/include/tao/config/internal/phase2_everything.hpp index 6476dce..1e5d5e6 100644 --- a/include/tao/config/internal/phase2_everything.hpp +++ b/include/tao/config/internal/phase2_everything.hpp @@ -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. } } diff --git a/include/tao/config/internal/phase3_remove.hpp b/include/tao/config/internal/phase3_remove.hpp index 8a5690e..19dc64c 100644 --- a/include/tao/config/internal/phase3_remove.hpp +++ b/include/tao/config/internal/phase3_remove.hpp @@ -4,6 +4,7 @@ #ifndef TAO_CONFIG_INTERNAL_PHASE3_REMOVE_HPP #define TAO_CONFIG_INTERNAL_PHASE3_REMOVE_HPP +#include #include #include @@ -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 ) diff --git a/tests/complex_02.failure b/tests/complex_02.failure index 1725cf7..8f3e014 100644 --- a/tests/complex_02.failure +++ b/tests/complex_02.failure @@ -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) diff --git a/tests/complex_03.failure b/tests/complex_03.failure new file mode 100644 index 0000000..73be71c --- /dev/null +++ b/tests/complex_03.failure @@ -0,0 +1,2 @@ +a = (default (b) "foo") + "a" +b = (default (a) "bar") + "b"