Held Friday, September 13, 2002
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.
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
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