diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp index 6f10f2f550..638dbdb622 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp @@ -194,6 +194,18 @@ TextParseErrorOr TextParser::parse_list_initialization() return make_ref_counted(move(elements)); } +TextParseErrorOr 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::Type::This); +} + // :== | | | | | | TextParseErrorOr TextParser::parse_value() { @@ -232,6 +244,9 @@ TextParseErrorOr 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 {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h index 5fb64df487..8d7d1190bf 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h @@ -78,6 +78,7 @@ private: TextParseErrorOr parse_record_direct_list_initialization(); TextParseErrorOr> parse_function_arguments(); TextParseErrorOr parse_list_initialization(); + TextParseErrorOr parse_the_this_value(); TextParseErrorOr parse_value(); TextParseErrorOr parse_expression(); TextParseErrorOr parse_condition(); diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml index 69ac82c49c..c85a1a2a38 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml @@ -63,4 +63,14 @@ + +

6 get Temporal.PlainDateTime.prototype.inLeapYear

+ +
    +
  1. Let dateTime be the this value.
  2. +
  3. Perform ? RequireInternalSlot(dateTime, [[A]]).
  4. +
  5. Return undefined.
  6. +
+
+
diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml.expectation b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml.expectation index 27213af633..01b6287810 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml.expectation +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Tests/spec-parsing.xml.expectation @@ -87,3 +87,16 @@ TreeList ReturnNode Enumerator unused +%get Temporal.PlainDateTime.prototype.inLeapYear%(): +TreeList + BinaryOperation Assignment + Var dateTime + WellKnownNode This + UnaryOperation ReturnIfAbrubt + FunctionCall + UnresolvedReference RequireInternalSlot + Var dateTime + Slot A + ReturnNode + WellKnownNode Undefined +