[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazza]

[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]

[Current Assignment]
[Current Lab]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
Related Courses:
[CSC362 2004S (Rebelsky)]
[CSC362 2010S (Stone)]
Misc:
[SamR]
[GNU Coding Standards]
[Dragon Book]
[Pascal Standards]
Back to From Specification to Optimal DFA (1). On to Lex and Flex.
This outline is also available in PDF.
Held: Friday, 16 September 2011
Summary: Today we continue our consideration of how to move from the readable but declarative regular expression notation to the executable but sometimes obtuse finite automaton notation.
Related Pages:
Notes:
Overview:
Q0 = { q0 } // but there are some states we can reach from q0 at no cost Q0 = epsilonclosure(Q0) while there are states in the DFA we haven't processed pick one such state, Qn for each symbol s let tmp be a new, empty, set for each q in Qn add delta(q,s) to tmp end for tmp = epsilonclosure(tmp) if tmp is not in the DFA then let Qi be a new state Qi = tmp add Qi to the DFA else let Qi be the state equivalent to tmp end if add an edge from Qn to Qi in the automaton end for end while for each Qi if there is a q in Qi that is a final state then Qi is a final state end if end for
Assume all nonfinal 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 nonequivalent states, split q1 and q2 into different equivalencies figure out where the other states in the original 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
strings of a's and b's with equal numbers of a's and b's
Back to From Specification to Optimal DFA (1). On to Lex and Flex.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
[Piazza]

[Academic Honesty]
[Instructions]
Current:
[Current Outline]
[Current EBoard]

[Current Assignment]
[Current Lab]
Groupings:
[Assignments]
[Documents]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Readings]
Related Courses:
[CSC362 2004S (Rebelsky)]
[CSC362 2010S (Stone)]
Misc:
[SamR]
[GNU Coding Standards]
[Dragon Book]
[Pascal Standards]
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 Wed Dec 7 10:26:32 2011.
The source to the document was last modified on Fri Aug 26 13:03:12 2011.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2011F/Outlines/outline.10.html
.