The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+14 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 (59.9k points)
edited by | 675 views

2 Answers

+22 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 Active (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 Loyal (8.1k points)

Related questions

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
47,903 questions
52,285 answers
67,713 users