diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-02-16 00:18:37 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-02-16 00:18:37 +0100 |
commit | 87793f331c632ee527915805a0c92a94a534ba37 (patch) | |
tree | 3e747075d819c07c2b6b59982108f60a5d8b8159 /src/core/parser/stack/Stack.cpp | |
parent | fbcdbd6ea539520826492501be87823bae1f475d (diff) |
Fixed problem with fieldEnd closing implicit fields and added unit test
Diffstat (limited to 'src/core/parser/stack/Stack.cpp')
-rw-r--r-- | src/core/parser/stack/Stack.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/core/parser/stack/Stack.cpp b/src/core/parser/stack/Stack.cpp index 47f7d2c..905edb4 100644 --- a/src/core/parser/stack/Stack.cpp +++ b/src/core/parser/stack/Stack.cpp @@ -322,7 +322,8 @@ void Stack::command(const Variant &name, const Variant::mapType &args) // to create an empty default field, otherwise this is an exception const State *targetState = findTargetStateOrWildcard(name.asString()); if (targetState == nullptr) { - if (!currentInfo().inField) { + HandlerInfo &info = currentInfo(); + if (info.inImplicitDefaultField || !info.inField) { endCurrentHandler(); continue; } else { @@ -397,7 +398,7 @@ void Stack::data(const Variant &data) while (true) { // Check whether there is any command the data can be sent to if (stack.empty()) { - throw LoggableException("No command here to receive data."); + throw LoggableException("No command here to receive data.", data); } // Fetch the current command handler information @@ -497,14 +498,23 @@ void Stack::fieldStart(bool isDefault) void Stack::fieldEnd() { - // Make sure the current handler stack is not empty + // Check whether there is any command the data can be sent to if (stack.empty()) { - throw LoggableException("No command for which a field could be ended"); + throw LoggableException("No command, but got end of field."); + } + + // Unroll the stack until the next explicitly open field + while (!stack.empty()) { + HandlerInfo &info = currentInfo(); + if (info.inField && !info.inImplicitDefaultField) { + break; + } + endCurrentHandler(); } // Fetch the information attached to the current handler HandlerInfo &info = currentInfo(); - if (!info.inField) { + if (!info.inField || info.inImplicitDefaultField || stack.empty()) { logger().error( "Got field end, but there is no command for which to end the " "field."); |