ladybird/Userland/Libraries/LibCpp/Token.cpp

40 lines
932 B
C++
Raw Normal View History

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Token.h"
#include <AK/DeprecatedString.h>
namespace Cpp {
2022-04-01 20:58:27 +03:00
bool Position::operator<(Position const& other) const
{
return line < other.line || (line == other.line && column < other.column);
}
2022-04-01 20:58:27 +03:00
bool Position::operator>(Position const& other) const
{
return !(*this < other) && !(*this == other);
}
2022-04-01 20:58:27 +03:00
bool Position::operator==(Position const& other) const
{
return line == other.line && column == other.column;
}
2022-04-01 20:58:27 +03:00
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);
}
}