| 163 | } |
| 164 | |
| 165 | void LuaSyntaxTree::BuildToken(LuaToken &token) { |
| 166 | auto currentNodePos = _nodeOrTokens.size(); |
| 167 | auto currentTokenPos = _tokens.size(); |
| 168 | |
| 169 | _tokens.emplace_back(token, currentNodePos); |
| 170 | auto ¤tToken = _nodeOrTokens.emplace_back(currentTokenPos); |
| 171 | if (!_nodePosStack.empty()) { |
| 172 | auto parentIndex = _nodePosStack.top(); |
| 173 | auto &parentNode = _nodeOrTokens[parentIndex]; |
| 174 | if (parentNode.FirstChild == 0) { |
| 175 | parentNode.FirstChild = currentNodePos; |
| 176 | parentNode.LastChild = currentNodePos; |
| 177 | } else { |
| 178 | auto &lastNode = _nodeOrTokens[parentNode.LastChild]; |
| 179 | lastNode.NextSibling = currentNodePos; |
| 180 | currentToken.PrevSibling = parentNode.LastChild; |
| 181 | parentNode.LastChild = currentNodePos; |
| 182 | } |
| 183 | currentToken.Parent = parentIndex; |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | const LuaSource &LuaSyntaxTree::GetFile() const { |
| 188 | return *_source; |