Syntax tree, phrases, phrases directly Handles

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))

 

 

 phrase:

^、a、^,a、(^,a)、T,(^,a)、(T,(^,a))

Direct phrases:

^,a

Handle:

^

2. The context-free grammar structure description language:

{anbn|n>=0}

S=>aSb|ε

The if statement

if (n>0)

then S:=aSb;

else

   n:=0;

   S: = e?

 

{ambn|m>=n>=0}

E => ASB | SB | ThE | ε

The if statement

if (m>0 && n>0)

then S:=aSb;

else if (m=0 && n>0)

   S:=Sb;

else if (m>0 && n=0)

   S:=aS;

else 

   S: = e

  

   

 

Guess you like

Origin www.cnblogs.com/linyanli/p/11546436.html