| 330 | } |
| 331 | |
| 332 | std::size_t LuaSyntaxTree::GetPrevToken(std::size_t index) const { |
| 333 | if (index == 0) { |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | if (index < _nodeOrTokens.size()) { |
| 338 | auto &n = _nodeOrTokens[index]; |
| 339 | if (n.Type == NodeOrTokenType::Token) { |
| 340 | auto tokenIndex = n.Data.TokenIndex; |
| 341 | if (tokenIndex != 0) { |
| 342 | return _tokens[tokenIndex - 1].NodeIndex; |
| 343 | } |
| 344 | } else {// Node, 可能存在无元素节点 |
| 345 | for (auto nodeIndex = index - 1; nodeIndex > 0; nodeIndex--) { |
| 346 | if (IsToken(nodeIndex)) { |
| 347 | return nodeIndex; |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | std::size_t LuaSyntaxTree::GetNextToken(std::size_t index) const { |
| 356 | if (index == 0) { |
no test coverage detected