17 m_start = std::string::npos;
19 m_escapeChars.clear();
20 for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
21 visitChar( m_arg[m_pos] );
23 addPattern<TestSpec::NamePattern>();
31 void TestSpecParser::visitChar(
char c ) {
32 if( m_mode == None ) {
35 case '~': m_exclusion =
true;
return;
36 case '[':
return startNewMode( Tag, ++m_pos );
37 case '"':
return startNewMode( QuotedName, ++m_pos );
38 case '\\':
return escape();
39 default: startNewMode( Name, m_pos );
break;
42 if( m_mode == Name ) {
44 addPattern<TestSpec::NamePattern>();
48 if( subString() ==
"exclude:" )
51 addPattern<TestSpec::NamePattern>();
52 startNewMode( Tag, ++m_pos );
57 else if( m_mode == EscapedName )
59 else if( m_mode == QuotedName && c ==
'"' )
60 addPattern<TestSpec::NamePattern>();
61 else if( m_mode == Tag && c ==
']' )
62 addPattern<TestSpec::TagPattern>();
64 void TestSpecParser::startNewMode( Mode mode, std::size_t start ) {
68 void TestSpecParser::escape() {
72 m_escapeChars.push_back( m_pos );
74 std::string TestSpecParser::subString()
const {
return m_arg.substr( m_start, m_pos - m_start ); }
76 void TestSpecParser::addFilter() {
77 if( !m_currentFilter.m_patterns.empty() ) {
78 m_testSpec.m_filters.push_back( m_currentFilter );
79 m_currentFilter = TestSpec::Filter();
TestSpecParser(ITagAliasRegistry const &tagAliases)
TestSpecParser & parse(std::string const &arg)
TestSpec parseTestSpec(std::string const &arg)
static ITagAliasRegistry const & get()
virtual std::string expandAliases(std::string const &unexpandedTestSpec) const =0