Similar questions 2 more →
Parsing & Syntax Analysis

Answer & solution
Official answer: C
1. Apply the standard direct-left-recursion transformation A→Aα|β becomes A→βA′, A′→αA′|ε. For E, α is −T and β is T, giving E→TX and X→−TX|ε.
2. Apply it separately to T: α is +F and β is F, giving T→FY and Y→+FY|ε. Keep F→(E)|id so arbitrarily nested factors remain possible. These are exactly option C.
3. A leaves both original recursions intact. B fixes E but leaves T→T+F directly left-recursive. D restricts T to id and cannot generate nested expressions such as ((id)) or parentheses as arbitrary factors. The transformation preserves the generated strings, although semantic associativity must be handled when constructing evaluation actions.