一个关于编译原理的问题
E->T|E+T|E-T
T->F|T*F|T/F
F->(E)|i
给出 i+i*i,i*(i+i) 最左推导 和最右推导
参考答案:左:
E->E+T->T+T->F+T->i+T->i+T*F->i+F*F->i+i*F->i+i*i;
E->T->T*F->F*F->i*F->i*(E)->i*(E+T)->i*(T+F)->i*(F+F)->i*(i+F)->i*(i+i);
右:
E->E+T->E+T*F->E+T*i->E+F*i->E+i*i->T+i*i->F+i*i->i+i*i;
E->T->T*F->T*(E)->T*(E+T)->T*(E+F)->T*(E+i)->T*(T+i)->T*(F+i)->T*(i+i)->F*(i+i)->i*(i+i);