1.已知文法:
S->a|^|(T)
T->T,S|S
分析句型(T,(^,a)),求全部的短语、直接短语和句柄。
2.构造上下文无关文法,描述语言:
{anbn|n>=0}
{ambn|m>=n>=0}
{(ab)n|n>=0}
{ambn|m,n>=1}
(1)文法:G(T):T->ab|aTb|ε
(2)文法:G(T):T->aTb|aT|ε
(3)文法:G(T):T->ab|abT|ε
(4)文法:G(T):T->ab|aT|bT|aTb
3.如果if语句的方法:
stmt->if expr then stmt
| if expr then stmt else stmt
| other
句子if E1 then if E2 then S1 else S2是否有两棵不同的语法树?说明了什么?