We understood that symbol string and set operations.
L={A,B, … ,Z,a,b, … ,z}
D={0,1, … ,9}
Description meaning under represented:
LUD: binding a full set of alphanumeric
LD: the set of all strings of symbols consisting of a letter followed by a number composed of
L4: the set of all strings of symbols of four-letter
L *: All symbols of the alphabet string including a set of an empty string of symbols ξ
D +: sequence by a set of symbols or the whole composition to nine digits
L (LUD) *: all symbols beginning with the letter strings, or numbers followed by the letter set
Grammar G (Z): Z-> aZb | ab definition of what kind of language?
Z->aZb|ab
Z->ab
Z->aZb->aaZbb->aaaZbbb->aaaaZbbbb->......->anbn
G (Z) is defined by A n- B n-
Therefore, G (Z) are symmetrical grammar
Grammar written materials in the form of a quad page identifiers 2.2 22 cases (VN, VT, P, S).
An identifier set I, L letter, D is a digital
VN nonempty nonterminal, VT non-empty terminal symbols, P is a production set, S is the start symbol
P = {
I -> L
I -> IL
I>-> ID
......
L -> a
D -> 0
D -> 1
......
D -> 9
S = I
G: S -> L | IL | ID
L -> a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z
D -> 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
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)
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 => E+T+T => T+T+T => F+T+T => i+T+T => i+F+T => i+i+T => i+i+F => i+i+i => i+(i+i)
最右推导:E => E+T => E+F => E+i => E+T+i = > E+F+i => E+i+i => T+i+i => F+i+i => i+i+i => i+(i+i)