summaryrefslogtreecommitdiffhomepage
path: root/grammer.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-02-08 12:58:01 +0100
committerRoland Reichwein <mail@reichwein.it>2020-02-08 12:58:01 +0100
commit047a1ae14c75ce08ca04e67452eaebf89a1076d9 (patch)
treecc3a80d12e31e5f915f7bfd836f0ef6d9b8876b9 /grammer.cpp
parent2114083569546d6af32e8c638b3ebf677c433123 (diff)
Fix syntax errors
Diffstat (limited to 'grammer.cpp')
-rw-r--r--grammer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/grammer.cpp b/grammer.cpp
index 8a4f6b7..4118733 100644
--- a/grammer.cpp
+++ b/grammer.cpp
@@ -210,19 +210,22 @@ void Compiler::RemoveLastNode()
index_t node_id = node.node_id;
if (node_id == root_node_id) { // No parent -> remove root
- if (node.child_ids().empty()) { // No children -> now empty
+ if (node.child_ids.empty()) { // No children -> now empty
clear();
- } else if (node.child_ids().size() == 1) { // One child: removing possible
- root_node_id = node.child_ids()[0];
+ } else if (node.child_ids.size() == 1) { // One child: removing possible
+ if (!ChildIdIsToken(node.child_ids[0])) {
+ nodes[node.child_ids[0]].parent_node_id = node.child_ids[0];
+ root_node_id = node.child_ids[0];
+ }
nodes.pop_back();
} else
throw std::runtime_error("Backtrack not possible: Root not empty"); // ICE
- } else if (node.child_ids().empty()) { // No children -> remove leaf
+ } else if (node.child_ids.empty()) { // No children -> remove leaf
// We have a parent, otherwise we would have taken previous branch
TreeNode& parent {nodes[node.parent_node_id]};
- if (parent.child_ids().empty() || parent.child_ids().last() != node_id)
+ if (parent.child_ids.empty() || parent.child_ids.last() != node_id)
throw std::runtime_error("Backtrack: Bad child nodes"); // ICE
- parent.childs_ids().pop_back();
+ parent.childs_ids.pop_back();
nodes.pop_back();
} else { // In the middle
throw std::runtime_error("Backtrack in the middle of the tree."); // ICE