Java Reference
In-Depth Information
9. Compute First and Follow sets for the nonterminals of the following
grammar.
1 S
aSe
2
|
B
3 B
bBe
4
|
C
5 C
cCe
6
|
d
10. Compute First and Follow sets for each nonterminal in ac grammar from
Chapter 2, reprised as follows.
1 Prog
Dcls Stmts $
2 Dcls
Dcl Dcls
3
| λ
4 Dcl
floatdcl
id
5
|
intdcl
id
6 Stmts
Stmt Stmts
7
| λ
8 Stmt
id assign Val ExprTail
9
|
print
id
10 ExprTail
plus Val ExprTail
11
|
minus Val ExprTail
12
| λ
13 Val
id
14
|
num
11. Compute First and Follow sets for each nonterminal in Exercise 3.
12. As discussed in Section 4.3, the algorithm in Figure 4.4 could use left
or right recursion to transform a repeated sequence of symbols into
standard grammar form. A production of the form A
A
α
is said to
be left recursive . Similarly, a production of the form A
A is said
to be right recursive . Show that any grammar that contains left- and
right-recursive rules for the same LHS nonterminal must be ambiguous.
→β
 
Search WWH ::




Custom Search