retagged by
4,270 views
2 votes
2 votes

A grammar $G$ is $LL(1)$ if and only if the following conditions hold for two distinct productions $A \rightarrow \alpha \mid \beta$

I. First $(\alpha) \cap$ First $(\beta) \neq \left\{a\right\}$ where $a$ is some terminal symbol of the grammar.

II. First $(\alpha) \cap$ First $(\beta) \neq \lambda$

III. First $(\alpha) \cap$ Follow $(A) = \phi$ if $\lambda \in$ First $(\beta)$

  1. I and II 
  2. I and III 
  3. II and III
  4. I, II and III 
retagged by

2 Answers

Best answer
4 votes
4 votes
assume

S---> aX |aYb

first(aX)= a

first(aYb)= a

so there will 2 entries for  S in terminal 'a' which violates the rule of LL(1) grammar Bcoz for every variable and for every terminal there can be at most 1 production .

hence ,their intersection should be ∅

first one statement is correct

second one is true with similar reasoning as for first.

now third assume example

1) S-->aSA | ∈

2) A--> C |∈

now take 2) production

first(c)  = c

follow(A) = follow(S) = => first(A)= c,∈,$

now the first(c)∩  follow(A)= c

means there will be again 2 entries  for A in c place that means again violation of LL(1) rules.

so first(c)∩  follow(A)=  ∅  is true.

hence answer is (D)
edited by
0 votes
0 votes

For a grammar to be LL(1) each production must be unique. The following conditions must hold:-

  • $First(\alpha )\cap First(\beta )=\phi$

Hence I and II are True.

  • If either $\alpha$ or $\beta$ (not both) derive $\epsilon$, then $First(<remaining> )\cap Follow(A )=\phi$

Hence III is True.

Option D

https://www.csd.uwo.ca/~moreno/CS447/Lectures/Syntax.html/node14.html


PS: $\phi$ is the empty set

$\lambda$ or $\epsilon$ is the empty string

edited by
Answer:

Related questions

1 votes
1 votes
3 answers
1
makhdoom ghaya asked Jun 8, 2016
4,691 views
A shift reduce parser suffers from Shift reduce conflict only Reduce reduce conflict only Both shift reduce conflict and reduce reduce conflict Shift handle and reduce ha...
2 votes
2 votes
1 answer
2
makhdoom ghaya asked Jun 8, 2016
1,315 views
Which of the following suffices to convert an arbitrary $CFG$ to an $LL(1)$ grammar ? Removing left recursion aloneRemoving the grammar alone Removing left recursion and ...
0 votes
0 votes
2 answers
3
makhdoom ghaya asked Jul 1, 2016
3,394 views
Match the following $:$$\begin{array} {cIcI} & \textbf{List – I} && \textbf{List – II} \\ \text{a.} & \text{DDL} & \text{i.} & \text{LOCK TABLE} \\ \text{b.} & \tex...
2 votes
2 votes
3 answers
4
makhdoom ghaya asked Jul 1, 2016
20,033 views
Let $R =\{A, B, C, D, E, F\}$ be a relation schema with the following dependencies $C \rightarrow F$, $E \rightarrow A$, $EC \rightarrow D$, $A \rightarrow B$. Which of t...