MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / parse

Method parse

Source/ThirdParty/catch2/catch.hpp:9593–9637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9591 using ParserBase::parse;
9592
9593 auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override {
9594
9595 struct ParserInfo {
9596 ParserBase const* parser = nullptr;
9597 size_t count = 0;
9598 };
9599 const size_t totalParsers = m_options.size() + m_args.size();
9600 assert( totalParsers < 512 );
9601 // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do
9602 ParserInfo parseInfos[512];
9603
9604 {
9605 size_t i = 0;
9606 for (auto const &opt : m_options) parseInfos[i++].parser = &opt;
9607 for (auto const &arg : m_args) parseInfos[i++].parser = &arg;
9608 }
9609
9610 m_exeName.set( exeName );
9611
9612 auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
9613 while( result.value().remainingTokens() ) {
9614 bool tokenParsed = false;
9615
9616 for( size_t i = 0; i < totalParsers; ++i ) {
9617 auto& parseInfo = parseInfos[i];
9618 if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {
9619 result = parseInfo.parser->parse(exeName, result.value().remainingTokens());
9620 if (!result)
9621 return result;
9622 if (result.value().type() != ParseResultType::NoMatch) {
9623 tokenParsed = true;
9624 ++parseInfo.count;
9625 break;
9626 }
9627 }
9628 }
9629
9630 if( result.value().type() == ParseResultType::ShortCircuitAll )
9631 return result;
9632 if( !tokenParsed )
9633 return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token );
9634 }
9635 // !TBD Check missing required options
9636 return result;
9637 }
9638 };
9639
9640 template<typename DerivedT>

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected