MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / parse

Method parse

extern/Catch2/catch.hpp:9421–9455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected