The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+13 votes
472 views

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.4k points)
edited by | 472 views

2 Answers

+19 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 (2.9k points)
edited by
0
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.3k 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

34,770 questions
41,731 answers
118,876 comments
41,381 users