The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
85 views

asked in Compiler Design by Junior (973 points)
edited by | 85 views
0
Is correct answer is b and d.
0

ACCORDING TO ACE ANSWER IS

0
Left factoring is removing the common left factor that appears in two productions of the same non-terminal. It is done to avoid back-tracing by the parser. Suppose the parser has a look-ahead ,consider this example-

A -> qB | qC
where A,B,C are non-terminals and q is a sentence. In this case, the parser will be confused as to which of the two productions to choose and it might have to back-trace. After left factoring, the grammar is converted to-

A -> qD

D -> B | C

This is what left factoring.

Then how can D be the answer?
0
Actually yes you r right. But is { S->A | B     A--> aaaac    B--> aaaab} left factored ??
0
yes this one is left factored!
0
But how can u say that there will be no backtracking in this. Say string is aaaab ; now from S we doesn't have any hint whether to go towards A or towards B. Now if we go through A then we will surely need to backtrack. Do you agree??
0
yes I agree
0
Then how is it left factored , because there is no determinism.
0
Actually this is my reasoning , i doesn't know the exact answer so please correct me if i am wrong...
0
Left factored version for { S->A | B     A--> aaaac    B--> aaaab} should be  {S->aaaaB  B->c|b }
0
why isn't A left factored?

1 Answer

+2 votes
Answer is D.

First (AB) ⋂ First(ef) = phi then it is left factored...
answered by Active (2.9k points)
0

@Aakash_ please tell correct answer for below question also :

https://gateoverflow.in/262707/compiler-design-doubt#c262791  

Related questions

0 votes
2 answers
3
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,587 questions
54,197 answers
187,535 comments
71,151 users