edited by
932 views
0 votes
0 votes
consider the following grammar

$E\rightarrow int|int+E|int-E |int-(E) |int*E$

Which statement is true?

a) Grammer is left factored

b) Cant be determined
edited by

5 Answers

1 votes
1 votes

Left Factoring is a grammar transformation technique. It consists in "factoring out" prefixes which are common to two or more productions.

For example, going from:

A -> α β | α γ

to:

A -> α A'

A' -> β | γ


1 votes
1 votes

What is nondeterminism in grammar?

Also called common suffix problem. There is non-determinism in grammar when in the same production there is more than one option to proceed further on reading a particular symbol.

For example, going from:

A → α β | α γ

The compiler will be confused whether to take use first production or 2nd one.So it tires both one after the other which may lead to backtracking.

What is left factoring? 

Left Factoring is a grammar transformation technique. It consists in "factoring out" prefixes which are common to two or more productions.

For example, going from:

A → α β | α γ

to:

A → α A'

A' → β | γ

Good Read: https://cs.stackexchange.com/questions/4862/left-factoring-a-grammar-into-ll1

Source: https://stackoverflow.com/questions/15194142/difference-between-left-factoring-and-left-recursion?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

0 votes
0 votes
At production

E -- > int + E | int - E | int * E | int - (E)

after seeing first "int" grammar might confuse what to choose next hence non determinism is there. That's why it is not left factored.
0 votes
0 votes
yes and so in this question you can make it left factoring as

E -> int-E'

E' -> E/(E)

So it is not in left factoring you can convert it.

Related questions

1 votes
1 votes
1 answer
1
4 votes
4 votes
1 answer
3
1 votes
1 votes
1 answer
4