///////
//
// Student: Russell Lowke
//     T.F: Francis Crick
// Unit Eight, pencil-and-paper - question 1 [worth 2pts],  8/2/2002
//
// Processing a line of text which may contain "delete" and "kill" characters.
//  "delete" means "remove the preceding character," while "kill" means "remove entire line"
//  You have two stacks that may be accessed only by stack operations and one char variable
//
//  describe an algorithm for processing the line of text:
// T S A {delete} T {kill} S T A K {delete} C K  into S T A C K


char c;
initialize stack<char> my_stack
initialize stack<char> rv_stack;

open_read
while (! eof) {
	read c
	switch (c) {
		case : kill
			while (! my_stack.EOL) {
				my_stack.pop(c)
			}
			break;
		case : delete
			my_stack.pop(c)
			break;
		otherwise:
			myStack.push(c)
	}
}
close

// reverse stack
while (! my_stack.EOL) {
	my_stack.pop(c)
	r_stack.push(c)
}

// write STACK
while (! my_stack.EOL) {
	rv_stack.pop(c)
	write c
}