Professional Documents
Culture Documents
Assignment 1: Lexical Analysis (correction)
Solved by:
Ahmad Bijairimi
7802141171
ahab7847@student.uu.se
(20101123)
Lex structure:
Pattern Action
P1: (aba)+ (action 1);
P2: (a(b*)a) (action 2);
P3: (a|b) (action 3);
Recognizer:
(aba)+
(a(b*)a)
(a|b)
P1
P2
P3
Then P1, P2 and P3 are combined together to form a complete NFA diagram:
From the NFA above, DFA is constructed in order to have a faster recognizer. To convert NFA to DFA,
operations below will be used:
Start state: S0
ε-closure({0}) = {0,1,5,13,14,16} = S0
Final states in DFA = S1, S2, S3, S5, S9 where all these states contain the final states.
DFA diagram:
Transition table:
State Action
S0 0
S1 3
S2 3
S3 2
S4 0
S5 1
S6 0
S7 0
S8 0
S9 1
Analysis of the string abaabbaba
S3 = {12, 19} and S5 = {1,4,12,19} are both final states, so merge S3 to S5,
No more states that can be combined, so I assume that this is the minimal state of DFA.