mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:07:45 +00:00
LibWeb: Use GenericLexer in WrapperGenerator
This commit is contained in:
parent
0d52e7f6e3
commit
064159d215
3 changed files with 70 additions and 92 deletions
|
@ -56,6 +56,15 @@ bool GenericLexer::next_is(char expected) const
|
|||
return peek() == expected;
|
||||
}
|
||||
|
||||
// Tests if the `expected` string comes next in the input
|
||||
bool GenericLexer::next_is(StringView expected) const
|
||||
{
|
||||
for (size_t i = 0; i < expected.length(); ++i)
|
||||
if (peek(i) != expected[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Tests if the `expected` string comes next in the input
|
||||
bool GenericLexer::next_is(const char* expected) const
|
||||
{
|
||||
|
@ -89,15 +98,21 @@ bool GenericLexer::consume_specific(char specific)
|
|||
}
|
||||
|
||||
// Consume the given string if it is next in the input
|
||||
bool GenericLexer::consume_specific(const char* str)
|
||||
bool GenericLexer::consume_specific(StringView str)
|
||||
{
|
||||
if (!next_is(str))
|
||||
return false;
|
||||
|
||||
ignore(__builtin_strlen(str));
|
||||
ignore(str.length());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Consume the given string if it is next in the input
|
||||
bool GenericLexer::consume_specific(const char* str)
|
||||
{
|
||||
return consume_specific(StringView(str));
|
||||
}
|
||||
|
||||
// Consume a number of characters
|
||||
StringView GenericLexer::consume(size_t count)
|
||||
{
|
||||
|
|
|
@ -45,27 +45,29 @@ public:
|
|||
|
||||
char peek(size_t offset = 0) const;
|
||||
|
||||
bool next_is(char expected) const;
|
||||
bool next_is(const char* expected) const;
|
||||
bool next_is(char) const;
|
||||
bool next_is(StringView) const;
|
||||
bool next_is(const char*) const;
|
||||
bool next_is(Condition) const;
|
||||
|
||||
char consume();
|
||||
bool consume_specific(char specific);
|
||||
bool consume_specific(const char* str);
|
||||
bool consume_specific(char);
|
||||
bool consume_specific(StringView);
|
||||
bool consume_specific(const char*);
|
||||
StringView consume(size_t count);
|
||||
StringView consume_all();
|
||||
StringView consume_line();
|
||||
StringView consume_while(Condition);
|
||||
StringView consume_until(char stop);
|
||||
StringView consume_until(const char* stop);
|
||||
StringView consume_until(char);
|
||||
StringView consume_until(const char*);
|
||||
StringView consume_until(Condition);
|
||||
// FIXME: provide an escape character
|
||||
StringView consume_quoted_string();
|
||||
|
||||
void ignore(size_t count = 1);
|
||||
void ignore_while(Condition);
|
||||
void ignore_until(char stop);
|
||||
void ignore_until(const char* stop);
|
||||
void ignore_until(char);
|
||||
void ignore_until(const char*);
|
||||
void ignore_until(Condition);
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue