mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 02:38:13 +00:00
LibCpp: Modify Token::to_string() to include more information
Token::to_string() now includes not only the token's type, but also its text and span in the document.
This commit is contained in:
parent
cdea9f5339
commit
0c9db38e8f
4 changed files with 18 additions and 12 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "Token.h"
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Cpp {
|
||||
|
||||
|
@ -24,4 +25,15 @@ bool Position::operator<=(const Position& other) const
|
|||
{
|
||||
return !(*this > other);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue