Two Issues in Lexical Analysis
Two Issues in Lexical Analysis
0 1 2 3
a b b
b
An NFA can easily implemented using a transition
table.
State a b
0 {0, 1} {0}
1 - {2}
2 - {3}
The algorithm that recognizes the language
accepted by NFA.
Input: an NFA (transition table) and a string x (terminated by eof).
output yes if accepted, no otherwise.
S = e-closure({s0});
a = nextchar;
while a != eof do begin
S = e-closure(move(S, a));
a := next char;
end
if (intersect (S, F) != empty) then return yes
else return no
Note: e-closure({S}) are the state that can be reached from states in S
through transitions labeled by the empty string.
Example: recognizing ababb from previous NFA
Example2: Use the example in Fig. 3.27 for recognizing ababb
Question:
for a NFA with |S| states, at most how many states can its
corresponding DFA have?