Get rid of m_topLevelModulePresent
This is a remnant from the old-style path parsing, where I parsed
modules separately from node identifiers. Right now, I parse them at the
same time, so I don't need a flag signifying whether the top level
module is present. Also, the node_identifier_class code was a part of a
bug fixed in a later patch.
Change-Id: Ibc28f3871456f0944b73829e524dc379569e3b1e
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 0ab9a35..7d38d73 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -44,19 +44,7 @@
}
};
-struct node_identifier_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_topLevelModulePresent) {
- if (parserContext.m_errorMsg.empty())
- parserContext.m_errorMsg = "You have to specify a top level module.";
- _pass(context) = false;
- }
- }
-};
+struct node_identifier_class;
struct key_identifier_class {
template <typename T, typename Iterator, typename Context>
@@ -130,7 +118,6 @@
if (schema.isModule(ast.m_name)) {
parserContext.m_curModule = ast.m_name;
- parserContext.m_topLevelModulePresent = true;
} else {
parserContext.m_errorMsg = "Invalid module name.";
_pass(context) = false;
diff --git a/src/parser_context.cpp b/src/parser_context.cpp
index 6b15cb9..723fbae 100644
--- a/src/parser_context.cpp
+++ b/src/parser_context.cpp
@@ -13,14 +13,11 @@
, m_dataquery(dataQuery)
, m_curPath(curDir)
{
- if (!currentDataPath().m_nodes.empty() && currentDataPath().m_nodes.at(0).m_prefix)
- m_topLevelModulePresent = true;
}
void ParserContext::clearPath()
{
m_curPath = dataPath_{Scope::Absolute, {}};
- m_topLevelModulePresent = false;
}
schemaPath_ ParserContext::currentSchemaPath()
@@ -42,12 +39,9 @@
void ParserContext::pushPathFragment(const dataNode_& node)
{
- auto pushNode = [this] (auto& where, const auto& what) {
+ auto pushNode = [] (auto& where, const auto& what) {
if (std::holds_alternative<nodeup_>(what.m_suffix)) {
where.m_nodes.pop_back();
- if (where.m_nodes.empty()) {
- m_topLevelModulePresent = false;
- }
} else {
where.m_nodes.push_back(what);
}
@@ -67,13 +61,9 @@
}
boost::get<schemaPath_>(m_curPath).m_nodes.push_back(node);
- if (currentSchemaPath().m_nodes.empty()) {
- m_topLevelModulePresent = false;
- }
}
void ParserContext::resetPath()
{
m_curPath = m_curPathOrig;
- m_topLevelModulePresent = !currentDataPath().m_nodes.empty() && currentDataPath().m_nodes.at(0).m_prefix;
}
diff --git a/src/parser_context.hpp b/src/parser_context.hpp
index 87706a5..9ef9d80 100644
--- a/src/parser_context.hpp
+++ b/src/parser_context.hpp
@@ -26,7 +26,6 @@
boost::optional<std::string> m_curModule;
std::string m_errorMsg;
std::string m_tmpListName;
- bool m_topLevelModulePresent = false;
struct {
schemaPath_ m_location;
diff --git a/src/path_parser.hpp b/src/path_parser.hpp
index bb622ef..b978d71 100644
--- a/src/path_parser.hpp
+++ b/src/path_parser.hpp
@@ -219,7 +219,6 @@
if (res) {
parserContext.pushPathFragment(attr);
- parserContext.m_topLevelModulePresent = true;
}
if (attr.m_prefix) {