Java Reference
In-Depth Information
1. Build the CFSMand the parse table for the grammar shown in Figure 6.2.
2. Using the knitting analogy of Section 6.2.2, show the sequence of LR
shift and reduce actions for the grammar of Figure 6.2 on the following
strings:
(a) plus plus num num num $
(b) plus num plus num num $
3. Figures 6.6 and 6.7 trace a bottom-up parse of an input string using the
table shown in Figure 6.5. Trace the parse of the following strings.
(a) q$
(b) c$
(c) adc$
4. Build the CFSM for the following grammar:
1 Prog
→
Block $
2 Block
→
begin StmtList end
3 StmtList
→
StmtList semi Stmt
4
|
Stmt
5 Stmt
→
Block
6
|
Var assign Expr
7 Var
→
id
8
|
id lb Expr rb
9 Expr
→
Expr plus T
10
|
T
11 T
→
Var
12
|
lp Expr rp
5. Show the LR parse table for the CFSM constructed in Exercise 4.