コード例 #1
0
ファイル: skeleton.cpp プロジェクト: Execsl/usnap
character A_upper_calltype A_upper_input(bool writeback, character c, buffer& ib) {
	if (writeback) {
		ib.push_front(c); 
		return 0; 
	} else {
		if (ib.size() > 0) return ib.pop_front(); 
		return (character)fgetc(stdin); 
	}
}
コード例 #2
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;
}
コード例 #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;
}