Add a real path computation

Many commands need a path as an argument. This path can be absolute or
relative. The key is to understand where the command will operate. For
example, when using `cd`, we need to know where we'll end up after
running the command.  And with `set`, we want to know what will be
modified. This change creates a general function called realPath() that
takes the current working directory (cwd) and the given path as
arguments, and then gives back the final path.  Doing this makes the
code easier to read and more compact because we'll use it several times
in the next changes.

Change-Id: Id940062525b64eed1de438407ff8ae2cfbcdde6d
diff --git a/src/ast_path.cpp b/src/ast_path.cpp
index e0348db..b34817b 100644
--- a/src/ast_path.cpp
+++ b/src/ast_path.cpp
@@ -359,3 +359,16 @@
     impl_pushFragment(m_nodes, fragment);
     validatePathNodes(m_nodes);
 }
+
+dataPath_ realPath(const dataPath_& cwd, const dataPath_& newPath)
+{
+    if (newPath.m_scope == Scope::Absolute) {
+        return newPath;
+    }
+
+    dataPath_ res = cwd;
+    for (const auto& it : newPath.m_nodes) {
+        res.pushFragment(it);
+    }
+    return res;
+}
diff --git a/src/ast_path.hpp b/src/ast_path.hpp
index e7df783..2da836f 100644
--- a/src/ast_path.hpp
+++ b/src/ast_path.hpp
@@ -154,6 +154,9 @@
 schemaPath_ dataPathToSchemaPath(const dataPath_& path);
 std::string escapeListKeyString(const std::string& what);
 
+// @brief Combining the current working directory with a new path, this function returns the resulting absolute path
+dataPath_ realPath(const dataPath_& cwd, const dataPath_& newPath);
+
 BOOST_FUSION_ADAPT_STRUCT(container_, m_name)
 BOOST_FUSION_ADAPT_STRUCT(listElement_, m_name, m_keys)
 BOOST_FUSION_ADAPT_STRUCT(leafListElement_, m_name, m_value)
diff --git a/src/parser.cpp b/src/parser.cpp
index 982be11..1547478 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -85,13 +85,7 @@
 
 void Parser::changeNode(const dataPath_& name)
 {
-    if (name.m_scope == Scope::Absolute) {
-        m_curDir = name;
-    } else {
-        for (const auto& it : name.m_nodes) {
-            m_curDir.pushFragment(it);
-        }
-    }
+    m_curDir = realPath(m_curDir, name);
 }
 
 std::string Parser::currentNode() const