The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
130 views

asked in Compiler Design by Junior (523 points) | 130 views
0
I am getting 6 but ans given is 2

2 Answers

0 votes
  a b $
S S-->aAbB S-->bAaB S--e
A

A-->S

A--->e

A--->S

A--->e

 
B B-->S B-->S B---e
answered by Loyal (7.6k points)
0
I think S->epsilon will be under column a and b , since S-->epsilon needs to be put under follow(S) which is {a,b}
0 votes

 $S \rightarrow aAbB \ \ \ \ \ \ \ ..... 1   $ 
$S \rightarrow bAaB \ \ \ \ \ \ \ ..... 2   $
$S \rightarrow \epsilon \ \ \ \ \ \  \ \  \ \ \ \ \ \ \ \ ..... 3   $ 
$A \rightarrow S \ \ \ \ \ \  \ \  \ \ \ \ \ \ \  ..... 4   $
$B \rightarrow S \ \ \ \ \ \  \ \  \ \ \ \ \ \ \  ..... 5   $

 

FIRST FOLLOW  NON-TERMINAL a b $
$\{ a, b, \epsilon  \}$ $\{ \$,b,a \}$ S  1 / 3 2 / 3 3
$\{ a, b, \epsilon  \}$ $\{b,a \}$ A 4 / 4 4 / 4  
$\{ a, b, \epsilon  \}$ $\{ \$,b,a \}$ B 5 / 5 5 / 5

 

$$\begin{array}{|l|l|l|l|l|}\hline \textbf{FIRST}&\textbf{FOLLOW}&\textbf{NON-TERMINAL}&\textbf{a}&\textbf{b}&\textbf{\$}\\\hline \{a,b,\epsilon\}&\{\$,b,a\}&\text{S}&1/3&2/3&3\\\hline \{a,b,\epsilon\}&\{b,a\}&\text{A}&4/4&4/4&\\\hline \{a,b,\epsilon\}&\{\$,b,a\}&\text{B}&5/5&5/5&5\\\hline\end{array}$$

There are 2 entries with multiple different productions which results in First/First conflict.

however there are 6 multiple entries in the table.

answered by Boss (34.6k points)
edited by

Related questions

0 votes
2 answers
1
asked Dec 5, 2017 in Compiler Design by pa-try (155 points) | 107 views
0 votes
0 answers
3
0 votes
1 answer
7
asked Dec 5, 2017 in Compiler Design by Parshu gate Active (3.1k points) | 356 views
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
49,814 questions
54,521 answers
188,387 comments
75,421 users