Removed a couple of static helpers in the data formatters, replaced with new general logic in StringLexer
llvm-svn: 222058
This commit is contained in:
@@ -42,6 +42,42 @@ StringLexer::NextIf (Character c)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::pair<bool, StringLexer::Character>
|
||||
StringLexer::NextIf (std::initializer_list<Character> cs)
|
||||
{
|
||||
auto val = Peek();
|
||||
for (auto c : cs)
|
||||
{
|
||||
if (val == c)
|
||||
{
|
||||
Next();
|
||||
return {true,c};
|
||||
}
|
||||
}
|
||||
return {false,0};
|
||||
}
|
||||
|
||||
bool
|
||||
StringLexer::AdvanceIf (const std::string& token)
|
||||
{
|
||||
auto pos = m_position;
|
||||
bool matches = true;
|
||||
for (auto c : token)
|
||||
{
|
||||
if (!NextIf(c))
|
||||
{
|
||||
matches = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matches)
|
||||
{
|
||||
m_position = pos;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
StringLexer::Character
|
||||
StringLexer::Next ()
|
||||
{
|
||||
@@ -69,6 +105,12 @@ StringLexer::HasAny (Character c)
|
||||
return m_data.find(c, m_position) != std::string::npos;
|
||||
}
|
||||
|
||||
std::string
|
||||
StringLexer::GetUnlexed ()
|
||||
{
|
||||
return std::string(m_data, m_position);
|
||||
}
|
||||
|
||||
void
|
||||
StringLexer::Consume()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user