Explain left factoring with suitable example.
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-
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-
In this case, a parser with a look-ahead will always choose the right production.
Another Example:
If we remove the left lecturing, the result will be as follows:
Show that no left recursive grammar can be LL(1). Show that no LL(1) grammar can be ambiguous.
Write short notes on:
Short Notes :Lines of Code (LOC)
Write a C program to find factorial(using recursion) of any no.