The third work syntax tree, phrases, phrases directly Handles

  1. 1.   Known grammar:

S->a|^|(T)

T->T,S|S

Analysis sentence (T, (^, a)), find all phrases, phrases and handle directly.

推导:   s=>(T)=>(T,s)=>(T,(T))=>(T,(T,s))=>(T,(s,s))=>(T,(^,s))=>(T,(^,a))

Syntax tree:

 

All phrases:  (T, (^, A)); T, (^, A); (^, A); ^, A; ^; A  

Direct phrases:    ^; A    

Handle: ^

  1. 2. The   configuration context-free grammar description language:

anbn|n>=0

ambn|m>=n>=0

if statement

solution:

anbn|n>=0}:

D -> aDb | ab | ε

ambn|m>=n>=0}:

E -> aEb | ab | a | e

 

      if statement : 

       if < condition > then < statement a> | if < condition > then < statement a> else < statement b>

 

Guess you like

Origin www.cnblogs.com/fqy1028/p/11547313.html