mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-25 04:22:50 +00:00
JSSpecCompiler: Parse "the *this* value" in expressions
This commit is contained in:
parent
ddf26a768c
commit
3e6a07154b
Notes:
sideshowbarker
2024-07-17 07:09:53 +09:00
Author: https://github.com/DanShaders
Commit: 3e6a07154b
Pull-request: https://github.com/SerenityOS/serenity/pull/23123
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 39 additions and 0 deletions
|
@ -194,6 +194,18 @@ TextParseErrorOr<Tree> TextParser::parse_list_initialization()
|
|||
return make_ref_counted<List>(move(elements));
|
||||
}
|
||||
|
||||
TextParseErrorOr<Tree> TextParser::parse_the_this_value()
|
||||
{
|
||||
auto rollback = rollback_point();
|
||||
|
||||
TRY(consume_word("the"sv));
|
||||
TRY(consume_token(TokenType::WellKnownValue, "this"sv));
|
||||
TRY(consume_word("value"sv));
|
||||
|
||||
rollback.disarm();
|
||||
return make_ref_counted<WellKnownNode>(WellKnownNode::Type::This);
|
||||
}
|
||||
|
||||
// <value> :== <identifier> | <well_known_value> | <enumerator> | <number> | <string> | <list_initialization> | <record_initialization>
|
||||
TextParseErrorOr<Tree> TextParser::parse_value()
|
||||
{
|
||||
|
@ -232,6 +244,9 @@ TextParseErrorOr<Tree> TextParser::parse_value()
|
|||
if (auto record_initialization = parse_record_direct_list_initialization(); !record_initialization.is_error())
|
||||
return record_initialization.release_value();
|
||||
|
||||
if (auto the_this_value = parse_the_this_value(); !the_this_value.is_error())
|
||||
return the_this_value.release_value();
|
||||
|
||||
return TextParseError {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue