allow moving up a node with cd
Change-Id: Id1419fddda4aa2d2c16b5775a43c8df58db98c73
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 746116e..9ab4738 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -11,7 +11,6 @@
#include "CTree.hpp"
#include "parser_context.hpp"
-
struct keyValue_class {
template <typename T, typename Iterator, typename Context>
void on_success(Iterator const&, Iterator const&, T& ast, Context const& context)
@@ -99,6 +98,22 @@
}
};
+
+struct nodeup_class {
+ template <typename T, typename Iterator, typename Context>
+ void on_success(Iterator const&, Iterator const&, T&, Context const& context)
+ {
+ auto& parserContext = x3::get<parser_context_tag>(context);
+
+ if (!parserContext.m_curPath.empty()) {
+ parserContext.m_curPath = stripLastNodeFromPath(parserContext.m_curPath);
+ } else {
+ _pass(context) = false;
+ }
+
+ }
+};
+
struct container_class {
template <typename T, typename Iterator, typename Context>
void on_success(Iterator const&, Iterator const&, T& ast, Context const& context)