The Gateway to Computer Science Excellence
0 votes

S -> (L) | a

L -> L . S | S

Question: Make necessary changes to make it suitable for LL(1) parsing and Construct FIRST and FOLLOW sets.

in Compiler Design by (5 points) | 2.5k views

2 Answers

+4 votes
The only problem I see is the Left recursion.

Therefore the new grammar would be

$S\rightarrow \left ( L \right )|a$

$L\rightarrow SL'$

$L'\rightarrow .SL' | \epsilon$


FT( S)={( ,a }

FT( L)={ ( ,a}

FT( L' )={ .,$\epsilon$}

FL( S)={ $,.,( ,a }

FL( L)={  )}

FL( L')={  ) }
by Active (2.3k points)
edited by
0 votes

Here every thing you need 

by Junior (737 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
50,737 questions
57,370 answers
105,274 users