diff options
author | Benoit Lormeau <blormeau@outlook.com> | 2020-09-26 00:22:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-26 17:17:53 +0200 |
commit | 66481ad279934d18f258444b0ebfc73f52edc695 (patch) | |
tree | 178b7b1acbcd9d9f6dc65cbaf0adc680f90c5d30 | |
parent | fd7a2278b99d71a49dfe3aec1721745a0e8806e6 (diff) | |
download | serenity-66481ad279934d18f258444b0ebfc73f52edc695.zip |
AK: Added explanatory comments in GenericLexer.h
-rw-r--r-- | AK/GenericLexer.h | 10 |
1 files 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<bool(char)>; 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); |