/**
 * It uses "currentToken" and "expectedTokenSequences" to generate a parse
 * error message and returns it.  If this object has been created
 * due to a parse error, and you do not catch it (it gets thrown
 * from the parser) the correct error message
 * gets displayed.
 */
private static String initialise(Token currentToken, int[][] expectedTokenSequences, String[] tokenImage) {
	int maxSize = 0;

	// Build the list of expected tokens:
	StringBuffer expected = new StringBuffer();
	for (int i = 0; i < expectedTokenSequences.length; i++) {
		if (maxSize < expectedTokenSequences[i].length) {
			maxSize = expectedTokenSequences[i].length;
		}
		for (int j = 0; j < expectedTokenSequences[i].length; j++) {
			expected.append(tokenImage[expectedTokenSequences[i][j]]);
		}
		expected.append(" ");
	}

	// Encountered token (s list):
	StringBuffer msg = new StringBuffer();
	msg.append("[l.").append(currentToken.next.beginLine).append(";c.").append(currentToken.next.beginColumn).append("] Encountered \"");
	Token tok = currentToken.next;
	for (int i = 0; i < maxSize; i++) {
		if (i != 0) msg.append(' ');
		if (tok.kind == 0) {
			msg.append(tokenImage[0]);
			break;
		}
		msg.append(add_escapes(tok.image));
		tok = tok.next;
	}
	msg.append("\".");

	// Append the expected tokens list:
	if (expectedTokenSequences.length == 1) {
		msg.append(" Was expecting: ");
	} else {
		msg.append(" Was expecting one of: ");
	}
	msg.append(expected);

	return msg.toString();
}
