project Abeona #2

2018-10-14  本文已影响0人  放假广告

Scanner:

  1. 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")

  1. Finite Automata:
    Formal mathematical objects for above recognizer.
    (S, \Sigma, \delta, s0, SA)
    S is the finite set of states in the recognizer, along with an error state se.
    \Sigma is the finite alphabet used by the recognizer, the union of the edge labels in the transition diagram.
    \delta(s, c) is the recognizer's transition function. It maps each state s\in S and each character c \in \Sigma into some next state.
    s_0\in S is the designate start state.
    S_A is the set of accepting states, S_A\subseteq S.

the FA for new or not or while \xrightarrow{a}

上一篇下一篇

猜你喜欢

热点阅读