2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-09-05 08:17:25 +00:00

Cache lines in Lexer and show original input when running into an error

This commit is contained in:
Jan
2021-02-13 23:16:19 +01:00
parent 40fedc905d
commit 216125739c
19 changed files with 283 additions and 116 deletions

View File

@@ -129,9 +129,9 @@ HeaderParserValue HeaderLexer::GetNextToken()
if (isspace(c))
break;
const auto pos = GetPreviousCharacterPos();
if(isdigit(c))
{
const auto pos = GetPreviousCharacterPos();
bool isFloatingPointValue;
double doubleValue;
int integerValue;
@@ -150,12 +150,12 @@ HeaderParserValue HeaderLexer::GetNextToken()
const auto foundKeyword = m_keywords.find(identifier);
if (foundKeyword != m_keywords.end())
return HeaderParserValue::Keyword(GetPreviousCharacterPos(), foundKeyword->second);
return HeaderParserValue::Keyword(pos, foundKeyword->second);
return HeaderParserValue::Identifier(GetPreviousCharacterPos(), new std::string(std::move(identifier)));
return HeaderParserValue::Identifier(pos, new std::string(std::move(identifier)));
}
return HeaderParserValue::Character(GetPreviousCharacterPos(), static_cast<char>(c));
return HeaderParserValue::Character(pos, static_cast<char>(c));
}
}

View File

@@ -111,8 +111,8 @@ HeaderParserValue HeaderParserValue::TypeName(const TokenPos pos, std::string* t
HeaderParserValue::HeaderParserValue(const TokenPos pos, const HeaderParserValueType type)
: m_pos(pos),
m_type(type),
m_value()
m_type(type),
m_value()
{
}
@@ -134,14 +134,16 @@ HeaderParserValue::~HeaderParserValue()
}
HeaderParserValue::HeaderParserValue(HeaderParserValue&& other) noexcept
: m_type(other.m_type),
m_value(other.m_value)
: m_pos(other.m_pos),
m_type(other.m_type),
m_value(other.m_value)
{
other.m_value = ValueType();
}
HeaderParserValue& HeaderParserValue::operator=(HeaderParserValue&& other) noexcept
{
m_pos = other.m_pos;
m_type = other.m_type;
m_value = other.m_value;
other.m_value = ValueType();