Compilation Principle 9 DFA minimization, parsing preliminary

1. DFA minimization: Textbook P65 Question 9

 

I

{1,2,3,4,5}

{6,7}

 

 

{1,2}b->{2}

{3,4}b->{6,7}

{1,2} a -> {3,4} indistinguishable

{3,4} c -> {3} indistinguishable

 

II

{1,2}{3,4}{5}

{6,7}

 

 

 

 

2. The minimum configuration of the DFA corresponding grammar

S→ 0A|1B

A→ 1S|1

B→0S|0

 

answer:

S → 0 (1 S + 1) | 1 (0S | 0)

S→01S+01|10S+10

S→(01+10)S|(01+10)

S→(01|10)*(01|10)

 

 DFA:

 

 

0

1

 0

e {S} = {AD}

{BE}

{CF}

 1

{BE}

 

{ADG}

 2

{CF}

{ADG}

 

 3

{ADG}

{BE}

{CF}

I

{0,1,2}

{3}

 

{0}->{1,2}

{1}1->{3}

{2}0->{3}

 

II

{0}{1}{2}

{3}

Simplification DFA:

 

 

 

3. Given the following grammar  G [ S ]:

AB

→ aA | ɛ 

→ b | bB

Given sentences aaab  of a top-down parsing process, and explain the reasons for backtracking produce what is?

 answer:

AB

→aAB

→aaAB

aaaɛB

aaabɛ

aaab

The reason backtracking produced: Left repeatedly extracted Public factor

 

4.P100 练习4,反复提取公共左因子,对文法进行改写。

答:

S -> C$

C -> bA | aB

A -> aC' | bAA

B -> bC' | aBB

C' -> C | ɛ

Guess you like

Origin www.cnblogs.com/longlog/p/11822086.html