| 142 | } |
| 143 | |
| 144 | void LuaSyntaxTree::BuildNode(LuaSyntaxNodeKind kind) { |
| 145 | auto currentPos = _nodeOrTokens.size(); |
| 146 | auto ¤tNode = _nodeOrTokens.emplace_back(kind); |
| 147 | if (!_nodePosStack.empty()) { |
| 148 | auto parentIndex = _nodePosStack.top(); |
| 149 | auto &parentNode = _nodeOrTokens[parentIndex]; |
| 150 | if (parentNode.FirstChild == 0) { |
| 151 | parentNode.FirstChild = currentPos; |
| 152 | parentNode.LastChild = currentPos; |
| 153 | } else { |
| 154 | auto &lastNode = _nodeOrTokens[parentNode.LastChild]; |
| 155 | lastNode.NextSibling = currentPos; |
| 156 | currentNode.PrevSibling = parentNode.LastChild; |
| 157 | parentNode.LastChild = currentPos; |
| 158 | } |
| 159 | currentNode.Parent = parentIndex; |
| 160 | } |
| 161 | |
| 162 | _nodePosStack.push(currentPos); |
| 163 | } |
| 164 | |
| 165 | void LuaSyntaxTree::BuildToken(LuaToken &token) { |
| 166 | auto currentNodePos = _nodeOrTokens.size(); |