
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
39 lines
910 B
C++
39 lines
910 B
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "Token.h"
|
|
#include <AK/DeprecatedString.h>
|
|
|
|
namespace Cpp {
|
|
|
|
bool Position::operator<(Position const& other) const
|
|
{
|
|
return line < other.line || (line == other.line && column < other.column);
|
|
}
|
|
bool Position::operator>(Position const& other) const
|
|
{
|
|
return !(*this < other) && !(*this == other);
|
|
}
|
|
bool Position::operator==(Position const& other) const
|
|
{
|
|
return line == other.line && column == other.column;
|
|
}
|
|
bool Position::operator<=(Position const& other) const
|
|
{
|
|
return !(*this > other);
|
|
}
|
|
|
|
DeprecatedString Token::to_string() const
|
|
{
|
|
return DeprecatedString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
|
}
|
|
|
|
DeprecatedString Token::type_as_string() const
|
|
{
|
|
return type_to_string(m_type);
|
|
}
|
|
|
|
}
|