Allow data path to end with a list for get and ls
Change-Id: I3facc8315fa6192da4318012a85121de37e7314b
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index c670168..0cb64f1 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -201,6 +201,8 @@
}
};
+struct dataNodeList_class;
+
struct dataNode_class {
template <typename T, typename Iterator, typename Context>
void on_success(Iterator const&, Iterator const&, T& ast, Context const& context)
@@ -226,6 +228,10 @@
}
};
+struct dataNodesListEnd_class;
+
+struct dataPathListEnd_class;
+
struct dataPath_class {
template <typename Iterator, typename Exception, typename Context>
x3::error_handler_result on_error(Iterator&, Iterator const&, Exception const&, Context const& context)
@@ -332,7 +338,7 @@
leaf_ leaf = boost::get<leaf_>(parserContext.m_curPath.m_nodes.back().m_suffix);
schemaPath_ location = pathWithoutLastNode(parserContext.m_curPath);
if (location.m_nodes.empty()) {
- parserContext.m_curModule = parserContext.m_curPath.m_nodes.back().m_prefix->m_name;
+ parserContext.m_curModule = parserContext.m_curPath.m_nodes.back().m_prefix->m_name;
}
parserContext.m_errorMsg = "Expected " + leafDataTypeToString(schema.leafType(location, {parserContext.m_curModule, leaf.m_name})) + " here:";
return x3::error_handler_result::fail;
@@ -455,3 +461,18 @@
return x3::error_handler_result::fail;
}
};
+
+struct initializeContext_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);
+ parserContext.m_curPath = parserContext.m_curPathOrig;
+ parserContext.m_tmpListKeys.clear();
+ parserContext.m_tmpListName.clear();
+ if (!parserContext.m_curPath.m_nodes.empty() && parserContext.m_curPath.m_nodes.at(0).m_prefix)
+ parserContext.m_topLevelModulePresent = true;
+ else
+ parserContext.m_topLevelModulePresent = false;
+ }
+};