编译原理参考答案
程 序 设 计 语 言
Chapter 4. 自上而下语法分析
CH.4.练习题1(P81.)
1.考虑下面文法G1: S→a|^|(T) T→T,S|S(1) 消去G1左递归。然后对每个非终止符,写出不带回溯递归子程序。
解(1) 消左后文法G1’: S→a|^|(T) T→ST’ T’→ ,ST’|ε
CH.4.练习题1(P81.)
解(1) 不带回溯递归子程序: S→a|^|(T) Procedure S; Begin if sym=‘a’ or sym=‘^’ then advance else if sym=‘(‘ then begin advance; T; if sym=‘)’ then advance else error end else error End;


雷达卡




京公网安备 11010802022788号







