1
$\begingroup$

If I have to check a Left Recursive grammer for LL(1) then should I check it after removing left recursion?

For example:- S-> (L)|a L->L.S|S

If I check after removing Left Recursion then the above grammer is LL(1). But if I do not remove left recursion then above grammer is not LL(1). which one is the right answer?

$\endgroup$
1
$\begingroup$

If the question is, "Is this grammar LL(1)?", then the answer is "No".

If the question is, "Can this grammar be made LL(1)", then by all means remove the left-recursion.

The distinction is important because removing left-recursion does not preserve derivation order, so the left-recursion-eliminated grammar produces different parse trees. If it is being used to parse, it is not the same grammar.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.