Program to Calculate leading for all the mon terminals of the given grammer
ALGORITHM1. Start2. For each nonterminal A and terminal a do L(A,a):= false;3. For each production of the form A->a or A->B do INSTALL(A,a);4. While STACK not empty repeat step 5& 65.…