mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +00:00
LibWeb: Extract CalculationNode::constant_type_from_string() function
This is needed by some upcoming generated code. Renamed "PI" member to "Pi" while I was at it.
This commit is contained in:
parent
e4a2bd7a44
commit
136dc7a1c3
Notes:
sideshowbarker
2024-07-17 07:16:27 +09:00
Author: https://github.com/AtkinsSJ
Commit: 136dc7a1c3
Pull-request: https://github.com/SerenityOS/serenity/pull/19996
3 changed files with 27 additions and 25 deletions
|
@ -8932,28 +8932,9 @@ ErrorOr<OwnPtr<CalculationNode>> Parser::parse_a_calculation(Vector<ComponentVal
|
|||
}
|
||||
|
||||
if (value.is(Token::Type::Ident)) {
|
||||
if (value.token().ident().equals_ignoring_ascii_case("e"sv)) {
|
||||
TRY(values.try_append({ TRY(ConstantCalculationNode::create(CalculationNode::ConstantType::E)) }));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.token().ident().equals_ignoring_ascii_case("pi"sv)) {
|
||||
TRY(values.try_append({ TRY(ConstantCalculationNode::create(CalculationNode::ConstantType::PI)) }));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.token().ident().equals_ignoring_ascii_case("infinity"sv)) {
|
||||
TRY(values.try_append({ TRY(ConstantCalculationNode::create(CalculationNode::ConstantType::Infinity)) }));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.token().ident().equals_ignoring_ascii_case("-infinity"sv)) {
|
||||
TRY(values.try_append({ TRY(ConstantCalculationNode::create(CalculationNode::ConstantType::MinusInfinity)) }));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value.token().ident().equals_ignoring_ascii_case("NaN"sv)) {
|
||||
TRY(values.try_append({ TRY(ConstantCalculationNode::create(CalculationNode::ConstantType::NaN)) }));
|
||||
auto maybe_constant = CalculationNode::constant_type_from_string(value.token().ident());
|
||||
if (maybe_constant.has_value()) {
|
||||
TRY(values.try_append({ TRY(ConstantCalculationNode::create(maybe_constant.value())) }));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue