forked from jasder/antlr
Consequently use static_cast for (s)size_t casts.
Also fixed XCode tests.
This commit is contained in:
parent
6319d62409
commit
8149ff77fa
|
@ -91,7 +91,7 @@ using namespace antlr4::misc;
|
|||
|
||||
- (void)testANTLRInputStreamUse {
|
||||
std::string text(u8"🚧Lorem ipsum dolor sit amet🕶");
|
||||
std::u32string wtext = utfConverter.from_bytes(text); // Convert to UTF-32.
|
||||
std::u32string wtext = utf8_to_utf32(text.c_str(), text.c_str() + text.size()); // Convert to UTF-32.
|
||||
ANTLRInputStream stream(text);
|
||||
XCTAssertEqual(stream.index(), 0U);
|
||||
XCTAssertEqual(stream.size(), wtext.size());
|
||||
|
@ -116,8 +116,8 @@ using namespace antlr4::misc;
|
|||
|
||||
XCTAssertEqual(stream.LA(0), 0ULL);
|
||||
for (size_t i = 1; i < wtext.size(); ++i) {
|
||||
XCTAssertEqual(stream.LA((ssize_t)i), wtext[i - 1]); // LA(1) means: current char.
|
||||
XCTAssertEqual(stream.LT((ssize_t)i), wtext[i - 1]); // LT is mapped to LA.
|
||||
XCTAssertEqual(stream.LA(static_cast<ssize_t>(i)), wtext[i - 1]); // LA(1) means: current char.
|
||||
XCTAssertEqual(stream.LT(static_cast<ssize_t>(i)), wtext[i - 1]); // LT is mapped to LA.
|
||||
XCTAssertEqual(stream.index(), 0U); // No consumption when looking ahead.
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ using namespace antlr4::misc;
|
|||
XCTAssertEqual(stream.index(), wtext.size() / 2);
|
||||
|
||||
stream.seek(wtext.size() - 1);
|
||||
for (ssize_t i = 1; i < (ssize_t)wtext.size() - 1; ++i) {
|
||||
for (ssize_t i = 1; i < static_cast<ssize_t>(wtext.size()) - 1; ++i) {
|
||||
XCTAssertEqual(stream.LA(-i), wtext[wtext.size() - i - 1]); // LA(-1) means: previous char.
|
||||
XCTAssertEqual(stream.LT(-i), wtext[wtext.size() - i - 1]); // LT is mapped to LA.
|
||||
XCTAssertEqual(stream.index(), wtext.size() - 1); // No consumption when looking ahead.
|
||||
|
@ -150,7 +150,7 @@ using namespace antlr4::misc;
|
|||
|
||||
misc::Interval interval1(2, 10UL); // From - to, inclusive.
|
||||
std::string output = stream.getText(interval1);
|
||||
std::string sub = utfConverter.to_bytes(wtext.substr(2, 9));
|
||||
std::string sub = utf32_to_utf8(wtext.substr(2, 9));
|
||||
XCTAssertEqual(output, sub);
|
||||
|
||||
misc::Interval interval2(200, 10UL); // Start beyond bounds.
|
||||
|
|
|
@ -92,7 +92,7 @@ using namespace antlrcpp;
|
|||
// in a deterministic and a random sequence of 100K values each.
|
||||
std::set<size_t> hashs;
|
||||
for (size_t i = 0; i < 100000; ++i) {
|
||||
std::vector<size_t> data = { i, (size_t)(i * M_PI), arc4random()};
|
||||
std::vector<size_t> data = { i, static_cast<size_t>(i * M_PI), arc4random() };
|
||||
size_t hash = 0;
|
||||
for (auto value : data)
|
||||
hash = MurmurHash::update(hash, value);
|
||||
|
@ -103,7 +103,7 @@ using namespace antlrcpp;
|
|||
|
||||
hashs.clear();
|
||||
for (size_t i = 0; i < 100000; ++i) {
|
||||
std::vector<size_t> data = { i, (size_t)(i * M_PI)};
|
||||
std::vector<size_t> data = { i, static_cast<size_t>(i * M_PI) };
|
||||
size_t hash = 0;
|
||||
for (auto value : data)
|
||||
hash = MurmurHash::update(hash, value);
|
||||
|
@ -232,19 +232,25 @@ using namespace antlrcpp;
|
|||
{ 78, Interval(1000, 1000UL), Interval(20, 100UL), { false, false, true, true, false, true, false, false } },
|
||||
|
||||
// It's possible to add more tests with borders that touch each other (e.g. first starts before/on/after second
|
||||
// and first ends directly before/after second. However, such cases are not handled differently in the Interval class
|
||||
// and first ends directly before/after second. However, such cases are not handled differently in the Interval
|
||||
// class
|
||||
// (only adjacent intervals, where first ends directly before second starts and vice versa. So I ommitted them here.
|
||||
};
|
||||
|
||||
for (auto &entry : testData) {
|
||||
XCTAssert(entry.interval1.startsBeforeDisjoint(entry.interval2) == entry.results[0], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsBeforeNonDisjoint(entry.interval2) == entry.results[1], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsBeforeDisjoint(entry.interval2) == entry.results[0], @"entry: %zu",
|
||||
entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsBeforeNonDisjoint(entry.interval2) == entry.results[1], @"entry: %zu",
|
||||
entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsAfter(entry.interval2) == entry.results[2], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsAfterDisjoint(entry.interval2) == entry.results[3], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsAfterNonDisjoint(entry.interval2) == entry.results[4], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsAfterDisjoint(entry.interval2) == entry.results[3], @"entry: %zu",
|
||||
entry.runningNumber);
|
||||
XCTAssert(entry.interval1.startsAfterNonDisjoint(entry.interval2) == entry.results[4], @"entry: %zu",
|
||||
entry.runningNumber);
|
||||
XCTAssert(entry.interval1.disjoint(entry.interval2) == entry.results[5], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.adjacent(entry.interval2) == entry.results[6], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.properlyContains(entry.interval2) == entry.results[7], @"entry: %zu", entry.runningNumber);
|
||||
XCTAssert(entry.interval1.properlyContains(entry.interval2) == entry.results[7], @"entry: %zu",
|
||||
entry.runningNumber);
|
||||
}
|
||||
|
||||
XCTAssert(Interval().Union(Interval(10, 100UL)) == Interval(-1L, 100));
|
||||
|
@ -327,30 +333,34 @@ using namespace antlrcpp;
|
|||
try {
|
||||
set4.clear();
|
||||
XCTFail(@"Expected exception");
|
||||
}
|
||||
catch (IllegalStateException &e) {
|
||||
} catch (IllegalStateException &e) {
|
||||
}
|
||||
|
||||
try {
|
||||
set4.setReadOnly(false);
|
||||
XCTFail(@"Expected exception");
|
||||
} catch (IllegalStateException &e) {
|
||||
}
|
||||
catch (IllegalStateException &e) {
|
||||
}
|
||||
|
||||
set4 = IntervalSet::of(12345);
|
||||
XCTAssertEqual(set4.getSingleElement(), 12345);
|
||||
XCTAssertEqual(set4.getMinElement(), 12345);
|
||||
XCTAssertEqual(set4.getMaxElement(), 12345);
|
||||
|
||||
IntervalSet set5(10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
|
||||
XCTAssertEqual(set5.getMinElement(), 5);
|
||||
XCTAssertEqual(set5.getMaxElement(), 50);
|
||||
XCTAssertEqual(set5.size(), 10U);
|
||||
set5.add(12, 18);
|
||||
XCTAssertEqual(set5.size(), 16U); // (15, 15) replaced by (12, 18)
|
||||
set5.add(9, 33);
|
||||
XCTAssertEqual(set5.size(), 30U); // (10, 10), (12, 18), (20, 20), (25, 25) and (30, 30) replaced by (9, 33)
|
||||
try {
|
||||
set4 = IntervalSet::of(12345);
|
||||
XCTFail(@"Expected exception");
|
||||
} catch (IllegalStateException &e) {
|
||||
}
|
||||
|
||||
IntervalSet set5 = IntervalSet::of(12345);
|
||||
XCTAssertEqual(set5.getSingleElement(), 12345);
|
||||
XCTAssertEqual(set5.getMinElement(), 12345);
|
||||
XCTAssertEqual(set5.getMaxElement(), 12345);
|
||||
|
||||
IntervalSet set6(10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50);
|
||||
XCTAssertEqual(set6.getMinElement(), 5);
|
||||
XCTAssertEqual(set6.getMaxElement(), 50);
|
||||
XCTAssertEqual(set6.size(), 10U);
|
||||
set6.add(12, 18);
|
||||
XCTAssertEqual(set6.size(), 16U); // (15, 15) replaced by (12, 18)
|
||||
set6.add(9, 33);
|
||||
XCTAssertEqual(set6.size(), 30U); // (10, 10), (12, 18), (20, 20), (25, 25) and (30, 30) replaced by (9, 33)
|
||||
|
||||
XCTAssert(IntervalSet(3, 1, 2, 10).Or(IntervalSet(3, 1, 2, 5)) == IntervalSet(4, 1, 2, 5, 10));
|
||||
XCTAssert(IntervalSet({ Interval(2, 10UL) }).Or(IntervalSet({ Interval(5, 8UL) })) == IntervalSet({ Interval(2, 10UL) }));
|
||||
|
@ -358,8 +368,10 @@ using namespace antlrcpp;
|
|||
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(7, 55)) == IntervalSet::of(11, 55));
|
||||
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(20, 55)) == IntervalSet::of(20, 55));
|
||||
XCTAssert(IntervalSet::of(1, 10).complement(IntervalSet::of(5, 6)) == IntervalSet::EMPTY_SET);
|
||||
XCTAssert(IntervalSet::of(15, 20).complement(IntervalSet::of(7, 55)) == IntervalSet({ Interval(7, 14UL), Interval(21, 55UL) }));
|
||||
XCTAssert(IntervalSet({ Interval(1, 10UL), Interval(30, 35UL) }).complement(IntervalSet::of(7, 55)) == IntervalSet({ Interval(11, 29UL), Interval(36, 55UL) }));
|
||||
XCTAssert(IntervalSet::of(15, 20).complement(IntervalSet::of(7, 55)) ==
|
||||
IntervalSet({ Interval(7, 14UL), Interval(21, 55UL) }));
|
||||
XCTAssert(IntervalSet({ Interval(1, 10UL), Interval(30, 35UL) }).complement(IntervalSet::of(7, 55)) ==
|
||||
IntervalSet({ Interval(11, 29UL), Interval(36, 55UL) }));
|
||||
|
||||
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(7, 55)) == IntervalSet::of(7, 10));
|
||||
XCTAssert(IntervalSet::of(1, 10).And(IntervalSet::of(20, 55)) == IntervalSet::EMPTY_SET);
|
||||
|
@ -368,7 +380,8 @@ using namespace antlrcpp;
|
|||
|
||||
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(7, 55)) == IntervalSet::of(1, 6));
|
||||
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(20, 55)) == IntervalSet::of(1, 10));
|
||||
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(5, 6)) == IntervalSet({ Interval(1, 4UL), Interval(7, 10UL) }));
|
||||
XCTAssert(IntervalSet::of(1, 10).subtract(IntervalSet::of(5, 6)) ==
|
||||
IntervalSet({ Interval(1, 4UL), Interval(7, 10UL) }));
|
||||
XCTAssert(IntervalSet::of(15, 20).subtract(IntervalSet::of(7, 55)) == IntervalSet::EMPTY_SET);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace antlr4 {
|
|||
/// </summary>
|
||||
class ANTLR4CPP_PUBLIC IntStream {
|
||||
public:
|
||||
static const size_t EOF = (size_t)-1; // std::numeric_limits<size_t>::max(); doesn't work in VS 2013
|
||||
static const size_t EOF = static_cast<size_t>(-1); // std::numeric_limits<size_t>::max(); doesn't work in VS 2013
|
||||
|
||||
/// The value returned by <seealso cref="#LA LA()"/> when the end of the stream is
|
||||
/// reached.
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace antlr4 {
|
|||
|
||||
class ANTLR4CPP_PUBLIC Recognizer {
|
||||
public:
|
||||
static const size_t EOF = (size_t)-1; // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
|
||||
static const size_t EOF = static_cast<size_t>(-1); // std::numeric_limits<size_t>::max(); doesn't work in VS 2013.
|
||||
|
||||
Recognizer();
|
||||
Recognizer(Recognizer const&) = delete;
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace antlr4 {
|
|||
|
||||
/// During lookahead operations, this "token" signifies we hit rule end ATN state
|
||||
/// and did not follow it despite needing to.
|
||||
static const size_t EPSILON = (size_t)-2;
|
||||
static const size_t EPSILON = static_cast<size_t>(-2);
|
||||
static const size_t MIN_USER_TOKEN_TYPE = 1;
|
||||
static const size_t EOF = IntStream::EOF;
|
||||
|
||||
|
|
|
@ -89,23 +89,23 @@ size_t UnbufferedCharStream::LA(ssize_t i) {
|
|||
}
|
||||
|
||||
// We can look back only as many chars as we have buffered.
|
||||
ssize_t index = (ssize_t)_p + i - 1;
|
||||
ssize_t index = static_cast<ssize_t>(_p) + i - 1;
|
||||
if (index < 0) {
|
||||
throw IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
sync((size_t)i); // No need to sync if we look back.
|
||||
sync(static_cast<size_t>(i)); // No need to sync if we look back.
|
||||
}
|
||||
if ((size_t)index >= _data.size()) {
|
||||
if (static_cast<size_t>(index) >= _data.size()) {
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (_data[(size_t)index] == 0xFFFF) {
|
||||
if (_data[static_cast<size_t>(index)] == 0xFFFF) {
|
||||
return EOF;
|
||||
}
|
||||
|
||||
return _data[(size_t)index];
|
||||
return _data[static_cast<size_t>(index)];
|
||||
}
|
||||
|
||||
ssize_t UnbufferedCharStream::mark() {
|
||||
|
@ -113,13 +113,13 @@ ssize_t UnbufferedCharStream::mark() {
|
|||
_lastCharBufferStart = _lastChar;
|
||||
}
|
||||
|
||||
ssize_t mark = -(ssize_t)_numMarkers - 1;
|
||||
ssize_t mark = -static_cast<ssize_t>(_numMarkers) - 1;
|
||||
_numMarkers++;
|
||||
return mark;
|
||||
}
|
||||
|
||||
void UnbufferedCharStream::release(ssize_t marker) {
|
||||
ssize_t expectedMark = -(ssize_t)_numMarkers;
|
||||
ssize_t expectedMark = -static_cast<ssize_t>(_numMarkers);
|
||||
if (marker != expectedMark) {
|
||||
throw IllegalStateException("release() called with an invalid marker.");
|
||||
}
|
||||
|
@ -147,16 +147,16 @@ void UnbufferedCharStream::seek(size_t index) {
|
|||
}
|
||||
|
||||
// index == to bufferStartIndex should set p to 0
|
||||
ssize_t i = (ssize_t)index - (ssize_t)getBufferStartIndex();
|
||||
ssize_t i = static_cast<ssize_t>(index) - static_cast<ssize_t>(getBufferStartIndex());
|
||||
if (i < 0) {
|
||||
throw IllegalArgumentException(std::string("cannot seek to negative index ") + std::to_string(index));
|
||||
} else if (i >= (ssize_t)_data.size()) {
|
||||
} else if (i >= static_cast<ssize_t>(_data.size())) {
|
||||
throw UnsupportedOperationException("Seek to index outside buffer: " + std::to_string(index) +
|
||||
" not in " + std::to_string(getBufferStartIndex()) + ".." +
|
||||
std::to_string(getBufferStartIndex() + _data.size()));
|
||||
}
|
||||
|
||||
_p = (size_t)i;
|
||||
_p = static_cast<size_t>(i);
|
||||
_currentCharIndex = index;
|
||||
if (_p == 0) {
|
||||
_lastChar = _lastCharBufferStart;
|
||||
|
@ -189,7 +189,7 @@ std::string UnbufferedCharStream::getText(const misc::Interval &interval) {
|
|||
}
|
||||
}
|
||||
|
||||
if (interval.a < (ssize_t)bufferStartIndex || interval.b >= ssize_t(bufferStartIndex + _data.size())) {
|
||||
if (interval.a < static_cast<ssize_t>(bufferStartIndex) || interval.b >= ssize_t(bufferStartIndex + _data.size())) {
|
||||
throw UnsupportedOperationException("interval " + interval.toString() + " outside buffer: " +
|
||||
std::to_string(bufferStartIndex) + ".." + std::to_string(bufferStartIndex + _data.size() - 1));
|
||||
}
|
||||
|
|
|
@ -46,17 +46,17 @@ Token* UnbufferedTokenStream::LT(ssize_t i)
|
|||
}
|
||||
|
||||
sync(i);
|
||||
ssize_t index = (ssize_t)_p + i - 1;
|
||||
ssize_t index = static_cast<ssize_t>(_p) + i - 1;
|
||||
if (index < 0) {
|
||||
throw IndexOutOfBoundsException(std::string("LT(") + std::to_string(i) + std::string(") gives negative index"));
|
||||
}
|
||||
|
||||
if (index >= (ssize_t)_tokens.size()) {
|
||||
if (index >= static_cast<ssize_t>(_tokens.size())) {
|
||||
assert(_tokens.size() > 0 && _tokens.back()->getType() == EOF);
|
||||
return _tokens.back().get();
|
||||
}
|
||||
|
||||
return _tokens[(size_t)index].get();
|
||||
return _tokens[static_cast<size_t>(index)].get();
|
||||
}
|
||||
|
||||
size_t UnbufferedTokenStream::LA(ssize_t i)
|
||||
|
@ -113,9 +113,9 @@ void UnbufferedTokenStream::consume()
|
|||
/// </summary>
|
||||
void UnbufferedTokenStream::sync(ssize_t want)
|
||||
{
|
||||
ssize_t need = ((ssize_t)_p + want - 1) - (ssize_t)_tokens.size() + 1; // how many more elements we need?
|
||||
ssize_t need = (static_cast<ssize_t>(_p) + want - 1) - static_cast<ssize_t>(_tokens.size()) + 1; // how many more elements we need?
|
||||
if (need > 0) {
|
||||
fill((size_t)need);
|
||||
fill(static_cast<size_t>(need));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ void UnbufferedTokenStream::release(ssize_t marker)
|
|||
if (_p > 0) {
|
||||
// Copy tokens[p]..tokens[n-1] to tokens[0]..tokens[(n-1)-p], reset ptrs
|
||||
// p is last valid token; move nothing if p==n as we have no valid char
|
||||
_tokens.erase(_tokens.begin(), _tokens.begin() + (ssize_t)_p);
|
||||
_tokens.erase(_tokens.begin(), _tokens.begin() + static_cast<ssize_t>(_p));
|
||||
_p = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -752,6 +752,7 @@ Ref<LexerAction> ATNDeserializer::lexerActionFactory(LexerActionType type, int d
|
|||
return std::make_shared<LexerTypeAction>(data1);
|
||||
|
||||
default:
|
||||
throw IllegalArgumentException("The specified lexer action type " + std::to_string((size_t)type) + " is not valid.");
|
||||
throw IllegalArgumentException("The specified lexer action type " + std::to_string(static_cast<size_t>(type)) +
|
||||
" is not valid.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
serializeUUID(data, ATNDeserializer::SERIALIZED_UUID());
|
||||
|
||||
// convert grammar type to ATN const to avoid dependence on ANTLRParser
|
||||
data.push_back((size_t)atn->grammarType);
|
||||
data.push_back(static_cast<size_t>(atn->grammarType));
|
||||
data.push_back(atn->maxTokenType);
|
||||
size_t nedges = 0;
|
||||
|
||||
|
@ -288,7 +288,7 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
if (atn->grammarType == ATNType::LEXER) {
|
||||
data.push_back(atn->lexerActions.size());
|
||||
for (Ref<LexerAction> &action : atn->lexerActions) {
|
||||
data.push_back((size_t)action->getActionType());
|
||||
data.push_back(static_cast<size_t>(action->getActionType()));
|
||||
switch (action->getActionType()) {
|
||||
case LexerActionType::CHANNEL:
|
||||
{
|
||||
|
@ -348,7 +348,8 @@ std::vector<size_t> ATNSerializer::serialize() {
|
|||
|
||||
default:
|
||||
throw IllegalArgumentException("The specified lexer action type " +
|
||||
std::to_string((size_t)action->getActionType()) + " is not valid.");
|
||||
std::to_string(static_cast<size_t>(action->getActionType())) +
|
||||
" is not valid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace atn {
|
|||
virtual ~ATNState();
|
||||
|
||||
static const size_t INITIAL_NUM_TRANSITIONS = 4;
|
||||
static const size_t INVALID_STATE_NUMBER = (size_t)-1; // std::numeric_limits<size_t>::max();
|
||||
static const size_t INVALID_STATE_NUMBER = static_cast<size_t>(-1); // std::numeric_limits<size_t>::max();
|
||||
|
||||
enum {
|
||||
ATN_INVALID_TYPE = 0,
|
||||
|
|
|
@ -144,12 +144,12 @@ void LL1Analyzer::_LOOK(ATNState *s, ATNState *stopState, Ref<PredictionContext>
|
|||
} else if (t->isEpsilon()) {
|
||||
_LOOK(t->target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
|
||||
} else if (t->getSerializationType() == Transition::WILDCARD) {
|
||||
look.addAll(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, (ssize_t)_atn.maxTokenType));
|
||||
look.addAll(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
|
||||
} else {
|
||||
misc::IntervalSet set = t->label();
|
||||
if (!set.isEmpty()) {
|
||||
if (is<NotSetTransition*>(t)) {
|
||||
set = set.complement(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, (ssize_t)_atn.maxTokenType));
|
||||
set = set.complement(misc::IntervalSet::of(Token::MIN_USER_TOKEN_TYPE, static_cast<ssize_t>(_atn.maxTokenType)));
|
||||
}
|
||||
look.addAll(set);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ void LexerChannelAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerChannelAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
hash = MurmurHash::update(hash, _channel);
|
||||
return MurmurHash::finish(hash, 2);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ void LexerCustomAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerCustomAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
hash = MurmurHash::update(hash, _ruleIndex);
|
||||
hash = MurmurHash::update(hash, _actionIndex);
|
||||
return MurmurHash::finish(hash, 3);
|
||||
|
|
|
@ -33,7 +33,7 @@ void LexerModeAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerModeAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
hash = MurmurHash::update(hash, _mode);
|
||||
return MurmurHash::finish(hash, 2);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void LexerMoreAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerMoreAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
return MurmurHash::finish(hash, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void LexerPopModeAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerPopModeAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
return MurmurHash::finish(hash, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void LexerPushModeAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerPushModeAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
hash = MurmurHash::update(hash, _mode);
|
||||
return MurmurHash::finish(hash, 2);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ void LexerSkipAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerSkipAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
return MurmurHash::finish(hash, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ void LexerTypeAction::execute(Lexer *lexer) {
|
|||
|
||||
size_t LexerTypeAction::hashCode() const {
|
||||
size_t hash = MurmurHash::initialize();
|
||||
hash = MurmurHash::update(hash, (size_t)getActionType());
|
||||
hash = MurmurHash::update(hash, static_cast<size_t>(getActionType()));
|
||||
hash = MurmurHash::update(hash, _type);
|
||||
return MurmurHash::finish(hash, 2);
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ namespace atn {
|
|||
/// Represents $ in an array in full context mode, when $
|
||||
/// doesn't mean wildcard: $ + x = [$,x]. Here,
|
||||
/// $ = EMPTY_RETURN_STATE.
|
||||
// ml: originally Integer.MAX_VALUE, which would be (size_t)-1 for us, but this is already used in places where
|
||||
// ml: originally Integer.MAX_VALUE, which would be -1 for us, but this is already used in places where
|
||||
// -1 is converted to unsigned, so we use a different value here. Any value does the job provided it doesn't
|
||||
// conflict with real return states.
|
||||
static const size_t EMPTY_RETURN_STATE = (size_t)-10; // std::numeric_limits<size_t>::max() - 9;
|
||||
static const size_t EMPTY_RETURN_STATE = static_cast<size_t>(-10); // std::numeric_limits<size_t>::max() - 9;
|
||||
|
||||
private:
|
||||
static const size_t INITIAL_HASH = 1;
|
||||
|
|
|
@ -82,7 +82,7 @@ int SemanticContext::PrecedencePredicate::compareTo(PrecedencePredicate *o) {
|
|||
|
||||
size_t SemanticContext::PrecedencePredicate::hashCode() const {
|
||||
size_t hashCode = 1;
|
||||
hashCode = 31 * hashCode + (size_t)precedence;
|
||||
hashCode = 31 * hashCode + static_cast<size_t>(precedence);
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,16 +10,16 @@ using namespace antlr4::misc;
|
|||
Interval::~Interval() = default;
|
||||
|
||||
size_t antlr4::misc::numericToSymbol(ssize_t v) {
|
||||
return (size_t)v;
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
|
||||
ssize_t antlr4::misc::symbolToNumeric(size_t v) {
|
||||
return (ssize_t)v;
|
||||
return static_cast<ssize_t>(v);
|
||||
}
|
||||
|
||||
Interval const Interval::INVALID;
|
||||
|
||||
Interval::Interval() : Interval((ssize_t)-1, -2) { // Need an explicit cast here for VS.
|
||||
Interval::Interval() : Interval(static_cast<ssize_t>(-1), -2) { // Need an explicit cast here for VS.
|
||||
}
|
||||
|
||||
Interval::Interval(size_t a_, size_t b_) : Interval(symbolToNumeric(a_), symbolToNumeric(b_)) {
|
||||
|
@ -41,8 +41,8 @@ bool Interval::operator == (const Interval &other) const {
|
|||
|
||||
size_t Interval::hashCode() const {
|
||||
size_t hash = 23;
|
||||
hash = hash * 31 + (size_t)a;
|
||||
hash = hash * 31 + (size_t)b;
|
||||
hash = hash * 31 + static_cast<size_t>(a);
|
||||
hash = hash * 31 + static_cast<size_t>(b);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue