Ch5 - Chapter 5 Finite Automata 2 5.1 Finite State Automata...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: Chapter 5 Finite Automata 2 5.1 Finite State Automata Capable of recognizing numerous symbol patterns, the class of regular languages Suitable for pattern-recognition type applications, such as the lexical analyzer of a compiler An abstract (computing) machine M , which is implementation independent , can be used to determine the acceptability (the outputs) of input strings (which make up the language of M ) 3 Lexical Analyzer Recognizes occurrences of (valid/acceptable) strings concisely Use a (state ) transition diagram for producing lexical analysis routines, e.g., Figure 1 (next page) Use a transition table whose entries provide a summary of a corresponding transition diagram, which consists of rows (representing states ), columns (representing symbols) and EOS (End_of_string) Entries of a transition table contain the values accept, error, next states. e.g., Figure 3 Can be encode in a program segment , e.g., Figure 2 4 Transition Diagram and Table 3 1 2 letter digit letter digit letter digit EOS 1 3 2 error 2 error error error 3 3 3 accept Figure 2. A transition table constructed from the transition diagram of Figure 1 Figure 1. A transition diagram representing the syntax of a variable name 5 Instruction Sequence State := 1; Read the next symbol from input; While not end-of-string do Case State of 1: If the current symbol is a letter then State := 3, else if the current symbol is a digit then State := 2, else exit to error routine; 2: Exit to error routine; 3: If the current symbol is a letter then State := 3, else if the current symbol is a digit then State := 3, else exit to error routine; Read the next symbol from the input; End while; If State not 3 then exit to error routine; Figure 3. An instruction sequence suggested by the transition diagram of Figure 1 letter digit EOS 1 3 2 error 2 error error error 3 3 3 accept 6 5.2 Deterministic Finite Automaton DFA (D eterministic F inite A utomaton) is a quintuple M = ( Q , , , q , F ), where 1) Q is a finite set of states 2 29 is a finite set of (machine) alphabet 3 29 is a transitive function from Q x to Q , i.e., : Q x Q 4) q Q, is the start state 5) F Q , is the set of final (accepting) states letter digit EOS 1 3 2 error 2 error error error 3 3 3 accept Figure 4. A transition table constructed from the transition diagram of Figure 1 7 Transition Diagram digit 4 1 2 3 5 6 7 digit digit digit digit digit digit E E +- Figure 5. A transition diagram representing the syntax of a real number 8 Transition Table digit E + - EOS 1 2 error error error error error 2 2 3 5 error error error 3 4 error error error error error 4 4 error 5 error error error 5 7 error error 6 6 error 6 7 error error error error error 7 7 error error error error accept Table 1. A transition table constructed from the transition diagram of the previous figure 9 Deterministic Finite Automaton state indicator 1 4 5 6 2 3 tape head head moves in this direction...
View Full Document

Page1 / 29

Ch5 - Chapter 5 Finite Automata 2 5.1 Finite State Automata...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online