diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationClause.cpp b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationClause.cpp index bcf7d87e3e7..1e03ce34fd4 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationClause.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationClause.cpp @@ -26,6 +26,9 @@ NonnullOwnPtr SpecificationClause::create(SpecificationPars }, [&](OneOf auto const&) { result = make(move(specification_clause)); + }, + [&](ClauseHeader::PropertiesList const&) { + result = make(move(specification_clause)); }); if (!result->post_initialize(element)) diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationParsing.h b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationParsing.h index 87e8226db11..088b654efef 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationParsing.h +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/SpecificationParsing.h @@ -150,6 +150,14 @@ private: Algorithm m_algorithm; }; +class ObjectProperties : public SpecificationClause { +public: + ObjectProperties(SpecificationClause&& clause) + : SpecificationClause(move(clause)) + { + } +}; + class Specification { public: static NonnullOwnPtr create(SpecificationParsingContext& ctx, XML::Node const* element); diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp index 19a391d1769..e7f9ac30d19 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.cpp @@ -731,6 +731,47 @@ TextParseErrorOr TextParser::parse_accessor_declaration() return accessor; } +// :== | Properties of the Prototype Object $ +// | Properties of the Constructor $ +// | Properties of Instances $ +// | The Constructor $ +TextParseErrorOr TextParser::parse_properties_list_declaration() +{ + auto rollback = rollback_point(); + + ClauseHeader::PropertiesList properties_list; + + if (!consume_word("The"sv).is_error()) { + properties_list.name = TRY(parse_qualified_name()); + properties_list.object_type = ClauseHeader::ObjectType::Constructor; + TRY(consume_word("Constructor"sv)); + } else { + TRY(consume_words({ "Properties"sv, "of"sv })); + + bool has_the = !consume_word("the"sv).is_error(); + + properties_list.name = TRY(parse_qualified_name()); + + if (!has_the) { + TRY(consume_word("Instances"sv)); + properties_list.object_type = ClauseHeader::ObjectType::Instance; + } else { + if (consume_word("Prototype"sv).is_error()) { + TRY(consume_word("Constructor"sv)); + properties_list.object_type = ClauseHeader::ObjectType::Constructor; + } else { + TRY(consume_word("Object"sv)); + properties_list.object_type = ClauseHeader::ObjectType::Prototype; + } + } + } + + TRY(expect_eof()); + + rollback.disarm(); + return properties_list; +} + TextParseErrorOr TextParser::parse_method_declaration() { auto rollback = rollback_point(); @@ -764,6 +805,9 @@ TextParseErrorOr TextParser::parse_clause_header(ClauseHasAoidAttr } else if (auto method = parse_method_declaration(); !method.is_error()) { result.header = method.release_value(); return result; + } else if (auto properties_list = parse_properties_list_declaration(); !properties_list.is_error()) { + result.header = properties_list.release_value(); + return result; } } return TextParseError {}; diff --git a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h index 8267499ed05..b7793fbb235 100644 --- a/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h +++ b/Meta/Lagom/Tools/CodeGenerators/JSSpecCompiler/Parser/TextParser.h @@ -13,8 +13,19 @@ namespace JSSpecCompiler { struct ClauseHeader { + enum class ObjectType { + Constructor, + Prototype, + Instance, + }; + + struct PropertiesList { + QualifiedName name; + ObjectType object_type; + }; + StringView section_number; - Variant header; + Variant header; }; struct TextParseError { }; @@ -93,6 +104,7 @@ private: TextParseErrorOr parse_abstract_operation_declaration(); TextParseErrorOr parse_method_declaration(); TextParseErrorOr parse_accessor_declaration(); + TextParseErrorOr parse_properties_list_declaration(); SpecificationParsingContext& m_ctx; Vector const& m_tokens;