The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+11 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 $

  1. Compute the FIRST and FOLLOW sets for $E$ and $A$.
  2. Complete the LL(1) parse table for the grammar.
asked in Compiler Design by Veteran (68.9k points)
edited by | 416 views

2 Answers

+16 votes
Best answer

First $(E) = \{ a,( \}$

First $(A) = \{ +,*, \epsilon \}$

Follow $(E) =$ Follow $(A) =$ $\{$ $\$$ $,) \}$

LL(1) Parsing Table :


  $a$ $($  $)$  $+$  $*$


$E$ $E \rightarrow aA$ $E \rightarrow (E)$        
$A$     $A \rightarrow \epsilon$ $A \rightarrow +E$ $A \rightarrow *E$  $A \rightarrow \epsilon$


answered by Loyal (3k points)
edited by
Hello @aditya i have just structured your parsing table
+1 vote
First(E) = a,(   and   First(A) = +,*,epsilon

Follow(E)= ),\$    and  Follow(A) = ),\$
answered by Boss (8.5k points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

32,694 questions
39,293 answers
36,701 users