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

Method parse

tests/catch.hpp:7487–7531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7485 using ParserBase::parse;
7486
7487 auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override {
7488
7489 struct ParserInfo {
7490 ParserBase const* parser = nullptr;
7491 size_t count = 0;
7492 };
7493 const size_t totalParsers = m_options.size() + m_args.size();
7494 assert( totalParsers < 512 );
7495 // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do
7496 ParserInfo parseInfos[512];
7497
7498 {
7499 size_t i = 0;
7500 for (auto const &opt : m_options) parseInfos[i++].parser = &opt;
7501 for (auto const &arg : m_args) parseInfos[i++].parser = &arg;
7502 }
7503
7504 m_exeName.set( exeName );
7505
7506 auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );
7507 while( result.value().remainingTokens() ) {
7508 bool tokenParsed = false;
7509
7510 for( size_t i = 0; i < totalParsers; ++i ) {
7511 auto& parseInfo = parseInfos[i];
7512 if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {
7513 result = parseInfo.parser->parse(exeName, result.value().remainingTokens());
7514 if (!result)
7515 return result;
7516 if (result.value().type() != ParseResultType::NoMatch) {
7517 tokenParsed = true;
7518 ++parseInfo.count;
7519 break;
7520 }
7521 }
7522 }
7523
7524 if( result.value().type() == ParseResultType::ShortCircuitAll )
7525 return result;
7526 if( !tokenParsed )
7527 return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token );
7528 }
7529 // !TBD Check missing required options
7530 return result;
7531 }
7532 };
7533
7534 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