From 66481ad279934d18f258444b0ebfc73f52edc695 Mon Sep 17 00:00:00 2001 From: Benoit Lormeau Date: Sat, 26 Sep 2020 00:22:44 +0200 Subject: [PATCH] AK: Added explanatory comments in GenericLexer.h --- AK/GenericLexer.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index 7f332de5c3..f5a12b51d2 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -36,6 +36,7 @@ public: explicit GenericLexer(const StringView& input); virtual ~GenericLexer(); + // A lambda/function can be used to match characters as the user pleases using Condition = Function; size_t tell() const { return m_index; } @@ -82,8 +83,13 @@ constexpr auto is_any_of(const StringView& values) return [values](auto c) { return values.contains(c); }; } -// ctype adaptors -// FIXME: maybe put them in an another file? +/* + * CType adapters: pass them as Conditions to a GenericLexer's methods + * Examples: + * - `if (lexer.next_is(is_digit))` + * - `auto name = lexer.consume_while(is_alphanum); + * - `lexer.ignore_until(is_any_of("<^>"))` + */ bool is_alpha(char); bool is_alphanum(char); bool is_control(char);