# Closure in LR(1) sets

1 vote
289 views
Find the closure of S $\rightarrow$ .A ,dollar for the grammar

S --> A

A --> AB | $\varepsilon$

B --> aB | b

// I'm getting
S --> .A , dollar

A --> .AB, dollar

A --> . $\varepsilon$ , a,b

edited
1

S--->.A, $A--->.AB,$

/.ϵ, $A--->.AB, a/b /.ϵ, a/b 0 So you're saying that in A--->.AB, lookaheads will be {$, a, b} ?

0
yes..
0
can you elaborate in detail please ? @joshi_nitish
3

S--->.A, $A--->.AB,$

/.ϵ, $upto above you might be clear...now, in A--->.AB, \$  dot(.) is before A you have to write productions of 'A' and his time new lookaheads will be first(B$) i.e a,b... ## Please log in or register to answer this question. ## Related questions 1 vote 0 answers 1 172 views Consider the following grammar:$S \rightarrow AS \rightarrow xbA \rightarrow aAbA \rightarrow BB \rightarrow x$The average length of the stack used while parsing the string "axb$" using LR(1) parser is _________. I am getting 5, but answer is 2.5.
2 votes
0 answers
2
716 views
Consider the following grammer:- Stmts -> Stmt | Stmts;Stmt Stmt -> Var =E Var ->id[E] | id E-> id | (E) Find the number of conflicts in LR(0)?
0 votes
1 answer
3
217 views
Can lookahead symbol be epsilon in LR(1) parsing? and pls give the LR(1) diagram for the following grammar? A->AB | a B->*AC | Cb | ∈ C->+ABc | ∈
1 vote
1 answer
4
359 views
According to my understanding, we LALR is constructed by reducing LR(1) automaton states. So I think it should be LR(1) However, we construct SLR(1) items from the LR(0) automaton, and we say with surety that number of states in SLR(...) is equal to number of states in LALR(...), how can this be?