diff --git a/src/lib/diff/diff-language.hpp b/src/lib/diff/diff-language.hpp index 511108389..724856472 100644 --- a/src/lib/diff/diff-language.hpp +++ b/src/lib/diff/diff-language.hpp @@ -270,6 +270,8 @@ namespace diff{ * target type `TAR` (1st template arg) * @warning the actual language remains unspecified; * it is picked from the visible context. + * @see tree-diff-application.hpp + * @see list-diff-application.hpp */ template class DiffApplicationStrategy; @@ -307,6 +309,7 @@ namespace diff{ target_.initDiffApplication(); for ( ; diff; ++diff ) diff->applyTo(target_); + target_.completeDiffApplication(); } }; diff --git a/src/lib/diff/list-diff-application.hpp b/src/lib/diff/list-diff-application.hpp index a3bb04f38..15f3fc4dc 100644 --- a/src/lib/diff/list-diff-application.hpp +++ b/src/lib/diff/list-diff-application.hpp @@ -171,6 +171,17 @@ namespace diff{ seq_.reserve (orig_.size() * 120 / 100); // heuristics for storage pre-allocation pos_ = orig_.begin(); } + + void + completeDiffApplication() + { + if (not end_of_target()) + throw error::State(_Fmt("Not all source data consumed after diff application. " + "Element %s waiting to be consumed") % *pos_ + , LERR_(DIFF_STRUCTURE)); + // discard storage + orig_.clear(); + } }; diff --git a/src/lib/diff/tree-diff-application.hpp b/src/lib/diff/tree-diff-application.hpp index 2c3b19741..976d6e8fa 100644 --- a/src/lib/diff/tree-diff-application.hpp +++ b/src/lib/diff/tree-diff-application.hpp @@ -271,6 +271,7 @@ namespace diff{ * @throws _unspecified errors_ when delegated operations fail. * @see TreeDiffInterpreter explanation of the verbs * @see DiffComplexApplication_test demonstration of usage + * @see [implementation of the binding functions](\ref tree-diff.cpp) */ class TreeDiffMutatorBinding : public TreeDiffInterpreter @@ -384,6 +385,18 @@ namespace diff{ TreeDiffMutatorBinding::treeMutator_ = &scopes_.currentScope(); REQUIRE (this->treeMutator_); } + + void + completeDiffApplication() + { + if (not treeMutator_->completeScope()) + throw error::State(_Fmt("Unsettled content remains after diff application. " + "Top level == %s") % subject_ + , LERR_(DIFF_STRUCTURE)); + // discard storage + treeMutator_ = nullptr; + scopes_.clear(); + } }; diff --git a/src/lib/diff/tree-diff.cpp b/src/lib/diff/tree-diff.cpp index 8c61b297f..c9fd23782 100644 --- a/src/lib/diff/tree-diff.cpp +++ b/src/lib/diff/tree-diff.cpp @@ -118,7 +118,7 @@ namespace diff{ throw error::State(_Fmt("Diff application floundered in nested scope %s; " "unexpected extra elements found when diff " "should have settled everything.") % idi.getSym() - , LUMIERA_ERROR_DIFF_CONFLICT); + , LUMIERA_ERROR_DIFF_STRUCTURE); } void @@ -127,7 +127,7 @@ namespace diff{ if (0 == scopeManger_->depth()) throw error::Fatal(_Fmt("Diff application floundered after leaving scope %s; " "unbalanced nested scopes, diff attempts to pop root.") % idi.getSym() - , LUMIERA_ERROR_DIFF_CONFLICT); + , LUMIERA_ERROR_DIFF_STRUCTURE); } diff --git a/src/lib/diff/tree-mutator.hpp b/src/lib/diff/tree-mutator.hpp index 7d50a5cd0..ff85cf34b 100644 --- a/src/lib/diff/tree-mutator.hpp +++ b/src/lib/diff/tree-mutator.hpp @@ -84,6 +84,7 @@ ** @see tree-mutator-test.cpp ** @see tree-mutator-binding-test.cpp ** @see [usage for tree diff application](\ref tree-diff-application.hpp) + ** especially `DiffApplicationStrategy>>` defined there ** @see diff-language.hpp ** @see DiffDetector ** diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index be4c54ca3..d6ab7ba1a 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -36283,12 +36283,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +