CS536 Reading Notes: The Scanner

2014-09-10  本文已影响26人  Nahnuj

The Scanner

Overview

Finite State Machine

An input string is accepted by a FSM if

* The entire string is consumed, and
* The machine ends in a final state.

Formal Definition

An FSM is a 5-tuple: (Q,Σ,δ,q,F)

Regular Expressions

Pay attention to the precedence of operators.
"|" < "." < "*"

for example: letter(letter|digit)* is different with
letter.letter|digit*, which is (letter.letter)|(digit*).

Using Regular Expressions and FSMs to Define a Scanner

There is a theorem that says that for every regular expression, there is a finite-state machine that defines the same language, and vice versa.

上一篇下一篇

猜你喜欢

热点阅读