private static void buildFilesForRecoveryTemplates(
	String indexFilename,
	String templatesFilename,
	char[] newTerminalIndex,
	char[] newNonTerminalIndex,
	String[] newName,
	char[] newLhs,
	String[] tokens) {

	int[] newReverse = computeReverseTable(newTerminalIndex, newNonTerminalIndex, newName);

	char[] newRecoveyTemplatesIndex = new char[newNonTerminalIndex.length];
	char[] newRecoveyTemplates = new char[newNonTerminalIndex.length];
	int newRecoveyTemplatesPtr = 0;

	for (int i = 0; i < tokens.length; i = i + 3) {
		if("3".equals(tokens[i])) { //$NON-NLS-1$
			int length = newRecoveyTemplates.length;
			if(length == newRecoveyTemplatesPtr + 1) {
				System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length);
			}
			newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0;

			int index = newLhs[Integer.parseInt(tokens[i + 1])];

			newRecoveyTemplatesIndex[index] = (char)newRecoveyTemplatesPtr;

			String token = tokens[i + 2].trim();
			java.util.StringTokenizer st = new java.util.StringTokenizer(new String(token), " ");  //$NON-NLS-1$
			String[] terminalNames = new String[st.countTokens()];
			int t = 0;
			while (st.hasMoreTokens()) {
				terminalNames[t++] = st.nextToken();
			}

			for (int j = 0; j < terminalNames.length; j++) {
				int symbol = getSymbol(terminalNames[j], newName, newReverse);
				if(symbol > -1) {
					length = newRecoveyTemplates.length;
					if(length == newRecoveyTemplatesPtr + 1) {
						System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length);
					}
					newRecoveyTemplates[newRecoveyTemplatesPtr++] = (char)symbol;
				}
			}
		}
	}
	newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0;
	System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[newRecoveyTemplatesPtr], 0, newRecoveyTemplatesPtr);

	buildFileForTable(indexFilename, newRecoveyTemplatesIndex);
	buildFileForTable(templatesFilename, newRecoveyTemplates);
}