[Instructions] [Search] [Current] [News] [Syllabus] [Handouts] [Outlines] [Assignments]
Held Wednesday, September 23, 1998
Notes
Follow table is a little
bit more subtle.
Follow
table? We know that M can be followed by anything that can begin
a string derivable from beta.
for each nonterminal, N
Follow(N) = {};
for each production P
for each form of P, N ::= alpha M beta
Follow(M) = Follow(M) union first(beta)
end for
end for
repeat
for each production P
for each form of P, N :: = alpha M beta
if nullable(beta)
Follow(M) = Follow(M) union Follow(N)
end if
end for
end for
until no changes are made
end for
for each nonterminal N, build the method parseN as follows
for each production, N ::= Stuff
for each symbol in first(Stuff)
add a case for that symbol, using the steps to parse Stuff
end for
if nullable(Stuff) then
for each symbol in Follow(N)
add a case for that symbol, using the steps to parse Stuff
-- Note that we still parse Stuff, even thoush we
-- ``know'' it nullifies
end for
end if
end for each production
end for each nonterminal
Back to Predictive parsing. On to Shift-reduce parsing.
History
[Instructions] [Search] [Current] [News] [Syllabus] [Handouts] [Outlines] [Assignments]
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Mon Sep 28 11:22:10 1998.
This page generated on Mon Sep 28 11:31:38 1998 by SiteWeaver.
Contact our webmaster at rebelsky@math.grin.edu