summaryrefslogtreecommitdiffhomepage
path: root/grammer.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-02-14 09:17:25 +0100
committerRoland Reichwein <mail@reichwein.it>2020-02-14 09:17:25 +0100
commit991b493afc385de84e916e7e23e9313825d6e6d9 (patch)
tree724981c2de152c6617b103054ecd100e11f805df /grammer.cpp
parent770a74159b05e6c6e0490390fe0f42c20b0ca970 (diff)
Bugfix
Diffstat (limited to 'grammer.cpp')
-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];
}