Пример #1
0
// ni stands for "next int".
int ni(buffer& buf)
{
	int i = atoi(buf.front().c_str());
	if (i == 0)
		for(char ch : buf.front())
			if (!isdigit(ch))
				error("Expected number, found \"" +
					buf.front() + "\".");
	buf.pop_front();
	return i;
}
Пример #2
0
std::string comma_list(const buffer& buf)
{
	std::string str;
	if (buf.size() == 0)
		str = "";
	else if (buf.size() == 1)
		str = buf.front();
	else if (buf.size() == 2)
		str = buf.front() + " and " + buf.back();
	else
	{
		buffer::const_iterator it = buf.begin();
		str = "and " + *(it++);

		for (;it != buf.end(); it++)
			str = *it + ", " + str;
	}
	return str;
}
Пример #3
0
// ns stands for "next std::string".
std::string ns(buffer& buf)
{
	std::string s = buf.front();
	buf.pop_front();
	return s;
}
Пример #4
0
// nch stands of "next char".
char nch(buffer& buf)
{
	char ch = (buf.front()[0]);
	buf.pop_front();
	return ch;
}