Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the algorithm described in Section 4.4.2, remove direct left recursion form the following grammar rules. A Aa Abc bcd For each nonterminal, A, 1.
Using the algorithm described in Section 4.4.2, remove direct left recursion form the following grammar rules. A Aa Abc bcd For each nonterminal, A, 1. Group the A-rules as A - Aa, ... Aam I Bil B2 | ... Bn where none of the B's begins with A 2. Replace the original A-rules with ABA' I BA' IBA' A'A' | Q A' | AmA' Note that e specifies the empty string. A rule that has e as its RHS is called an erasure rule, because its use in a derivation effectively erases its LHS from the sentential form. Consider the following example grammar and the application of the above process: E E + TIT TT*F|F F (E) | id For the E-rules, we have a + T and B = T, so we replace the E-rules with ETE E' + TETE For the T-rules, we have a = *F and B F, so we replace the T-rules with TFT T' *FT' | 8 Because there is no left recursion in the F-rules, they remain the same, so the complete replacement grammar is E TE E' + TE' T-FT T' *FT | 8 F (E) | id umar but is not
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started