diff --git a/AK/GenericLexer.cpp b/AK/GenericLexer.cpp index 565ecf3917..4ea809973f 100644 --- a/AK/GenericLexer.cpp +++ b/AK/GenericLexer.cpp @@ -76,6 +76,13 @@ bool GenericLexer::next_is(const char* expected) const return true; } +// Go back to the previous character +void GenericLexer::retreat() +{ + ASSERT(m_index > 0); + m_index--; +} + // Consume a character and advance the parser index char GenericLexer::consume() { diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index ce5d123f16..854bc96a21 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -48,6 +48,8 @@ public: bool next_is(StringView) const; bool next_is(const char*) const; + void retreat(); + char consume(); bool consume_specific(char); bool consume_specific(StringView);