Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Back to Predictive Parsing. On to Even More Predictive Parsing.
Held Friday, September 27, 2002
Summary
Today we continue our exploration of predictive parsing by looking at steps for automating the construction of predictive parsers..
Notes
Several contributors to the Slashdot commentary on this story are looking forward to the arrival of spam in the Cubicle of the Future, complete with Active X controls that crank up the volume before rendering those invitations to [spam topic of your choice].
Assignments
Overview
First table.
Nullable table.
Follow table.
b when matching
an S in
S :: = X b X ::= x X | epsilon
TokenSet first(SymbolList string) {
Symbol s1 = string.car();
if (isToken(s1)) {
return new TokenSet(s1);
}
else {
tmp = First[s1];
if (Nullable[s1]) {
return new Union(tmp,
first(string.cdr()));
} // if s1 is nullable
} // if s1 is a nonterminal
} // first
for each nonterminal N, First(N) = emptySet();
repeat
for each production N ::= RHS
First(N) = union(First(N), first(RHS))
end for
until no changes are made
boolean nullable(SymbolList string) {
// The empty string can derive the empty string
if (String.isEpsilon()) {
return true;
}
Symbol s1 = string.car()
// If we begin with a token, we're not nullable
if (isToken(s1)) {
return false;
}
// Otherwise, we begin with a nonterminal. That nonterminal must
// be nullable, as must the rest of the sequence.
else {
return Nullable[s1] &&
nullable(string.cdr());
}
} // nullable
foreach nonterminal N, Nullable(N) = false
repeat
for each production N := RHS
if nullable(RHS) {
Nullable[N] = true;
}
end for
until no changes are made
Thursday, 29 August 2002 [Samuel A> Rebelsky]
Friday, 27 September 2002 [Samuel A. Rebelsky]
Back to Predictive Parsing. On to Even More Predictive Parsing.
Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri Dec 6 10:38:08 2002.
The source to the document was last modified on Fri Sep 27 10:36:11 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/Outlines/outline.13.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby