mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-09 22:38:06 -05:00
Add permissive mode for menu parsing that accepts unknown script tokens as long as they can be put into the script
This commit is contained in:
@ -14,20 +14,20 @@ class MockLexer final : public ILexer<TokenType>
|
||||
|
||||
std::vector<TokenType> m_tokens;
|
||||
TokenType m_eof;
|
||||
int m_pop_count;
|
||||
size_t m_pop_count;
|
||||
|
||||
public:
|
||||
MockLexer(std::initializer_list<Movable<TokenType>> tokens, TokenType eof)
|
||||
: m_tokens(std::make_move_iterator(tokens.begin()), std::make_move_iterator(tokens.end())),
|
||||
m_eof(std::move(eof)),
|
||||
m_pop_count(0)
|
||||
m_pop_count(0u)
|
||||
{
|
||||
}
|
||||
|
||||
MockLexer(std::vector<TokenType> tokens, TokenType eof)
|
||||
: m_tokens(std::move(tokens)),
|
||||
m_eof(std::move(eof)),
|
||||
m_pop_count(0)
|
||||
m_pop_count(0u)
|
||||
{
|
||||
}
|
||||
|
||||
@ -39,28 +39,30 @@ public:
|
||||
|
||||
const TokenType& GetToken(const unsigned index) override
|
||||
{
|
||||
if (index < m_tokens.size())
|
||||
return m_tokens[index];
|
||||
const auto absoluteIndex = m_pop_count + index;
|
||||
if (absoluteIndex < m_tokens.size())
|
||||
return m_tokens[absoluteIndex];
|
||||
|
||||
return m_eof;
|
||||
}
|
||||
|
||||
void PopTokens(const int amount) override
|
||||
{
|
||||
m_pop_count += amount;
|
||||
assert(amount >= 0);
|
||||
m_pop_count += static_cast<size_t>(amount);
|
||||
}
|
||||
|
||||
bool IsEof() override
|
||||
{
|
||||
return !m_tokens.empty();
|
||||
return !m_tokens.empty() || m_pop_count >= m_tokens.size();
|
||||
}
|
||||
|
||||
const TokenPos& GetPos() override
|
||||
{
|
||||
return !m_tokens.empty() ? m_tokens[0].GetPos() : m_eof.GetPos();
|
||||
return !m_tokens.empty() && m_pop_count < m_tokens.size() ? m_tokens[m_pop_count].GetPos() : m_eof.GetPos();
|
||||
}
|
||||
|
||||
_NODISCARD int GetPopCount() const
|
||||
_NODISCARD size_t GetPopCount() const
|
||||
{
|
||||
return m_pop_count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user