| 5140 | namespace Catch { |
| 5141 | |
| 5142 | class TestSpecParser { |
| 5143 | enum Mode{ None, Name, QuotedName, Tag, EscapedName }; |
| 5144 | Mode m_mode = None; |
| 5145 | Mode lastMode = None; |
| 5146 | bool m_exclusion = false; |
| 5147 | std::size_t m_pos = 0; |
| 5148 | std::size_t m_realPatternPos = 0; |
| 5149 | std::string m_arg; |
| 5150 | std::string m_substring; |
| 5151 | std::string m_patternName; |
| 5152 | std::vector<std::size_t> m_escapeChars; |
| 5153 | TestSpec::Filter m_currentFilter; |
| 5154 | TestSpec m_testSpec; |
| 5155 | ITagAliasRegistry const* m_tagAliases = nullptr; |
| 5156 | |
| 5157 | public: |
| 5158 | TestSpecParser( ITagAliasRegistry const& tagAliases ); |
| 5159 | |
| 5160 | TestSpecParser& parse( std::string const& arg ); |
| 5161 | TestSpec testSpec(); |
| 5162 | |
| 5163 | private: |
| 5164 | bool visitChar( char c ); |
| 5165 | void startNewMode( Mode mode ); |
| 5166 | bool processNoneChar( char c ); |
| 5167 | void processNameChar( char c ); |
| 5168 | bool processOtherChar( char c ); |
| 5169 | void endMode(); |
| 5170 | void escape(); |
| 5171 | bool isControlChar( char c ) const; |
| 5172 | void saveLastMode(); |
| 5173 | void revertBackToLastMode(); |
| 5174 | void addFilter(); |
| 5175 | bool separate(); |
| 5176 | |
| 5177 | // Handles common preprocessing of the pattern for name/tag patterns |
| 5178 | std::string preprocessPattern(); |
| 5179 | // Adds the current pattern as a test name |
| 5180 | void addNamePattern(); |
| 5181 | // Adds the current pattern as a tag |
| 5182 | void addTagPattern(); |
| 5183 | |
| 5184 | inline void addCharToPattern(char c) { |
| 5185 | m_substring += c; |
| 5186 | m_patternName += c; |
| 5187 | m_realPatternPos++; |
| 5188 | } |
| 5189 | |
| 5190 | }; |
| 5191 | TestSpec parseTestSpec( std::string const& arg ); |
| 5192 | |
| 5193 | } // namespace Catch |