mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
LibJS: Remove unused nonterminals from the ISO8601 parser
This is an editorial change in the Temporal spec.
See: fe9ef00
This commit is contained in:
parent
42452a81a2
commit
2cf5f5c278
3 changed files with 21 additions and 292 deletions
|
@ -499,169 +499,6 @@ bool ISO8601Parser::parse_time_second()
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeHourNotValidMonth
|
||||
bool ISO8601Parser::parse_time_hour_not_valid_month()
|
||||
{
|
||||
// TimeHourNotValidMonth : one of
|
||||
// 00 13 14 15 16 17 18 19 20 21 23
|
||||
StateTransaction transaction { *this };
|
||||
auto success = m_state.lexer.consume_specific("00"sv)
|
||||
|| m_state.lexer.consume_specific("13"sv)
|
||||
|| m_state.lexer.consume_specific("14"sv)
|
||||
|| m_state.lexer.consume_specific("15"sv)
|
||||
|| m_state.lexer.consume_specific("16"sv)
|
||||
|| m_state.lexer.consume_specific("17"sv)
|
||||
|| m_state.lexer.consume_specific("18"sv)
|
||||
|| m_state.lexer.consume_specific("19"sv)
|
||||
|| m_state.lexer.consume_specific("20"sv)
|
||||
|| m_state.lexer.consume_specific("21"sv)
|
||||
|| m_state.lexer.consume_specific("22"sv)
|
||||
|| m_state.lexer.consume_specific("23"sv);
|
||||
if (!success)
|
||||
return false;
|
||||
m_state.parse_result.time_hour_not_valid_month = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeHourNotThirtyOneDayMonth
|
||||
bool ISO8601Parser::parse_time_hour_not_thirty_one_day_month()
|
||||
{
|
||||
// TimeHourNotThirtyOneDayMonth : one of
|
||||
// 02 04 06 09 11
|
||||
StateTransaction transaction { *this };
|
||||
auto success = m_state.lexer.consume_specific("02"sv)
|
||||
|| m_state.lexer.consume_specific("04"sv)
|
||||
|| m_state.lexer.consume_specific("06"sv)
|
||||
|| m_state.lexer.consume_specific("09"sv)
|
||||
|| m_state.lexer.consume_specific("11"sv);
|
||||
if (!success)
|
||||
return false;
|
||||
m_state.parse_result.time_hour_not_thirty_one_day_month = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeHourTwoOnly
|
||||
bool ISO8601Parser::parse_time_hour_two_only()
|
||||
{
|
||||
// TimeHourTwoOnly :
|
||||
// 02
|
||||
StateTransaction transaction { *this };
|
||||
if (!m_state.lexer.consume_specific("02"sv))
|
||||
return false;
|
||||
m_state.parse_result.time_hour_two_only = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeMinuteNotValidDay
|
||||
bool ISO8601Parser::parse_time_minute_not_valid_day()
|
||||
{
|
||||
// TimeMinuteNotValidDay :
|
||||
// 00
|
||||
// 32
|
||||
// 33
|
||||
// 34
|
||||
// 35
|
||||
// 36
|
||||
// 37
|
||||
// 38
|
||||
// 39
|
||||
// 4 DecimalDigit
|
||||
// 5 DecimalDigit
|
||||
// 60
|
||||
StateTransaction transaction { *this };
|
||||
if (m_state.lexer.consume_specific('4') || m_state.lexer.consume_specific('5')) {
|
||||
if (!parse_decimal_digit())
|
||||
return false;
|
||||
} else {
|
||||
auto success = m_state.lexer.consume_specific("00"sv)
|
||||
|| m_state.lexer.consume_specific("32"sv)
|
||||
|| m_state.lexer.consume_specific("33"sv)
|
||||
|| m_state.lexer.consume_specific("34"sv)
|
||||
|| m_state.lexer.consume_specific("35"sv)
|
||||
|| m_state.lexer.consume_specific("36"sv)
|
||||
|| m_state.lexer.consume_specific("37"sv)
|
||||
|| m_state.lexer.consume_specific("38"sv)
|
||||
|| m_state.lexer.consume_specific("39"sv)
|
||||
|| m_state.lexer.consume_specific("60"sv);
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
m_state.parse_result.time_minute_not_valid_day = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeMinuteThirtyOnly
|
||||
bool ISO8601Parser::parse_time_minute_thirty_only()
|
||||
{
|
||||
// TimeMinuteThirtyOnly :
|
||||
// 30
|
||||
StateTransaction transaction { *this };
|
||||
if (!m_state.lexer.consume_specific("30"sv))
|
||||
return false;
|
||||
m_state.parse_result.time_minute_thirty_only = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeMinuteThirtyOneOnly
|
||||
bool ISO8601Parser::parse_time_minute_thirty_one_only()
|
||||
{
|
||||
// TimeMinuteThirtyOneOnly :
|
||||
// 31
|
||||
StateTransaction transaction { *this };
|
||||
if (!m_state.lexer.consume_specific("31"sv))
|
||||
return false;
|
||||
m_state.parse_result.time_minute_thirty_one_only = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeSecondNotValidMonth
|
||||
bool ISO8601Parser::parse_time_second_not_valid_month()
|
||||
{
|
||||
// TimeSecondNotValidMonth :
|
||||
// 00
|
||||
// 13
|
||||
// 14
|
||||
// 15
|
||||
// 16
|
||||
// 17
|
||||
// 18
|
||||
// 19
|
||||
// 2 DecimalDigit
|
||||
// 3 DecimalDigit
|
||||
// 4 DecimalDigit
|
||||
// 5 DecimalDigit
|
||||
// 60
|
||||
StateTransaction transaction { *this };
|
||||
if (m_state.lexer.consume_specific('2')
|
||||
|| m_state.lexer.consume_specific('3')
|
||||
|| m_state.lexer.consume_specific('4')
|
||||
|| m_state.lexer.consume_specific('5')) {
|
||||
if (!parse_decimal_digit())
|
||||
return false;
|
||||
} else {
|
||||
auto success = m_state.lexer.consume_specific("00"sv)
|
||||
|| m_state.lexer.consume_specific("13"sv)
|
||||
|| m_state.lexer.consume_specific("14"sv)
|
||||
|| m_state.lexer.consume_specific("15"sv)
|
||||
|| m_state.lexer.consume_specific("16"sv)
|
||||
|| m_state.lexer.consume_specific("17"sv)
|
||||
|| m_state.lexer.consume_specific("18"sv)
|
||||
|| m_state.lexer.consume_specific("19"sv)
|
||||
|| m_state.lexer.consume_specific("60"sv);
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
m_state.parse_result.time_second_not_valid_month = transaction.parsed_string_view();
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-FractionalPart
|
||||
bool ISO8601Parser::parse_fractional_part()
|
||||
{
|
||||
|
@ -819,38 +656,6 @@ bool ISO8601Parser::parse_time_zone_utc_offset()
|
|||
|| parse_utc_designator();
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeZoneNumericUTCOffsetNotAmbiguousWithDayOfMonth
|
||||
bool ISO8601Parser::parse_time_zone_numeric_utc_offset_not_ambiguous_with_day_of_month()
|
||||
{
|
||||
// TimeZoneNumericUTCOffsetNotAmbiguousWithDayOfMonth :
|
||||
// TimeZoneNumericUTCOffset but not - TimeZoneUTCOffsetHour
|
||||
StateTransaction transaction { *this };
|
||||
if (!parse_time_zone_numeric_utc_offset())
|
||||
return false;
|
||||
auto parsed = *m_state.parse_result.time_zone_numeric_utc_offset;
|
||||
if (parsed.length() == 3 && parsed[0] == '-')
|
||||
return false;
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeZoneNumericUTCOffsetNotAmbiguousWithMonth
|
||||
bool ISO8601Parser::parse_time_zone_numeric_utc_offset_not_ambiguous_with_month()
|
||||
{
|
||||
// TimeZoneNumericUTCOffsetNotAmbiguousWithMonth :
|
||||
// TimeZoneNumericUTCOffsetNotAmbiguousWithDayOfMonth
|
||||
// - TimeHourNotValidMonth
|
||||
StateTransaction transaction { *this };
|
||||
if (!parse_time_zone_numeric_utc_offset_not_ambiguous_with_day_of_month()) {
|
||||
if (!m_state.lexer.consume_specific('-'))
|
||||
return false;
|
||||
if (!parse_time_hour_not_valid_month())
|
||||
return false;
|
||||
}
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeZoneUTCOffsetName
|
||||
bool ISO8601Parser::parse_time_zone_utc_offset_name()
|
||||
{
|
||||
|
@ -1145,45 +950,6 @@ bool ISO8601Parser::parse_time_spec()
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeHourMinuteBasicFormatNotAmbiguousWithMonthDay
|
||||
bool ISO8601Parser::parse_time_hour_minute_basic_format_not_ambiguous_with_month_day()
|
||||
{
|
||||
// TimeHourMinuteBasicFormatNotAmbiguousWithMonthDay :
|
||||
// TimeHourNotValidMonth TimeMinute
|
||||
// TimeHour TimeMinuteNotValidDay
|
||||
// TimeHourNotThirtyOneDayMonth TimeMinuteThirtyOneOnly
|
||||
// TimeHourTwoOnly TimeMinuteThirtyOnly
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour_not_valid_month() && parse_time_minute()) {
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour() && parse_time_minute_not_valid_day()) {
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour_not_thirty_one_day_month() && parse_time_minute_thirty_one_only()) {
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
{
|
||||
StateTransaction transaction { *this };
|
||||
if (parse_time_hour_two_only() && parse_time_minute_thirty_only()) {
|
||||
transaction.commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://tc39.es/proposal-temporal/#prod-TimeSpecWithOptionalTimeZoneNotAmbiguous
|
||||
bool ISO8601Parser::parse_time_spec_with_optional_time_zone_not_ambiguous()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue