Java Reference
In-Depth Information
rst(
+
) = f
+
g
rst(
*
) = f
*
g
rst(
(
) = f
(
g
rst(
)
) = f
)
g
rst(
id
) = f
id
g
Step 2 of Algorithm 3.2 gives
rst(E) = fg
rst(E
0
) = fg
rst(T) = fg
rst(T
0
) = fg
rst(F)
= fg
Step 3 of Algorithm 3.2 yields
rst(E
0
) = fg
rst(T
0
) = fg
Step 4 of Algorithm 3.2 is repeatedly executed until no further symbols are added. The
first round yields
rst(E) = fg
rst(E
0
) = f
+
, g
rst(T) = fg
rst(T
0
) = f
*
, g
rst(F)
= f
(
,
id
g
The second round of step 4 yields
rst(E) = fg
rst(E
0
) = f
+
, g
first(T = f
(
,
id
g
rst(T
0
) = f
*
, g
rst(F)
= f
(
,
id
g
The third round of step 4 yields
(3.23)first(E) = f
(
,
id
g
rst(E
0
) = f
+
, g
first(T = f
(
,
id
g
rst(T
0
) = f
*
, g
rst(F)
(3.23)
= f
(
,
id
g
The fourth round of step 4 adds no symbols to any set, leaving us with (3.23).
We are left with the question as to when is a rule, X ::= applicable? For this we need
the notion of follow.
We dene follow(X) = fajS ) wX and ) a:::g, that is, all terminal symbols that
start terminal strings derivable from what can follow X in a derivation. Another definition
is as follows.
Search WWH ::
Custom Search