mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibJS: Plumb line and column information through Lexer / Parser
While debugging test failures, it's pretty frustrating to have to go do printf debugging to figure out what test is failing right now. While watching your JS Raytracer stream it seemed like this was pretty furstrating as well. So I wanted to start working on improving the diagnostics here. In the future I hope we can eventually be able to plumb the info down to the Error classes so any thrown exceptions will contain enough metadata to know where they came from.
This commit is contained in:
parent
4f200def9c
commit
dd112421b4
4 changed files with 34 additions and 7 deletions
|
@ -131,10 +131,12 @@ enum class TokenType {
|
|||
|
||||
class Token {
|
||||
public:
|
||||
Token(TokenType type, StringView trivia, StringView value)
|
||||
Token(TokenType type, StringView trivia, StringView value, size_t line_number, size_t line_column)
|
||||
: m_type(type)
|
||||
, m_trivia(trivia)
|
||||
, m_value(value)
|
||||
, m_line_number(line_number)
|
||||
, m_line_column(line_column)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -144,6 +146,8 @@ public:
|
|||
|
||||
const StringView& trivia() const { return m_trivia; }
|
||||
const StringView& value() const { return m_value; }
|
||||
size_t line_number() const { return m_line_number; }
|
||||
size_t line_column() const { return m_line_column; }
|
||||
double double_value() const;
|
||||
String string_value() const;
|
||||
bool bool_value() const;
|
||||
|
@ -152,6 +156,8 @@ private:
|
|||
TokenType m_type;
|
||||
StringView m_trivia;
|
||||
StringView m_value;
|
||||
size_t m_line_number;
|
||||
size_t m_line_column;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue