mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Fix not reading hex numbers with integer only lexing for SimpleLexer
This commit is contained in:
parent
a092f76ec9
commit
1d798647c3
@ -289,6 +289,28 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
void ReadNumber(bool& hasSignPrefix, int& integerValue)
|
||||
{
|
||||
const auto& currentLine = CurrentLine();
|
||||
assert(m_current_line_offset >= 1);
|
||||
assert(isdigit(currentLine.m_line[m_current_line_offset - 1])
|
||||
|| currentLine.m_line[m_current_line_offset - 1] == '+'
|
||||
|| currentLine.m_line[m_current_line_offset - 1] == '-');
|
||||
hasSignPrefix = currentLine.m_line[m_current_line_offset - 1] == '+' || currentLine.m_line[m_current_line_offset - 1] == '-';
|
||||
|
||||
const auto lineLength = currentLine.m_line.size();
|
||||
if (lineLength - m_current_line_offset >= 1
|
||||
&& currentLine.m_line[m_current_line_offset - 1] == '0'
|
||||
&& currentLine.m_line[m_current_line_offset] == 'x')
|
||||
{
|
||||
ReadHexNumber(integerValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
integerValue = ReadInteger();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
const TokenType& GetToken(unsigned index) override
|
||||
{
|
||||
|
@ -125,12 +125,13 @@ SimpleParserValue SimpleLexer::GetNextToken()
|
||||
|
||||
if (m_config.m_read_integer_numbers && (isdigit(c) || (c == '+' || c == '-' || (m_config.m_read_floating_point_numbers && c == '.')) && isdigit(PeekChar())))
|
||||
{
|
||||
bool hasSignPrefix;
|
||||
int integerValue;
|
||||
|
||||
if(m_config.m_read_floating_point_numbers)
|
||||
{
|
||||
bool isFloatingPointValue;
|
||||
bool hasSignPrefix;
|
||||
double floatingPointValue;
|
||||
int integerValue;
|
||||
|
||||
ReadNumber(isFloatingPointValue, hasSignPrefix, floatingPointValue, integerValue);
|
||||
|
||||
@ -140,7 +141,8 @@ SimpleParserValue SimpleLexer::GetNextToken()
|
||||
return SimpleParserValue::Integer(pos, integerValue, hasSignPrefix);
|
||||
}
|
||||
|
||||
return SimpleParserValue::Integer(pos, ReadInteger(), c == '+' || c == '-');
|
||||
ReadNumber(hasSignPrefix, integerValue);
|
||||
return SimpleParserValue::Integer(pos, integerValue, hasSignPrefix);
|
||||
}
|
||||
|
||||
if (isalpha(c) || c == '_')
|
||||
|
Loading…
x
Reference in New Issue
Block a user