mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibUnicode: Add lexer to test if a string matches the "type" production
This commit is contained in:
parent
113bf4a9dd
commit
a05419db55
Notes:
sideshowbarker
2024-07-18 04:53:37 +09:00
Author: https://github.com/trflynn89
Commit: a05419db55
Pull-request: https://github.com/SerenityOS/serenity/pull/9749
Reviewed-by: https://github.com/linusg ✅
3 changed files with 35 additions and 0 deletions
|
@ -114,6 +114,22 @@ static Optional<StringView> consume_next_segment(GenericLexer& lexer, bool with_
|
|||
return segment;
|
||||
}
|
||||
|
||||
bool is_type_identifier(StringView identifier)
|
||||
{
|
||||
// type = alphanum{3,8} (sep alphanum{3,8})*
|
||||
GenericLexer lexer { identifier };
|
||||
|
||||
while (true) {
|
||||
auto type = consume_next_segment(lexer, lexer.tell() > 0);
|
||||
if (!type.has_value())
|
||||
break;
|
||||
if (!is_single_type(*type))
|
||||
return false;
|
||||
}
|
||||
|
||||
return lexer.is_eof() && (lexer.tell() > 0);
|
||||
}
|
||||
|
||||
static Optional<LanguageID> parse_unicode_language_id(GenericLexer& lexer)
|
||||
{
|
||||
// https://unicode.org/reports/tr35/#Unicode_language_identifier
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue