Java Reference
In-Depth Information
6. Which of following grammars are LR(0)? Explain why.
1 S
→
StmtList $
2 StmtList
→
StmtList semi Stmt
(a)
3
|
Stmt
4 Stmt
→
s
1 S
→
StmtList $
2 StmtList
→
Stmt semi StmtList
(b)
3
|
Stmt
4 Stmt
→
s
1 S
→
StmtList $
2 StmtList
→
StmtList semi StmtList
(c)
3
|
Stmt
4 Stmt
→
s
1 S
→
StmtList $
(d)
2 StmtList
→
sStTa l
3 StTail
→
semi StTail
4
| λ
7. Show that the CFSMcorresponding to a LL(1) grammar has the following
property. Each state has exactly one kernel item if the grammar is
λ
-free.
8. Prove or disprove that all
λ
-free LL(1) grammars are LR(0).
9. Explain why the following grammar is unambiguous:
1 Start
→
Single a
2
|
Double b
3 Single
→
0 Single 1
4
|
01
5 Double
→
0 Double 1 1
6
|
011