Java Reference
In-Depth Information
procedure LL
parser
( ts )
call
(S)
accepted
push
false
while not accepted do
5
if TOS( )
∈Σ
6
then
call
match
( ts ,
TOS( ) )
7
if TOS( )
=
$
8
then
accepted
true
call
pop
()
9
else
, ts . peek()]
p LLtable [TOS( )
10
if p =
0
then
call
error
( Syntax error—no production applicable )
else call
apply
( p )
end
procedure
apply
( p : A
→X
...X m )
1
call
pop
()
11
for i = m downto 1 do
call
12
push
(
X i )
end
Figure 5.8: Generic LL(1) parser.
procedure F
ill
T
able
( LLtable )
foreach A
N do
foreach a
∈Σ
do LLtable [A][a]
0
foreach A
N do
foreach p ProductionsFor (A) do
foreach a
Predict( p ) do LLtable [A][a]
p
end
Figure 5.9: Construction of an LL(1) parse table.
 
Search WWH ::




Custom Search