Commit a5683591 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[2374] Some last cleanups

- reduced a line that was 1 character too long
- flipped order of check with isdigit()
- renamed Token::NUMBER_RANGE to Token::NUMBER_OUT_OF_RANGE
parent e206bfd6
......@@ -212,7 +212,7 @@ const char* const error_text[] = {
"unexpected end of input", // UNEXPECTED_END
"unbalanced quotes", // UNBALANCED_QUOTES
"no token produced", // NO_TOKEN_PRODUCED
"number out of range" // NUMBER_RANGE
"number out of range" // NUMBER_OUT_OF_RANGE
};
const size_t error_text_max_count = sizeof(error_text) / sizeof(error_text[0]);
} // end unnamed namespace
......@@ -379,7 +379,7 @@ State::start(MasterLexer& lexer, MasterLexer::Options options) {
return (NULL);
}
--paren_count;
} else if (isdigit(c) && (options & MasterLexer::NUMBER) != 0) {
} else if ((options & MasterLexer::NUMBER) != 0 &&isdigit(c)) {
lexerimpl.last_was_eol_ = false;
// this character will be handled in the number state
lexerimpl.source_->ungetChar();
......@@ -469,12 +469,12 @@ Number::handle(MasterLexer& lexer) const {
data.push_back('\0');
try {
const uint32_t number32 =
boost::lexical_cast<uint32_t, const char*>(&data.at(0));
boost::lexical_cast<uint32_t, const char*>(&data[0]);
token = MasterLexer::Token(number32);
} catch (const boost::bad_lexical_cast&) {
// Since we already know we have only digits,
// range should be the only possible problem.
token = Token(Token::NUMBER_RANGE);
token = Token(Token::NUMBER_OUT_OF_RANGE);
}
} else {
token = MasterLexer::Token(&data.at(0),
......
......@@ -292,7 +292,7 @@ public:
UNBALANCED_QUOTES, ///< Unbalanced quotations detected
NO_TOKEN_PRODUCED, ///< No token was produced. This means programmer
/// error and should never get out of the lexer.
NUMBER_RANGE, ///< Number was out of range
NUMBER_OUT_OF_RANGE, ///< Number was out of range
MAX_ERROR_CODE ///< Max integer corresponding to valid error codes.
/// (excluding this one). Mainly for internal use.
};
......
......@@ -488,12 +488,12 @@ TEST_F(MasterLexerStateTest, basicNumbers) {
EXPECT_EQ(&s_number, State::start(lexer, options));
s_number.handle(lexer);
EXPECT_EQ(Token::NUMBER_RANGE,
EXPECT_EQ(Token::NUMBER_OUT_OF_RANGE,
s_number.getToken(lexer).getErrorCode());
EXPECT_EQ(&s_number, State::start(lexer, options));
s_number.handle(lexer);
EXPECT_EQ(Token::NUMBER_RANGE,
EXPECT_EQ(Token::NUMBER_OUT_OF_RANGE,
s_number.getToken(lexer).getErrorCode());
EXPECT_EQ(&s_number, State::start(lexer, options));
......
......@@ -146,7 +146,7 @@ TEST_F(MasterLexerTokenTest, errors) {
MasterLexer::Token(MasterLexer::Token::NO_TOKEN_PRODUCED).
getErrorText());
EXPECT_EQ("number out of range",
MasterLexer::Token(MasterLexer::Token::NUMBER_RANGE).
MasterLexer::Token(MasterLexer::Token::NUMBER_OUT_OF_RANGE).
getErrorText());
// getErrorCode/Text() isn't allowed for non number types
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment