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]
Held Friday, September 13, 2002
Summary
Today we continue our consideration of how to move from the readable but declarative regular exprssion notation to the executable but obtuse finite automaton notation.
Notes
Overview
Assume all non-final states can be treated as the same state
Assume all final states can be treated as the same state
For each group of states treated as equivalent
as the same state
For each symbol, s
If there are two "equivalent" states q1,q2 such that
edge(q1,s) and edge(q2,s) lead to non-equivalent states,
split q1 and q2 into different equivalencies
figure out where the other states in the equivalency go
End For // each symbol
End for // each pair of states
/**
* Find the first token in the candidate string, starting
* at a particular position.
*/
public token findToken(String candidate, starting_pos)
begin
State current_state = q0;
for i = starting_pos to the length of candidate
current_state = edge(current_state,candidate.symbolAt(i))
if current_state is a final state
final_found = current_state
final_pos = i
end if
if current_state is undefined then
exit the for loop
end if
end for
if (final_found is defined) then
return the token given by final_found at position final_pos
else
no token can be found
end if
end
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:37:58 2002.
The source to the document was last modified on Wed Sep 4 10:08:34 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/Outlines/outline.07.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby