02 understanding of grammar and language 09/11

1. understood that symbol string and set operations.

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

  D={0,1, … ,9}

  L and D can be seen as the alphabet, L and D can also be seen as language

Description meaning under represented:

  LUD: full set of letters and numbers

  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

  The set of all symbol string of letters (including [Sigma) is: L *

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

  The set of all strings beginning with the letter symbol, followed by the letter, numbers of: L (LUD) *

 

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

  Production has: Z-> aZb, Z-> ab

  Can be deduced: Z-> ab

        Z->aZb->aabb

        Z->aZb->aaZbb->aaabbb

        .........

  And so on, can be obtained on a L (G [the Z]) = {a n- b n-  | ≧ n-a}. 1, a and b equal to the number of language grammar.   

3. Write grammar quaternion form materials 22 pages in Example 2.2 identifier (VN, NT, P, S).

  Where V N = {the I, L, D}, V T = {L, D}

  P={ I -> I | IL | ID

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

      D -> 0 | 1 | 2 | .....| 9}

  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

  最左推导: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 + ( F + i ) => E + ( i + i ) =>  T + ( i + i ) => F + ( i + i ) => i + ( i

 + i)

Guess you like

Origin www.cnblogs.com/jwwzone/p/11505362.html