From 39a9cf4bb49751b49c63fa8b1c65555afc73d0e7 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sun, 11 Jul 2021 20:58:38 +0300 Subject: [PATCH] AK: Add a retreat(count) method to GenericLexer This method can be used to rewind a constant amount backwards in the source instead of one by one with retract() --- AK/GenericLexer.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index 131c0b24dd..e824f473a8 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -56,6 +56,12 @@ public: --m_index; } + constexpr void retreat(size_t count) + { + VERIFY(m_index >= count); + m_index -= count; + } + constexpr char consume() { VERIFY(!is_eof());