Lecture 3

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:   The symbols correspond to characters all t2011 Fall 2011 2 b 1 Winter 2013 a 3 b a 4 19 UW CSE 401 (Michael Ringenburg) Finite State Automaton C input symbols (usually c CSE341: Programming Languagesharacters) •  Operate by reading SE341: Programming Languages –  Transi?on can be taken if labeled with current symbol Lecture 1 Lecture 1 –  ε- transi?on can be taken at any ?me Course Course Mechanics Mechanics •  Accept when final state reached and no more input ML Variable Bindings –  Slightly different in a scanner, where the FSA is used as a subrou?ne to ML Variable Bindings find the longest input string that matches a token RE. •  Reject if no transi?on possible, or no more input and not in Dan Grossman final state (DFA) Dan Grossman Fall 2011 Fall 2011 2 b 1 Winter 2013 a 3 b a UW CSE 401 (Michael Ringenburg) 4 20 8 1/11/13 Example: FSA for “pig” p Winter 2013 i g 21 UW CSE 401 (Michael Ringenburg) Example: FSA for “pig” Input 1: pig p i g Status: Execu?ng… Winter 2013 UW CSE 401 (Michael Ringenburg) 22 9 1/11/13 Example: FSA for “pig” Input 1: pig p i g Status: Execu?ng… Winter 2013 23 UW CSE 401 (Michael Ringenburg) Example: FSA for “pig” Input 1: pig p i g Status: Execu?ng… Winter 2013 UW CSE 401 (Michael Ringenburg) 24 10 1/11/13 Example: FSA for “pig” Input 1: pig p i g Status: Accept! (In a final state, and no more input.) Winter 2013 25 UW CSE 401 (Michael Ringenburg) Example: FSA for “pig” Input 2: pit p i g Status: Execu?ng… Winter 2013 UW CSE 401 (Michael Ringenburg) 26 11 1/11/13 Example: FSA for “pig” Input 1: pit p i g Status: Execu?ng… Winter 2013 27 UW CSE 401 (Michael Ringenburg) Example: FSA for “pig” Input 1: pit p i g Status: Execu?ng… Winter 2013 UW CSE 401 (Michael Ringenburg) 28 12 1/11/13 Example: FSA for “pig” Input 1: pit p i g Status: Reject! (No legal transi?ons on ‘t’.) Winter 2013 UW CSE 401 (Michael Ringenburg) 29 DFA vs NFA CSE341: Programming CSE341: Programming Languages Languages •  Determinis?c Finite Automata (DFA) –  No choice of which transi?on to take Lecture 1 Lecture 1 Course Course inite Automata (NFA) •  Non- determinis?c FMechanics Mechanics ML Variable ML Variable Bindings –  Choice of transi?on in at least one case Bindings –  ε transi?ons (arcs): If the current state has any outgoing ε arcs, Dan Grossman we can follow Dny of them without consuming any input a an Grossman Fall 2011 Fall 2011 –  Accept if...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online