1. understood that symbol string and set operations.
L={A,B, … ,Z,a,b, … ,z}
D={0,1, … ,9}
Description meaning under represented:
LUD
LD
L4
L*
D+
L (LUD) *
LUD: full set of letters and numbers
LD: a letter followed by a set of digits
L4: the set of all strings of symbols of four-letter
L *: the set of all strings of symbols of the alphabet
Symbol string or a set of several digits: D +
L * (LUD): the set of all strings beginning with the letter symbols, followed by the letter, numbers.
2. grammar G (Z): Z-> aZb | ab definition of what kind of language?
Z->ab
Z->aZb ->aabb
Z ->aZb ->aaZbb ->aaabbb
Therefore, the definition is A n- B n-.
3. Write grammar quaternion form materials 22 pages in Example 2.2 identifier (VN, NT, P, S).
I->
L->
D->
VN={I,L,D}
VT={L,D}
P={I->L,I->IL,I->ID,L->L,D->D}
S={I}
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.
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
最右推导: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=>T+T=>F+T=>i+T=>i+T*F=>i+F*F=>i+i*F=>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=>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)
最右推导: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)