9.12 second job

1. understood that symbol string and set operations.

 

L={A,B, ,Z,a,b, ,z}

 

D={0,1, ,9}

 

Description meaning under represented:

 

LUD: a collection of all the numbers and letters

 

LD: the set of all symbols consisting of a letter followed by a number composed of

 

L4: 4 by a set of letters

 

L *: all the alphabet symbol string set

 

D +: the set of all strings of symbols by one or several digits

 

L (LUD) *: the set of all strings of symbols with the letter, followed by letters, digits

 

 

 

2. grammar G (Z): Z-> aZb | ab definition of what kind of language?

Because: z-> aZb | ab

 

所以:Z->aZb->aaZbb->aaaZbbb->an bn

 

3. Write materials 22 is this page embodiment 2.2 grammar in the form of four-tuple identifier (the VN, NT, P, S) .

 

I->I | IL |ID

 

L->a|b|c|...|x|y|z

 

D->0|1|...|8|9

 

 

 

4. Write the following expressions leftmost derivation, rightmost derivation.

 

G (E):

 

E=> E + T | T

 

T=>T * F | F

 

F=>E| i

 

i*i+i

i+i*i

i+(i+i)

 Observe different leftmost and rightmost derivation process.

Most right:

 

[i*i+i] E=>E+T=>E+F=>E+i=>T+i=>T*F+i=>T*i+i=>F*i+i=>i*i+i

 

[i+i*i] E=>E+T=>E+T*F=>E+T*i=>E+F*i=>E+i*i=>T+i*i=>F+i*i=>i+i*i

 

[i+(i+i)] E=>E+T=>E+F=>E+(E)=>E+(E+T)=>E+(E+F)=>E+(E+i)=>E+(T+i)=>E+(F+i)=>E+(i+i)=>T+(i+i)=>F+(i+i)=>i+(i+i)

leftmost:

 

[i*i+i] E=>E+T=>T+T=>T*F+T=>F*F+T=>i*F+T=>i*i+T=>i*i+F=>i*i+i

 

[i+i*i] E=>E+T=>T+T=>F+T=>i+T=>i+T*F=>i+F*F=>i+i*F=>i+i*i

 

[i+(i+i)] E=>E+T=>T+T=>F+T=>i+T=>i+F=>i+(E)=>i+(E+T)=>i+(T+T)=>i+(F+T)=>i+(i+T)=>i+(i+F)=>i+(i+i)

 

Guess you like

Origin www.cnblogs.com/SeBr7/p/11512164.html