mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Only match alternative syntax if entire stream consumed
Previously we would consider an alternative syntax child to be a match as long as parsing produced a value, even if there were trailing tokens (which would later invalidate it within `parse_with_a_syntax`). This meant that we wouldn't consider later alternatives which may actually produce a valid match.
This commit is contained in:
Notes:
github-actions[bot]
2026-03-26 01:13:15 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/283f8e46a4f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8330 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -290,8 +290,12 @@ RefPtr<StyleValue const> Parser::parse_according_to_syntax_node(TokenStream<Comp
|
||||
case SyntaxNode::NodeType::Alternatives: {
|
||||
auto const& alternatives_node = as<AlternativesSyntaxNode>(syntax_node);
|
||||
for (auto const& child : alternatives_node.children()) {
|
||||
if (auto result = parse_according_to_syntax_node(tokens, *child)) {
|
||||
transaction.commit();
|
||||
auto alternative_transaction = transaction.create_child();
|
||||
auto result = parse_according_to_syntax_node(tokens, *child);
|
||||
tokens.discard_whitespace();
|
||||
|
||||
if (result && tokens.is_empty()) {
|
||||
alternative_transaction.commit();
|
||||
return result.release_nonnull();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user