From bf7262681e89d81ff4b58a6c6052a1f797e963fa Mon Sep 17 00:00:00 2001 From: Itamar Date: Fri, 6 Aug 2021 10:16:53 +0300 Subject: [PATCH] LibCpp: Support initializing the lexer with a "start line" --- Userland/Libraries/LibCpp/Lexer.cpp | 4 +++- Userland/Libraries/LibCpp/Lexer.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibCpp/Lexer.cpp b/Userland/Libraries/LibCpp/Lexer.cpp index d3703db829..56ab1afd6c 100644 --- a/Userland/Libraries/LibCpp/Lexer.cpp +++ b/Userland/Libraries/LibCpp/Lexer.cpp @@ -12,8 +12,10 @@ namespace Cpp { -Lexer::Lexer(StringView const& input) +Lexer::Lexer(StringView const& input, size_t start_line) : m_input(input) + , m_previous_position { start_line, 0 } + , m_position { start_line, 0 } { } diff --git a/Userland/Libraries/LibCpp/Lexer.h b/Userland/Libraries/LibCpp/Lexer.h index 1f8c1d8a93..bbee2bbf9f 100644 --- a/Userland/Libraries/LibCpp/Lexer.h +++ b/Userland/Libraries/LibCpp/Lexer.h @@ -14,7 +14,7 @@ namespace Cpp { class Lexer { public: - Lexer(StringView const&); + explicit Lexer(StringView const&, size_t start_line = 0); Vector lex();