MCPcopy Create free account
hub / github.com/SerenityOS/jakt / parse_operator

Method parse_operator

bootstrap/stage0/parser.cpp:8834–8901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8832}
8833
8834NonnullRefPtr<typename Jakt::parser::ParsedExpression> Jakt::parser::Parser::parse_operator(bool const allow_assignments) {
8835{
8836Jakt::utility::Span const span = this->current().span();
8837Jakt::parser::BinaryOperator const op = ({
8838 auto&& _jakt_value = ([&]() -> JaktInternal::ExplicitValueOrControlFlow<Jakt::parser::BinaryOperator, NonnullRefPtr<typename Jakt::parser::ParsedExpression>>{
8839auto&& __jakt_match_variant = this->current();
8840switch(__jakt_match_variant.__jakt_init_index()) {
8841case 50 /* QuestionMarkQuestionMark */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::NoneCoalescing());
8842case 14 /* Plus */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Add());
8843case 15 /* Minus */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Subtract());
8844case 36 /* Asterisk */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Multiply());
8845case 47 /* ForwardSlash */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Divide());
8846case 13 /* PercentSign */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Modulo());
8847case 59 /* And */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::LogicalAnd());
8848case 90 /* Or */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::LogicalOr());
8849case 25 /* DoubleEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Equal());
8850case 24 /* NotEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::NotEqual());
8851case 28 /* LessThan */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::LessThan());
8852case 29 /* LessThanOrEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::LessThanOrEqual());
8853case 26 /* GreaterThan */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::GreaterThan());
8854case 27 /* GreaterThanOrEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::GreaterThanOrEqual());
8855case 37 /* Ampersand */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseAnd());
8856case 39 /* AmpersandAmpersand */:{
8857this->error(ByteString::from_utf8_without_validation("‘&&’ is not allowed, use ‘and’ instead"sv),span);
8858return JaktInternal::ExplicitValue<Jakt::parser::BinaryOperator>(Jakt::parser::BinaryOperator::LogicalAnd());
8859}
8860VERIFY_NOT_REACHED();
8861case 40 /* Pipe */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseOr());
8862case 42 /* PipePipe */:{
8863this->error(ByteString::from_utf8_without_validation("‘||’ is not allowed, use ‘or’ instead"sv),span);
8864return JaktInternal::ExplicitValue<Jakt::parser::BinaryOperator>(Jakt::parser::BinaryOperator::LogicalOr());
8865}
8866VERIFY_NOT_REACHED();
8867case 43 /* Caret */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseXor());
8868case 31 /* LeftShift */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseLeftShift());
8869case 33 /* RightShift */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseRightShift());
8870case 30 /* LeftArithmeticShift */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::ArithmeticLeftShift());
8871case 34 /* RightArithmeticShift */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::ArithmeticRightShift());
8872case 16 /* Equal */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::Assign());
8873case 32 /* LeftShiftEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseLeftShiftAssign());
8874case 35 /* RightShiftEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseRightShiftAssign());
8875case 38 /* AmpersandEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseAndAssign());
8876case 41 /* PipeEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseOrAssign());
8877case 44 /* CaretEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::BitwiseXorAssign());
8878case 17 /* PlusEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::AddAssign());
8879case 19 /* MinusEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::SubtractAssign());
8880case 21 /* AsteriskEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::MultiplyAssign());
8881case 22 /* ForwardSlashEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::DivideAssign());
8882case 23 /* PercentSignEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::ModuloAssign());
8883case 51 /* QuestionMarkQuestionMarkEqual */:return JaktInternal::ExplicitValue(Jakt::parser::BinaryOperator::NoneCoalescingAssign());
8884default:{
8885return Jakt::parser::ParsedExpression::Garbage(span);
8886}
8887}/*switch end*/
8888}()
8889);
8890 if (_jakt_value.is_return())
8891 return _jakt_value.release_return();

Callers 1

parse_expressionMethod · 0.95

Calls 9

currentMethod · 0.95
errorMethod · 0.95
is_assignmentMethod · 0.80
ExplicitValueClass · 0.50
spanMethod · 0.45
__jakt_init_indexMethod · 0.45
is_returnMethod · 0.45
release_returnMethod · 0.45
release_valueMethod · 0.45

Tested by

no test coverage detected