mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 11:39:43 +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
Notes:
sideshowbarker
2024-07-18 17:33:24 +09:00
Author: https://github.com/itamar8910
Commit: 0c9db38e8f
Pull-request: https://github.com/SerenityOS/serenity/pull/7383
Reviewed-by: https://github.com/gunnarbeutner
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