diff options
author | robot-piglet <[email protected]> | 2023-12-04 15:32:14 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2023-12-05 01:22:50 +0300 |
commit | c21ed9eedf73010bc81342518177dfdfb0d56bd7 (patch) | |
tree | 72f8fde4463080cfe5a38eb0babc051cfe32c51e /contrib/libs/antlr4_cpp_runtime/src/CommonTokenStream.cpp | |
parent | ec1311bf2e8cc231723b8b5e484ca576663a1309 (diff) |
Intermediate changes
Diffstat (limited to 'contrib/libs/antlr4_cpp_runtime/src/CommonTokenStream.cpp')
-rw-r--r-- | contrib/libs/antlr4_cpp_runtime/src/CommonTokenStream.cpp | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/contrib/libs/antlr4_cpp_runtime/src/CommonTokenStream.cpp b/contrib/libs/antlr4_cpp_runtime/src/CommonTokenStream.cpp deleted file mode 100644 index 02a2e55af3e..00000000000 --- a/contrib/libs/antlr4_cpp_runtime/src/CommonTokenStream.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. - * Use of this file is governed by the BSD 3-clause license that - * can be found in the LICENSE.txt file in the project root. - */ - -#include "Token.h" - -#include "CommonTokenStream.h" - -using namespace antlr4; - -CommonTokenStream::CommonTokenStream(TokenSource *tokenSource) : CommonTokenStream(tokenSource, Token::DEFAULT_CHANNEL) { -} - -CommonTokenStream::CommonTokenStream(TokenSource *tokenSource, size_t channel_) -: BufferedTokenStream(tokenSource), channel(channel_) { -} - -ssize_t CommonTokenStream::adjustSeekIndex(size_t i) { - return nextTokenOnChannel(i, channel); -} - -Token* CommonTokenStream::LB(size_t k) { - if (k == 0 || k > _p) { - return nullptr; - } - - ssize_t i = static_cast<ssize_t>(_p); - size_t n = 1; - // find k good tokens looking backwards - while (n <= k) { - // skip off-channel tokens - i = previousTokenOnChannel(i - 1, channel); - n++; - } - if (i < 0) { - return nullptr; - } - - return _tokens[i].get(); -} - -Token* CommonTokenStream::LT(ssize_t k) { - lazyInit(); - if (k == 0) { - return nullptr; - } - if (k < 0) { - return LB(static_cast<size_t>(-k)); - } - size_t i = _p; - ssize_t n = 1; // we know tokens[p] is a good one - // find k good tokens - while (n < k) { - // skip off-channel tokens, but make sure to not look past EOF - if (sync(i + 1)) { - i = nextTokenOnChannel(i + 1, channel); - } - n++; - } - - return _tokens[i].get(); -} - -int CommonTokenStream::getNumberOfOnChannelTokens() { - int n = 0; - fill(); - for (size_t i = 0; i < _tokens.size(); i++) { - Token *t = _tokens[i].get(); - if (t->getChannel() == channel) { - n++; - } - if (t->getType() == Token::EOF) { - break; - } - } - return n; -} |