English 中文(简体)
Compiler Design - Finite Automata
  • 时间:2024-11-03

Compiler Design - Finite Automata


Previous Page Next Page  

Finite automata is a state machine that takes a string of symbols as input and changes its state accordingly. Finite automata is a recognizer for regular expressions. When a regular expression string is fed into finite automata, it changes its state for each pteral. If the input string is successfully processed and the automata reaches its final state, it is accepted, i.e., the string just fed was said to be a vapd token of the language in hand.

The mathematical model of finite automata consists of:

    Finite set of states (Q)

    Finite set of input symbols (Σ)

    One Start state (q0)

    Set of final states (qf)

    Transition function (δ)

The transition function (δ) maps the finite set of state (Q) to a finite set of input symbols (Σ), Q × Σ ➔ Q

Finite Automata Construction

Let L(r) be a regular language recognized by some finite automata (FA).

    States : States of FA are represented by circles. State names are written inside circles.

    Start state : The state from where the automata starts, is known as the start state. Start state has an arrow pointed towards it.

    Intermediate states : All intermediate states have at least two arrows; one pointing to and another pointing out from them.

    Final state : If the input string is successfully parsed, the automata is expected to be in this state. Final state is represented by double circles. It may have any odd number of arrows pointing to it and even number of arrows pointing out from it. The number of odd arrows are one greater than even, i.e. odd = even+1.

    Transition : The transition from one state to another state happens when a desired symbol in the input is found. Upon transition, automata can either move to the next state or stay in the same state. Movement from one state to another is shown as a directed arrow, where the arrows points to the destination state. If automata stays on the same state, an arrow pointing from a state to itself is drawn.

Example : We assume FA accepts any three digit binary value ending in digit 1. FA = {Q(q0, qf), Σ(0,1), q0, qf, δ}

Finite automata construction Advertisements