mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
JSSpecCompiler: Parse "the *this* value" in expressions
This commit is contained in:
parent
ddf26a768c
commit
3e6a07154b
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 {};
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ private:
|
|||
TextParseErrorOr<Tree> parse_record_direct_list_initialization();
|
||||
TextParseErrorOr<Vector<Tree>> parse_function_arguments();
|
||||
TextParseErrorOr<Tree> parse_list_initialization();
|
||||
TextParseErrorOr<Tree> parse_the_this_value();
|
||||
TextParseErrorOr<Tree> parse_value();
|
||||
TextParseErrorOr<Tree> parse_expression();
|
||||
TextParseErrorOr<Tree> parse_condition();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue