mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue