add test for basic cd parsing
Change-Id: If35d62e323d48db11dc4128fb5c2898ef4ef63a6
diff --git a/src/ast.cpp b/src/ast.cpp
index d9964ea..762c7cc 100644
--- a/src/ast.cpp
+++ b/src/ast.cpp
@@ -1,35 +1,36 @@
/*
* Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
+ * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
*
* Written by Václav Kubernát <kubervac@fit.cvut.cz>
*
*/
#include "ast.hpp"
-
-
-template <typename T, typename Iterator, typename Context>
-inline void container_class::on_success(Iterator const& first, Iterator const& last
- , T& ast, Context const& context)
+container_::container_(const std::string& name)
+ : m_name(name)
{
- ast.m_name = ast.m_first + ast.m_name;
- //std::cout <<"parsed " << ast.m_name << "(container)\n";
}
-template <typename T, typename Iterator, typename Context>
-inline void path_class::on_success(Iterator const& first, Iterator const& last
- , T& ast, Context const& context)
+bool container_::operator==(const container_& b) const
{
- //std::cout << "parsed path:" << std::endl;
- //for (auto it : ast.m_nodes)
- //std::cout << it.m_name << std::endl;
+ return this->m_name == b.m_name;
}
-template <typename T, typename Iterator, typename Context>
-inline void cd_class::on_success(Iterator const& first, Iterator const& last
- , T& ast, Context const& context)
+bool path_::operator==(const path_& b) const
{
- //std::cout << "parsed cd! final path:" << std::endl;
- //for (auto it : ast.m_path.m_nodes)
- //std::cout << it.m_name << std::endl;
+ if (this->m_nodes.size() != b.m_nodes.size())
+ return false;
+ return this->m_nodes == b.m_nodes;
+}
+bool cd_::operator==(const cd_& b) const
+{
+ return this->m_path == b.m_path;
+}
+
+
+ParserContext::ParserContext(const CTree& tree)
+ : m_tree(tree)
+{
+ m_curPath = m_tree.currentNode();
}