Compiler
closed

closed by
655 views
1 votes
1 votes
closed as a duplicate of: made easy test

Consider the following grammar

1)Left Recursive

2)Ambiguos

3)Left factored

4)None of these

closed by

4 Answers

2 votes
2 votes
Yes.. this grammar is left factored.

Because in production S--> AaAb| Bb does not have common prefix string.
0 votes
0 votes

4) None of these

This grammer can generate only two terminal strings ab and b. And obviously the grammer is not ambiguos or left recursive. And the grammer does not have a common prefix so not left factored.

Only non deterministic grammers with common prefix are left factored.

If a grammer is of the format.

A -> aB

B-> CaD | FaD

Here a is the common prefix.

0 votes
0 votes

There is a bit difference between left factoring and left factored..

By left factored we mean the left factoring is removed ..So in the given grammar we have no left factoring as we have no non determinism as one production begins with 'A' and other with 'B'..

Hence the grammar is left factored

0 votes
0 votes
Since, the first() of  all the productions of S is different, its left factored. If the first() of more than or equal to 2 productions had some common in them, then left factoring is necessary.

Had  A->a   and B->a were the productions, still you would need to do left factoring considering LL(1).

Related questions

0 votes
0 votes
1 answer
2
A_i_$_h asked Dec 23, 2017
605 views
$E→E−T ∣ T$$T→T/F ∣ F$$F→(E) ∣ id$(E is the start symbol)This grammar is unambiguous but shouldn't it be ambiguous because it has left recursion?
1 votes
1 votes
1 answer
3
learner_geek asked Aug 3, 2017
279 views
A Grammar which is only left recursive or right recursive can be ambiguous grammar???Or it should have both left recursive and right recursive to be ambiguous???
1 votes
1 votes
1 answer
4