summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--grammer.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/grammer.cpp b/grammer.cpp
index dc65876..2fc136c 100644
--- a/grammer.cpp
+++ b/grammer.cpp
@@ -249,8 +249,12 @@ void Compiler::RemoveLastNode()
if (node_id == root_node_id) { // No parent -> remove root
if (node.child_ids.empty()) { // No children -> now tree is empty
clear();
+ } else if (ChildIdIsToken(node.child_ids.back())) { // last token child: remove
+ tokens_used--;
+ node.child_ids.pop_back();
} else if (node.child_ids.size() == 1) { // One child: removing possible
if (!ChildIdIsToken(node.child_ids[0])) {
+ // node: set new root
nodes[node.child_ids[0]].parent_node_id = node.child_ids[0];
root_node_id = node.child_ids[0];
}