国际空间研究组织 | ISRO CS 2013 |问题 6
下列哪个产生式消除了左递归
下面给出的产品:
S → Aa | b
A → 交流 |标清| ε
(A) S → Aa | b
A → bdA'
A' → A'c |阿坝 |一个 | ε
(B) S → Aa | b
A → A' | bdA',
A' → cA' | adA' | ε
(C) S → Aa | b
A → A'c |广告
A' → bdA' |钙| ε
(D) S → Aa | b
A → cA' | adA' | bdA'
A' → A | ε答案:(乙)
解释:
To remove left recursion from the grammar of the
form : A → Aα | β
We rewrite the production rules as:
A → βA'
A'→ αA'| ε
Given Grammar: S → Aa | b
A → Ac | Sd | ε
after finding indirect left recursion, grammar:
S → Aa | b
A → Ac | Aad | bd | ε
here, α = c, ad, β = bd
So, Grammar after removing left recursion =
S → Aa | b
A → A' | bdA'
A'→ CA'| ada'| ε
所以,选项(B)是正确的。
这个问题的测验