From de1d7b33d6141a53eb6db17a5b309d06a9d85348 Mon Sep 17 00:00:00 2001 From: Frank Tang Date: Fri, 23 Sep 2022 23:28:46 -0700 Subject: [PATCH] [Temporal] Clean up parser Remove unused parser function/rule ParseTemporalTimeZoneString and ParseTemporalCalendarString were obsoleted by PR 2385 and 2394 in https://chromium-review.googlesource.com/c/v8/v8/+/3893552 https://chromium-review.googlesource.com/c/v8/v8/+/3901196 This cl is purely unused code removal. Bug: v8:11544 Change-Id: Ib7ff4a3860cffa09afe7c7f6866f8dc526273f34 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3917039 Commit-Queue: Frank Tang Reviewed-by: Adam Klein Cr-Commit-Position: refs/heads/main@{#83460} --- src/temporal/temporal-parser.cc | 49 ----------------- src/temporal/temporal-parser.h | 6 +-- .../temporal/temporal-parser-unittest.cc | 52 ------------------- 3 files changed, 2 insertions(+), 105 deletions(-) diff --git a/src/temporal/temporal-parser.cc b/src/temporal/temporal-parser.cc index 586cb4709c..229144e3d5 100644 --- a/src/temporal/temporal-parser.cc +++ b/src/temporal/temporal-parser.cc @@ -1055,31 +1055,6 @@ int32_t ScanTemporalZonedDateTimeString(base::Vector str, int32_t s, SCAN_FORWARD(TemporalDateTimeString, CalendarDateTime, ParsedISO8601Result) -// Date [TimeSpecSeparator] TimeZone [Calendar] -template -int32_t ScanDate_TimeSpecSeparator_TimeZone_Calendar(base::Vector str, - int32_t s, - ParsedISO8601Result* r) { - int32_t cur = s; - int32_t len = ScanDate(str, cur, r); - if (len == 0) return 0; - cur = len; - cur += ScanTimeSpecSeparator(str, cur, r); - len = ScanTimeZone(str, cur, r); - if (len == 0) return 0; - cur += len; - cur += ScanCalendar(str, cur, r); - return cur - s; -} - -// TemporalTimeZoneString: -// TimeZoneIdentifier -// Date [TimeSpecSeparator] TimeZone [Calendar] -// The lookahead is at most 8 chars. -SCAN_EITHER_FORWARD(TemporalTimeZoneString, TimeZoneIdentifier, - Date_TimeSpecSeparator_TimeZone_Calendar, - ParsedISO8601Result) - // TemporalMonthDayString // DateSpecMonthDay // CalendarDateTime @@ -1140,7 +1115,6 @@ SATISIFY(TemporalDateTimeString, ParsedISO8601Result) SATISIFY(DateTime, ParsedISO8601Result) SATISIFY(DateSpecYearMonth, ParsedISO8601Result) SATISIFY(DateSpecMonthDay, ParsedISO8601Result) -SATISIFY(Date_TimeSpecSeparator_TimeZone_Calendar, ParsedISO8601Result) SATISIFY(CalendarDateTime, ParsedISO8601Result) SATISIFY(CalendarTime_L1, ParsedISO8601Result) SATISIFY(CalendarTime_L2, ParsedISO8601Result) @@ -1160,32 +1134,11 @@ SATISIFY_EITHER(TemporalMonthDayString, DateSpecMonthDay, CalendarDateTime, ParsedISO8601Result) SATISIFY(TimeZoneNumericUTCOffset, ParsedISO8601Result) SATISIFY(TimeZoneIdentifier, ParsedISO8601Result) -SATISIFY_EITHER(TemporalTimeZoneString, TimeZoneIdentifier, - Date_TimeSpecSeparator_TimeZone_Calendar, ParsedISO8601Result) SATISIFY(TemporalInstantString, ParsedISO8601Result) SATISIFY(TemporalZonedDateTimeString, ParsedISO8601Result) SATISIFY(CalendarName, ParsedISO8601Result) -// TemporalCalendarString : -// CalendarName -// TemporalInstantString -// CalendarDateTime -// CalendarTime -// DateSpecYearMonth -// DateSpecMonthDay -template -bool SatisfyTemporalCalendarString(base::Vector str, - ParsedISO8601Result* r) { - IF_SATISFY_RETURN(CalendarName) - IF_SATISFY_RETURN(TemporalInstantString) - IF_SATISFY_RETURN(CalendarDateTime) - IF_SATISFY_RETURN(CalendarTime) - IF_SATISFY_RETURN(DateSpecYearMonth) - IF_SATISFY_RETURN(DateSpecMonthDay) - return false; -} - // Duration // Digits : Digit [Digits] @@ -1445,9 +1398,7 @@ IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalMonthDayString) IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalTimeString) IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalInstantString) IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalZonedDateTimeString) -IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalTimeZoneString) IMPL_PARSE_METHOD(ParsedISO8601Result, TimeZoneIdentifier) -IMPL_PARSE_METHOD(ParsedISO8601Result, TemporalCalendarString) IMPL_PARSE_METHOD(ParsedISO8601Result, CalendarName) IMPL_PARSE_METHOD(ParsedISO8601Result, TimeZoneNumericUTCOffset) IMPL_PARSE_METHOD(ParsedISO8601Duration, TemporalDurationString) diff --git a/src/temporal/temporal-parser.h b/src/temporal/temporal-parser.h index dd48a9acf2..bfcd90aef0 100644 --- a/src/temporal/temporal-parser.h +++ b/src/temporal/temporal-parser.h @@ -15,9 +15,9 @@ namespace internal { * ParsedISO8601Result contains the parsed result of ISO 8601 grammar * documented in #sec-temporal-iso8601grammar * for TemporalInstantString, TemporalZonedDateTimeString, - * TemporalCalendarString, TemporalDateString, TemporalDateTimeString, + * CalendarName, TemporalDateString, TemporalDateTimeString, * TemporalMonthDayString, TemporalRelativeToString, TemporalTimeString, - * TemporalTimeZoneString, and TemporalYearMonthString. For all the fields + * TimeZoneIdentifier, and TemporalYearMonthString. For all the fields * represented by int32_t, a special value kMinInt31 is used to represent the * field is "undefined" after parsing. */ @@ -143,10 +143,8 @@ class V8_EXPORT_PRIVATE TemporalParser { DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalMonthDayString); DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalInstantString); DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalZonedDateTimeString); - DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalTimeZoneString); DEFINE_PARSE_METHOD(ParsedISO8601Result, TimeZoneIdentifier); DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalRelativeToString); - DEFINE_PARSE_METHOD(ParsedISO8601Result, TemporalCalendarString); DEFINE_PARSE_METHOD(ParsedISO8601Result, CalendarName); DEFINE_PARSE_METHOD(ParsedISO8601Duration, TemporalDurationString); DEFINE_PARSE_METHOD(ParsedISO8601Result, TimeZoneNumericUTCOffset); diff --git a/test/unittests/temporal/temporal-parser-unittest.cc b/test/unittests/temporal/temporal-parser-unittest.cc index a6086637c7..319bfd012e 100644 --- a/test/unittests/temporal/temporal-parser-unittest.cc +++ b/test/unittests/temporal/temporal-parser-unittest.cc @@ -158,17 +158,6 @@ class TemporalParserTest : public TestWithIsolate { } } - void VerifyParseTemporalCalendarStringSuccess( - const char* str, const std::string& calendar_name) { - Handle input = MakeString(str); - base::Optional result = - TemporalParser::ParseTemporalCalendarString(i_isolate(), input); - CHECK(result.has_value()); - ParsedISO8601Result actual = *result; - CheckCalendar(i_isolate(), input, actual.calendar_name_start, - actual.calendar_name_length, calendar_name); - } - void VerifyParseCalendarNameSuccess(const char* str) { Handle input = MakeString(str); base::Optional result = @@ -1627,47 +1616,6 @@ TEST_F(TemporalParserTest, TemporalZonedDateTimeStringIllegal) { VERIFY_PARSE_FAIL_ON_ZONED_DATE_TIME(TemporalZonedDateTimeString); } -TEST_F(TemporalParserTest, TemporalCalendarStringSuccess) { - // CalendarName - VerifyParseTemporalCalendarStringSuccess("chinese", "chinese"); - VerifyParseTemporalCalendarStringSuccess("roc", "roc"); - VerifyParseTemporalCalendarStringSuccess("indian", "indian"); - VerifyParseTemporalCalendarStringSuccess("persian", "persian"); - VerifyParseTemporalCalendarStringSuccess("abcd-efghi", "abcd-efghi"); - VerifyParseTemporalCalendarStringSuccess("abcd-efghi", "abcd-efghi"); - VerifyParseTemporalCalendarStringSuccess( - "a2345678-b2345678-c2345678-d7654321", - "a2345678-b2345678-c2345678-d7654321"); - // TemporalInstantString - VerifyParseTemporalCalendarStringSuccess("2021-11-08z[ABCD]", ""); - // CalendarDateTime - VerifyParseTemporalCalendarStringSuccess("2021-11-08[u-ca=chinese]", - "chinese"); - VerifyParseTemporalCalendarStringSuccess("2021-11-08[ABCDEFG][u-ca=chinese]", - "chinese"); - VerifyParseTemporalCalendarStringSuccess( - "2021-11-08[ABCDEFG/hijklmn][u-ca=roc]", "roc"); - // Time - VerifyParseTemporalCalendarStringSuccess("23:45:59", ""); - // DateSpecYearMonth - VerifyParseTemporalCalendarStringSuccess("2021-12", ""); - // DateSpecMonthDay - VerifyParseTemporalCalendarStringSuccess("--12-31", ""); - VerifyParseTemporalCalendarStringSuccess("12-31", ""); - VerifyParseTemporalCalendarStringSuccess("--1231", ""); -} - -TEST_F(TemporalParserTest, TemporalCalendarStringIllegal) { - VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=]"); - VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=a]"); - VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=ab]"); - VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=abcdef-ab]"); - VERIFY_PARSE_FAIL(TemporalCalendarString, "20210304[u-ca=abcdefghijkl]"); - // It is a Syntax Error if DateExtendedYear is "-000000" - VERIFY_PARSE_FAIL(TemporalCalendarString, "-0000000304[u-ca=abcdef-ab]"); - VERIFY_PARSE_FAIL(TemporalCalendarString, "\u22120000000304[u-ca=abcdef-ab]"); -} - constexpr int64_t empty = ParsedISO8601Duration::kEmpty; // Test basic cases.