2021-03-12 12:28:20 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-03-12 12:28:20 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Token.h"
|
2021-05-21 14:39:42 +03:00
|
|
|
#include <AK/String.h>
|
2021-03-12 12:28:20 +02:00
|
|
|
|
|
|
|
namespace Cpp {
|
|
|
|
|
2022-04-01 20:58:27 +03:00
|
|
|
bool Position::operator<(Position const& other) const
|
2021-03-12 12:28:20 +02:00
|
|
|
{
|
|
|
|
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
|
2021-03-12 12:28:20 +02:00
|
|
|
{
|
|
|
|
return !(*this < other) && !(*this == other);
|
|
|
|
}
|
2022-04-01 20:58:27 +03:00
|
|
|
bool Position::operator==(Position const& other) const
|
2021-03-12 12:28:20 +02:00
|
|
|
{
|
|
|
|
return line == other.line && column == other.column;
|
|
|
|
}
|
2022-04-01 20:58:27 +03:00
|
|
|
bool Position::operator<=(Position const& other) const
|
2021-05-09 21:40:27 +03:00
|
|
|
{
|
|
|
|
return !(*this > other);
|
|
|
|
}
|
2021-05-21 14:39:42 +03:00
|
|
|
|
|
|
|
String Token::to_string() const
|
|
|
|
{
|
|
|
|
return String::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
|
|
|
|
}
|
|
|
|
|
|
|
|
String Token::type_as_string() const
|
|
|
|
{
|
|
|
|
return type_to_string(m_type);
|
|
|
|
}
|
|
|
|
|
2021-03-12 12:28:20 +02:00
|
|
|
}
|