public static void parse(String string, Grammar grammar, LRParseTable table) {
		string = string + "$";
		int p = 0;
		IntStack stack = new IntStack();
		stack.push(0);
		Production[] productions = grammar.getProductions();
		while (true) {
			int state = stack.peekInt();
			String read = "" + string.charAt(p);
			String entry = table.getValueAt(state, read);
			// //System.out.println("Action: "+entry);
			// //System.out.println("Stack : "+stack);
			// //System.out.println("Input : "+string.substring(p));
			if (entry.length() == 0) {
				// Error! No derivation.
				// //System.out.println("Parse error");
				return;
			} else if (entry.charAt(0) == 's') {
				// Shift!
				stack.push(read); // Push the symbol.
				stack.push(Integer.parseInt(entry.substring(1)));
				p++; // Move to next input symbol.
			} else if (entry.charAt(0) == 'r') {
				// Reduce!
				int prodNumber = Integer.parseInt(entry.substring(1));
				Production red = productions[prodNumber];
				for (int i = 0; i < 2 * red.getRHS().length(); i++)
					stack.pop();
				state = stack.peekInt();
				stack.push(red.getLHS());
				stack.push(Integer.parseInt(table.getValueAt(state, red
						.getLHS())));
				// //System.out.println(red);
			} else if (entry.charAt(0) == 'a') {
				// //System.out.println("Acceptance!");
				return;
			}
		}
	}