1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Keep track of file names, lines and columns inside the AST

This commit is contained in:
Jean-Baptiste Boric 2021-02-28 10:42:34 +01:00 committed by Andreas Kling
parent 007b6edce4
commit 0039ecb189
6 changed files with 134 additions and 122 deletions

View file

@ -36,11 +36,12 @@ namespace JS {
class Lexer {
public:
explicit Lexer(StringView source);
explicit Lexer(StringView source, StringView filename = "(unknown)", size_t line_number = 1, size_t line_column = 0);
Token next();
const StringView& source() const { return m_source; };
const StringView& filename() const { return m_filename; };
private:
void consume();
@ -65,6 +66,8 @@ private:
size_t m_position { 0 };
Token m_current_token;
char m_current_char { 0 };
StringView m_filename;
size_t m_line_number { 1 };
size_t m_line_column { 0 };