Download presentation
Presentation is loading. Please wait.
Published byAron Andrews Modified over 8 years ago
1
Animated Conversion of Regular Expressions to C Code On the regular expression: ((a ⋅ b)|c) *
2
THOMPSON’S CONSTRUCTION Convert the regular expression to an NFA.
3
Step 1: construct a parse tree for the expression ((a ⋅ b)|c) * giving each nested expression a unique name. r6r6 r5r5 * r3r3 r4r4 r1r1 r2r2 ab c | ⋅
4
Step 2: construct NFA for r 1. r6r6 r5r5 * r3r3 r4r4 r1r1 r2r2 ab c | ⋅ 1 2 a
5
Step 3: construct NFA for r 2. r6r6 r5r5 * r3r3 r4r4 r1r1 r2r2 ab c | ⋅ 3 4 b 1 2 a
6
Step 4: construct NFA for r 3. r6r6 r5r5 * r3r3 r4r4 r1r1 r2r2 ab c | ⋅ 2 4 b 1 a
7
Step 5: construct NFA for r 4. r6r6 r5r5 * r3r3 r4r4 r1r1 r2r2 ab c | ⋅ 2 4 b 1 a 5 6 c
8
Step 6: construct NFA for r 5. r6r6 r5r5 * r3r3 r4r4 r1r1 r2r2 ab c | ⋅ 24 b 1 a 56 c 7 8
9
Step 7: construct NFA for r 6. 24 b 1 a 56 c 7 8 9 10
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.