diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-04-11 16:51:38 +0200 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2016-04-25 22:24:14 +0200 |
commit | d369ff33faa4bf5654db3f1eb105141fccf2270d (patch) | |
tree | dd09b8f9a628d055b36b96b3fca9b4b407c1413d /src/core/parser/stack/Handler.cpp | |
parent | 994615f76b86a65f11829863be96c63135eef977 (diff) |
Reimplement closeToken handling
Idea: Only start unrolling anything on the parser stack
if an element that matches the given close token is found.
This requires the endToken method in DocumentChildHandler
to search for the given descriptor that might be ended.
While performing this search, only a specified number of
"explicit" structures/fields opened by the Stack class may
be skipped (those with implicit default fields).
Added an integration test ("python_code") which requires
this new (hopefully sane) behaviour.
Diffstat (limited to 'src/core/parser/stack/Handler.cpp')
-rw-r--r-- | src/core/parser/stack/Handler.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core/parser/stack/Handler.cpp b/src/core/parser/stack/Handler.cpp index 1399fef..69bfc76 100644 --- a/src/core/parser/stack/Handler.cpp +++ b/src/core/parser/stack/Handler.cpp @@ -47,7 +47,8 @@ Handler::Handler(const HandlerData &handlerData) { } -Handler::~Handler() { +Handler::~Handler() +{ while (tokenStackDepth > 0) { popTokens(); } @@ -90,7 +91,8 @@ void Handler::pushTokens(const std::vector<SyntaxDescriptor> &tokens) handlerData.callbacks.pushTokens(tokens); } -void Handler::popTokens() { +void Handler::popTokens() +{ assert(tokenStackDepth > 0 && "popTokens called too often"); tokenStackDepth--; handlerData.callbacks.popTokens(); @@ -133,11 +135,10 @@ bool EmptyHandler::startToken(Handle<Node> node) return false; } -Handler::EndTokenResult EmptyHandler::endToken(const Token &token, - Handle<Node> node) +EndTokenResult EmptyHandler::endToken(Handle<Node> node, size_t maxStackDepth) { // There are no tokens to end here. - return EndTokenResult::ENDED_NONE; + return EndTokenResult(); } void EmptyHandler::end() @@ -179,10 +180,10 @@ bool StaticHandler::startAnnotation(Variant::mapType &args) { return false; } bool StaticHandler::startToken(Handle<Node> node) { return false; } -Handler::EndTokenResult StaticHandler::endToken(const Token &token, - Handle<Node> node) +EndTokenResult StaticHandler::endToken(Handle<Node> node, size_t maxStackDepth) { - return EndTokenResult::ENDED_NONE; + // There are no tokens to end here. + return EndTokenResult(); } void StaticHandler::end() |