Senin, 06 April 2015

g


Grammar  :
S -> E
E -> T+E | T
T -> F*T | F
F -> (E)   | i
Soal     :
1.)    i * i + i * i
2.)    i * (i + i) * i

Penyelesaian    :
                                                                        S
                                                           
                                                          E

                                                          T
                                                           
      F  *      T
                                                    
                                                      E           F
                                                T    + E          i
                                       
  F   *     T   T

                                         i          F   F
                  
                                                     i   i
Hasil : i * i + i * i
S
                                                           
                                                          E

                                                          T
                                                           
      F  *      T
                                                    
                                                      E           F
                                                T    + E          i
                                       
  F   *     T   T

                                         i          F   F
                  
                                                     i   i
Hasil :         i * (i + i) * i

Tidak ada komentar:

Posting Komentar