src/Generic/actors/JabariTokenMatcher.cpp
// Helper function for JabariTokenMatcher::addPattern().
// TODO: recursive call has SPACE(n!) growth on number of dashes, which crashes by
// using too much memory on a malformed pattern string. Add some checking?

Helper function for JabariTokenMatcher::addPattern().
TODO: recursive call has SPACE(n!) growth on number of dashes, which crashes by
using too much memory on a malformed pattern string.
Helper function for JabariTokenMatcher :: addPattern () . TODO : recursive call has SPACE ( n! ) growth on number of dashes which crashes by using too much memory on a malformed pattern string .
void findAllSplitsOnDash(const std::wstring &patternStr, std::vector<std::wstring> &result) {
		std::wstring::size_type pos = patternStr.find_first_of(L'-');
		if (pos == std::wstring::npos) {
			result.push_back(patternStr);
		} else {
			std::wstring lhs = patternStr.substr(0, pos);
			std::vector<std::wstring> rhs_expanded;
			findAllSplitsOnDash(patternStr.substr(pos+1), rhs_expanded);
			BOOST_FOREACH(const std::wstring &rhs, rhs_expanded) {
				result.push_back(lhs+L'-'+rhs);      
				result.push_back(lhs+rhs);           
				result.push_back(lhs+L"_ "+rhs);     
			}
		}
	}
void findAllSplitsOnDash ( const std :: wstring & patternStr , std :: vector < std :: wstring > & result ) { std :: wstring :: size_type pos = patternStr . find_first_of ( L' ' ) ; if ( pos == std :: wstring :: npos ) { result . push_back ( patternStr ) ; } else { std :: wstring lhs = patternStr . substr ( 0 , pos ) ; std :: vector < std :: wstring > rhs_expanded ; findAllSplitsOnDash ( patternStr . substr ( pos + 1 ) , rhs_expanded ) ; BOOST_FOREACH ( const std :: wstring & rhs , rhs_expanded ) { result . push_back ( lhs + L' ' + rhs ) ; result . push_back ( lhs + rhs ) ; result . push_back ( lhs + L" " + rhs ) ; } } }
Helper function for JabariTokenMatcher::addPattern().
Helper function for JabariTokenMatcher :: addPattern () .
// foo-bar     (one token)
 // foobar      (one token)
 // foo_ bar    (two tokens)
