MCPcopy Create free account
hub / github.com/Profactor/cv-plot / parse

Method parse

CvPlot/ext/catch2/inc/catch.hpp:9337–9371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9335 using ParserBase::parse;
9336
9337 auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {
9338 auto validationResult = validate();
9339 if( !validationResult )
9340 return InternalParseResult( validationResult );
9341
9342 auto remainingTokens = tokens;
9343 if( remainingTokens && remainingTokens->type == TokenType::Option ) {
9344 auto const &token = *remainingTokens;
9345 if( isMatch(token.token ) ) {
9346 if( m_ref->isFlag() ) {
9347 auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );
9348 auto result = flagRef->setFlag( true );
9349 if( !result )
9350 return InternalParseResult( result );
9351 if( result.value() == ParseResultType::ShortCircuitAll )
9352 return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
9353 } else {
9354 auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
9355 ++remainingTokens;
9356 if( !remainingTokens )
9357 return InternalParseResult::runtimeError( "Expected argument following " + token.token );
9358 auto const &argToken = *remainingTokens;
9359 if( argToken.type != TokenType::Argument )
9360 return InternalParseResult::runtimeError( "Expected argument following " + token.token );
9361 auto result = valueRef->setValue( argToken.token );
9362 if( !result )
9363 return InternalParseResult( result );
9364 if( result.value() == ParseResultType::ShortCircuitAll )
9365 return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );
9366 }
9367 return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );
9368 }
9369 }
9370 return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
9371 }
9372
9373 auto validate() const -> Result override {
9374 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