Correct syntax errors created by mechanical substitution