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

Method parse

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

Source from the content-addressed store, hash-verified

9512 using ParserBase::parse;
9513
9514 auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override {
9515
9516 struct ParserInfo {
9517 ParserBase const* parser = nullptr;
9518 size_t count = 0;
9519 };
9520 const size_t totalParsers = m_options.size() + m_args.size();
9521 assert( totalParsers < 512 );
9522 // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do
9523 ParserInfo parseInfos[512];
9524
9525 {
9526 size_t i = 0;
9527 for (auto const &opt : m_options) parseInfos[i++].parser = &opt;
9528 for (auto const &arg : m_args) parseInfos[i++].parser = &arg;
9529 }
9530
9531 m_exeName.set( exeName );
9532
9533 auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
9534 while( result.value().remainingTokens() ) {
9535 bool tokenParsed = false;
9536
9537 for( size_t i = 0; i < totalParsers; ++i ) {
9538 auto& parseInfo = parseInfos[i];
9539 if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {
9540 result = parseInfo.parser->parse(exeName, result.value().remainingTokens());
9541 if (!result)
9542 return result;
9543 if (result.value().type() != ParseResultType::NoMatch) {
9544 tokenParsed = true;
9545 ++parseInfo.count;
9546 break;
9547 }
9548 }
9549 }
9550
9551 if( result.value().type() == ParseResultType::ShortCircuitAll )
9552 return result;
9553 if( !tokenParsed )
9554 return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token );
9555 }
9556 // !TBD Check missing required options
9557 return result;
9558 }
9559 };
9560
9561 template<typename DerivedT>

Callers

nothing calls this directly

Calls 8

ParseStateClass · 0.85
sizeMethod · 0.80
setMethod · 0.80
remainingTokensMethod · 0.80
valueMethod · 0.45
cardinalityMethod · 0.45
parseMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected