ladybird/Userland/Libraries/LibCpp/Token.cpp
Linus Groh 57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00

39 lines
932 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_deprecated_string() const
{
return DeprecatedString::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
}
DeprecatedString Token::type_as_deprecated_string() const
{
return type_to_string(m_type);
}
}