summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-07-11 20:58:38 +0300
committerLinus Groh <mail@linusgroh.de>2021-07-12 19:05:17 +0100
commit39a9cf4bb49751b49c63fa8b1c65555afc73d0e7 (patch)
treeca9f2cedd6ebe0c03a8aafc553fb92eb8080bd12 /AK
parentb2daaca5ee1b95067d0a8d810520b0e86fd3611a (diff)
downloadserenity-39a9cf4bb49751b49c63fa8b1c65555afc73d0e7.zip
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()
Diffstat (limited to 'AK')
-rw-r--r--AK/GenericLexer.h6
1 files changed, 6 insertions, 0 deletions
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());