Every me the r machine nd a potenal match it non

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: e iFall 2011 s a well- defined procedure for conver?ng an NFA to an equivalent DFA Winter 2013 UW CSE 401 (Michael Ringenburg) 44 20 1/11/13 From RE to NFA: base cases CSE341: Programming CSE341: Programming Languages Languages These correspond to the “Fundamental REs” shown Lecture 1 Lecture 1 earlier. Course Course Mechanics Mechanics a ML Variable Bindings NFA fMsymbol ‘a’ or L Variable Bindings Dan Grossman NFA for empty string (ε) Fall 2011 Dan Grossman Fall 2011 ε NFA for empty set (∅) Winter 2013 45 UW CSE 401 (Michael Ringenburg) Concatena?on: r s An ε- ransi?on from CSE341: tProgramming Languages This rCSE341:FA that epresent an N Programmingnal state of the r every fi accepts the regular machine Lecture f Lecture 1 to start state o1 expression r the s machine. Languages An NFA for RE s Course Course Mechanics Mechanics ML Variable Bindings ML Variable Bindings r Dan Grossman Fall 2011 s ε an Grossman D ε Fall 2011 The idea: When we find a string that matches the regular expression r, we start trying to match the regular expression s. Since this is an NFA, it’s okay if we guess wrong – we will make an ε transi?on from every prefix of the input that matches r, and thus check all possible matches. Winter 2013 UW CSE 401 (Michael Ringenburg) 46 21 1/11/13 Union/Combina?on: r | s CSE341: rProgramming CSE341: Programming Languages Languages Lecture 1 Lecture 1 ε Course Course Mechanics Mechanics ML Variable Bindings ML Variable Bindings ε εDan Grossman Dan Grossman ε s Fall 2011 Fall 2011 The idea: Non- determinis?cally check if the input matches either r or s. If either sub- machine reaches a final state, jump to the union machine’s final state. If the en?re input has been consumed at this point (i.e., the en?re string matches r or s), the union machine will accept. Winter 2013 UW CSE 401 (Michael Ringenburg) 47 Kleene star: r * CSE341: Programming CSE341: Programming Languages Languages r Lecture 1 Lecture 1 Course Course Mechanics Mechanics ML Variable Bindings ML Variable Bindings ε ε Dan Grossman N1 Fall 2011 Dan Grossman Fallε 2011 The idea: At the start node (N1), we apempt to match either the empty string (to account for the possibility of zero occurrence of r) or a single match of r. Every ?me the r machine find a poten?al match, it non- determinis?cally jumps back to N1 and repeats the process. Since this is an NFA, it’s okay if we guess the wrong match of r – we’ll try all of them. Winter 2013 UW CSE 401 (Michael Ringenburg) 48 22 1/11/13 Example CSE341: Programming CSE341: Programming Languages Languages •  Draw the NFA for (ab|c): Lecture 1 Lecture 1 Course Course Mechanics Mechanics ML Variable Bindings ML Variable Bindings Dan Grossman Fall 2011 Winter 2013 Dan Grossman Fall 2011 UW CSE 401 (Michael Ringenburg) 49 Example CSE341: Programming CSE341: Programming Languages Languages •...
View Full Document

Ask a homework question - tutors are online