#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool nextToken(const string &s, string::size_type &start, string &token)
{
	token.clear();

	start = s.find_first_not_of(" \t", start);
	if (start == string::npos)
		return false;

	string::size_type end;

	if (s[start] == '\'')
	{
		++start;
		end = s.find('\'', start);
	}
	else
		end = s.find_first_of(" \t,", start);
	
	if (end == string::npos)
	{
		token = s.substr(start);
		start = s.size();
	}
	else
	{
		token = s.substr(start, end-start);
		if ((s[end] != ',') && ((end = s.find(',', end + 1)) == string::npos))
			start = s.size();
		else
			start = end + 1;
	}

	return true;
}

int main() {
	string s = "1, 10, 'abc', 'test, 1'", token;
	vector<string> v;
	
	string::size_type start = 0;
	while (nextToken(s, start, token))
		v.push_back(token);
	
	for (auto &token2 : v)
		cout << token2 << endl;

	return 0;
}