| 5199 | namespace Catch { |
| 5200 | |
| 5201 | class TestSpecParser { |
| 5202 | enum Mode{ None, Name, QuotedName, Tag, EscapedName }; |
| 5203 | Mode m_mode = None; |
| 5204 | Mode lastMode = None; |
| 5205 | bool m_exclusion = false; |
| 5206 | std::size_t m_pos = 0; |
| 5207 | std::size_t m_realPatternPos = 0; |
| 5208 | std::string m_arg; |
| 5209 | std::string m_substring; |
| 5210 | std::string m_patternName; |
| 5211 | std::vector<std::size_t> m_escapeChars; |
| 5212 | TestSpec::Filter m_currentFilter; |
| 5213 | TestSpec m_testSpec; |
| 5214 | ITagAliasRegistry const* m_tagAliases = nullptr; |
| 5215 | |
| 5216 | public: |
| 5217 | TestSpecParser( ITagAliasRegistry const& tagAliases ); |
| 5218 | |
| 5219 | TestSpecParser& parse( std::string const& arg ); |
| 5220 | TestSpec testSpec(); |
| 5221 | |
| 5222 | private: |
| 5223 | bool visitChar( char c ); |
| 5224 | void startNewMode( Mode mode ); |
| 5225 | bool processNoneChar( char c ); |
| 5226 | void processNameChar( char c ); |
| 5227 | bool processOtherChar( char c ); |
| 5228 | void endMode(); |
| 5229 | void escape(); |
| 5230 | bool isControlChar( char c ) const; |
| 5231 | void saveLastMode(); |
| 5232 | void revertBackToLastMode(); |
| 5233 | void addFilter(); |
| 5234 | bool separate(); |
| 5235 | |
| 5236 | // Handles common preprocessing of the pattern for name/tag patterns |
| 5237 | std::string preprocessPattern(); |
| 5238 | // Adds the current pattern as a test name |
| 5239 | void addNamePattern(); |
| 5240 | // Adds the current pattern as a tag |
| 5241 | void addTagPattern(); |
| 5242 | |
| 5243 | inline void addCharToPattern(char c) { |
| 5244 | m_substring += c; |
| 5245 | m_patternName += c; |
| 5246 | m_realPatternPos++; |
| 5247 | } |
| 5248 | |
| 5249 | }; |
| 5250 | TestSpec parseTestSpec( std::string const& arg ); |
| 5251 | |
| 5252 | } // namespace Catch |