Fix create/delete/set command crash

These commands crashed when they were given an empty path. Right now,
PathParser is allowed to parse empty paths (an empty string or just a
slash). The parsers that check the last node of a path don't expect the
path to be empty. Right now, I chose this easy fix, but PathParser
probably shouldn't be allowed to parse empty paths in the future (and
empty path should be dealt with in a different way).

Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/171
Change-Id: If0a1b97319307f88e83a07914186b6cf8c61b1d2
diff --git a/src/ast_handlers.hpp b/src/ast_handlers.hpp
index 735700a..4c5bdaa 100644
--- a/src/ast_handlers.hpp
+++ b/src/ast_handlers.hpp
@@ -168,6 +168,12 @@
     {
         auto& parserContext = x3::get<parser_context_tag>(context);
         const auto& schema = parserContext.m_schema;
+        if (ast.m_nodes.empty()) {
+            parserContext.m_errorMsg = "This container is not a presence container.";
+            _pass(context) = false;
+            return;
+        }
+
         try {
             boost::optional<std::string> module;
             if (ast.m_nodes.back().m_prefix)
@@ -191,6 +197,12 @@
     void on_success(Iterator const&, Iterator const&, T& ast, Context const& context)
     {
         auto& parserContext = x3::get<parser_context_tag>(context);
+        if (ast.m_nodes.empty()) {
+            parserContext.m_errorMsg = "This is not a list instance.";
+            _pass(context) = false;
+            return;
+        }
+
         if (ast.m_nodes.back().m_suffix.type() != typeid(listElement_)) {
             parserContext.m_errorMsg = "This is not a list instance.";
             _pass(context) = false;
@@ -235,6 +247,12 @@
     void on_success(Iterator const&, Iterator const&, T&, Context const& context)
     {
         auto& parserContext = x3::get<parser_context_tag>(context);
+        if (parserContext.currentSchemaPath().m_nodes.empty()) {
+            parserContext.m_errorMsg = "This is not a path to leaf.";
+            _pass(context) = false;
+            return;
+        }
+
         try {
             auto lastNode = parserContext.currentSchemaPath().m_nodes.back();
             auto leaf = boost::get<leaf_>(lastNode.m_suffix);