Compiler
closed

closed by
1,600 views
1 1 vote
closed as a duplicate of: made easy test

Consider the following grammar

1)Left Recursive

2)Ambiguos

3)Left factored

4)None of these

4 Answers

0 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 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 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).
Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
1.4k
1.4k views
A_i_$_h asked Dec 23, 2017
1,435 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 1 vote
1 answers 1 answer
545
545 views
learner_geek asked Aug 3, 2017
545 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 1 vote
1 1 answer
1.3k
1.3k views