MCPcopy Create free account
hub / github.com/apache/qpid-proton / parse

Method parse

tests/include/catch.hpp:9423–9457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9421 using ParserBase::parse;
9422
9423 auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
9424 auto validationResult = validate();
9425 if( !validationResult )
9426 return InternalParseResult( validationResult );
9427
9428 auto remainingTokens = tokens;
9429 if( remainingTokens && remainingTokens->type == TokenType::Option ) {
9430 auto const &token = *remainingTokens;
9431 if( isMatch(token.token ) ) {
9432 if( m_ref->isFlag() ) {
9433 auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
9434 auto result = flagRef->setFlag( true );
9435 if( !result )
9436 return InternalParseResult( result );
9437 if( result.value() == ParseResultType::ShortCircuitAll )
9438 return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
9439 } else {
9440 auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
9441 ++remainingTokens;
9442 if( !remainingTokens )
9443 return InternalParseResult::runtimeError( "Expected argument following " + token.token );
9444 auto const &argToken = *remainingTokens;
9445 if( argToken.type != TokenType::Argument )
9446 return InternalParseResult::runtimeError( "Expected argument following " + token.token );
9447 auto result = valueRef->setValue( argToken.token );
9448 if( !result )
9449 return InternalParseResult( result );
9450 if( result.value() == ParseResultType::ShortCircuitAll )
9451 return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
9452 }
9453 return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );
9454 }
9455 }
9456 return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
9457 }
9458
9459 auto validate() const -> Result override {
9460 if( m_optNames.empty() )

Callers

nothing calls this directly

Calls 7

validateFunction · 0.85
ParseStateClass · 0.85
isFlagMethod · 0.45
getMethod · 0.45
setFlagMethod · 0.45
valueMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected