project Abeona #2
2018-10-14 本文已影响0人
放假广告
Scanner:
- character-by-character formulation:
recognizing "new" pseudocode:
c <- NextChar();
if ( c = 'n')
then begin:
c <- NextChar();
if ( c = 'e' )
then begin:
c <- NextChar();
if ( c = 'w' )
then report success;
else try something else;
end;
else try something else;
end;
else try something else;
-> S0 -'n'-> S1 -'e'-> S2 -'w'-> S3 (to recognize "new")
-> S0 -'n'-> S1 -'e'-> S2 -'w'-> S3
\-'o'-> S4 -'t'-> S5 (to recognize "new" and "not")
- Finite Automata:
Formal mathematical objects for above recognizer.
(S, , , s0, SA)
S is the finite set of states in the recognizer, along with an error state se.
is the finite alphabet used by the recognizer, the union of the edge labels in the transition diagram.
is the recognizer's transition function. It maps each state and each character into some next state.
is the designate start state.
is the set of accepting states, .
the FA for new or not or while