32 32 votes Consider the following grammar with terminal alphabet $\Sigma =\{a,(,),+,* \}$ and start symbol $E$. The production rules of the grammar are: $ E \rightarrow aA$ $ E \rightarrow (E)$ $A \rightarrow +E$ $A \rightarrow *E$ $A \rightarrow \epsilon $ Compute the FIRST and FOLLOW sets for $E$ and $A$. Complete the LL(1) parse table for the grammar. Compiler Design gatecse-2001 compiler-design parsing normal descriptive + – Kathleen 7.5k views answer comment Share Follow Print See all 4 Comments 4 4 Comments reply sukesh_reddy commented Nov 22, 2022 reply Follow flag I came across a very tricky case while solving this question ie. Follow(E) contains Follow(A) because of the third production and at the same time Follow(A) contains the Follow(E) because of the first production .. how do we handle such a situation in follows of one anouther are depending .. 0 0 replyShare arpit.jha commented Aug 17, 2024 reply Follow flag @Shaik Masthan sir, How the follow is calculated here as Follow(E) depends upon Follow(F) and vice versa . 0 0 replyShare Shaik Masthan commented Aug 17, 2024 reply Follow flag @arpit.jha, In such situations, calculate follow(E) independently first as it is the start symbol.Then calculate follow(A) independently. Now as Follow(A) containts follow(E) add those to follow(A). Then add all together of Follow(A) to follow (E).In most of the cases, it is sufficient. Sometimes you need to do it one more time. Add all follow(E) to follow(A) then all together to follow (E). 2 2 replyShare arpit.jha commented Aug 17, 2024 reply Follow flag Good video to remove doubts about First and Follow : https://www.youtube.com/watch?v=oOCromcWnfc 0 0 replyShare Please log in or register to add a comment.
Best answer 51 51 votes First $(E) = \{ a,( \}$ First $(A) = \{ +,*, \epsilon \}$ Follow $(E) =$ Follow $(A) =$ $\{$ $\$$ $,) \}$ LL(1) Parsing Table: $$\begin{array}{|c|c|c|c|c|c|c|} \hline \textbf{} & \textbf{a} & \textbf{(} & \textbf{)} & \textbf{+} & \bf{*} & \textbf{\$} \\\hline \text{E} & \text{E} \rightarrow \text{aA} & \text{E} \rightarrow \text{(E)} & \text{} & \text{} & \text{} & \text{} \\\hline \text{A} & \text{}& \text{} & \text{A} \rightarrow \epsilon & \text{A} \rightarrow \text{+E} & \text{A} \rightarrow *\text{E} & \text{A} \rightarrow \epsilon \\\hline \end{array}$$ Aditya answered Aug 12, 2015 • edited Apr 17, 2019 by akash.dinkar12 Aditya comment Share Follow See all 2 Comments 2 2 Comments reply Rishi yadav commented Jan 9, 2018 reply Follow flag Hello @aditya i have just structured your parsing table 4 4 replyShare zgod commented Apr 5, 2025 reply Follow flag 🐐 1 1 replyShare Please log in or register to add a comment.
2 2 votes First(E) = a,( and First(A) = +,*,epsilon Follow(E)= ),\$ and Follow(A) = ),\$ jayendra answered Jan 2, 2015 jayendra comment Share Follow See all 2 Comments 2 2 Comments reply bharatmnair246 commented Dec 14, 2020 reply Follow flag how did $ come in follow of A, can somebody pls explain ?? 0 0 replyShare Jerry J. J. commented Jun 25, 2021 reply Follow flag because Follow of A will contain Follow of E, due to production E->aA And since Follow of E would contain $ (Since it is the start symbol) hence Follow of A will also contain $. 2 2 replyShare Please log in or register to add a comment.