Download presentation
Presentation is loading. Please wait.
1
Regular Expression to NFA
Module 05.1 COP4020 – Programming Language Concepts Dr. Manuel E. Bermudez
2
RE to NFA So far, RGR RGL Minimum DFA RE NFA DFA Done Soon Now
3
RE to NFA Algorithm 1 (bottom-up): Recursively build the FSA,
Mimicking structure of the RE. Each FSA built has one start state, and one final state. Conversions: if ø, if ℇ, and if a. 2 1 1 1 2 a
4
RE to NFA if P + Q, or if PQ, and if P*. 1 ε Q P 2 P Q ε 1 2 1 P ε 2
5
RE to NFA example: (b (aba + ε) a)* b a b a a 3 7 a b ε 1 2 3 4 5 6 7
8 a 9 10 11 a 3 4 5 6 7 8 a b ε
6
RE to NFA (b (aba + ε) a)* 3 7 a b ε 3 7 a b ε 9 12 3 7 a b ε 9 12 4 5
6 7 8 a b ε 3 4 5 6 7 8 a b ε 13 9 12 3 4 5 6 7 8 a b ε 13 9 12 2 1
7
3 4 5 6 7 8 a b ε 13 9 12 2 1 RE to NFA (b (aba + ε) a)* 3 4 5 6 7 8 a b ε 13 9 12 2 1 10 11 2 12 3 4 6 7 ε a 8 13 14 1 b 10 5 9 11 15
8
Algorithm 2 (top-down): 4 Rules Start: Apply Rules:
RE to NFA Algorithm 2 (top-down): 4 Rules Start: Apply Rules: E a a* ε ab a b b a + b a
9
RE to NFA Example (a + b)* (aa + bb) (a + b)* aa + bb aa a + b ε bb ε
10
RE to NFA (another Example)
ba(a + b)* ab b a ε
11
summary Algorithm 1: Builds FSA bottom up Good for machines
Bad for humans Algorithm 2: Builds FSA top down Bad for machines Good for humans
12
RE to NFA So far, RGR RGL Minimum DFA RE NFA DFA Two algorithms Done
Soon Two algorithms
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.