Java Reference
In-Depth Information
procedure
S( )
switch
(
)
case
ts
.
peek()∈{a, b, q, c,$}
call
A( )
call
C( )
call
...
match
( $ )
end
procedure
C( )
switch
(
)
case
ts
.
peek()∈{c}
call
match
...
( c )
case
ts
.
peek()∈{d,$}
return
()
end
procedure
A( )
switch
(
)
case
ts
.
peek()∈{a}
call
...
match
( a )
call
B( )
call
C( )
call
( d )
case
ts
.
peek()∈{b, q, c,$}
call
B( )
call
Q( )
match
end
procedure
B( )
switch
(
)
case
ts
.
peek()∈{b}
call
...
match
( b )
call
B( )
case
ts
.
peek()∈{q, c, d,$}
return
()
end
procedure
Q( )
switch
(
)
case
ts
.
peek()∈{q}
call
...
( q )
case
ts
.
peek()∈{c,$}
return
()
match
end
Figure 5.7: Recursive-descent code for the grammar shown in
Figure 5.2. The variable
ts
denotes the token stream
produced by the scanner.