编译原理

您所在的位置:网站首页 a∨输出 编译原理

编译原理

2024-07-14 00:09| 来源: 网络整理| 查看: 265

数值表示法 如同计算算数表达式一样,一步步计算(先算括号,后外面)例子: a or b and not c 翻译成:

                          T1=not c

                          T2=b and T1

                          T3=a and T2

                     2.   anot E1 { E.place:newtempemit(E.place=not E1.place)}E->(E1){ E.place=E1.place}E->id1 relop id2 { E.place=newtemp,emit(if id1 relop id2 goto nextstat+3),emit(E.place=0)emit(goto nextstat+2)emit(E.place=1)}E->id {E.place=id.place}例子:布尔表达式atrue E.code=gen(goto true)E->false E.code=gen(goto false)根据属性文法翻译布尔表达式:aE1 and M E2 backpatch(E1,truelist,M.quad)E.truelist=E2.truelistE.falselist=Merge(E1,falselist,E2.falselist)E->not E1 E.truelist=E1.falselistE.falselist=E1.truellistE->(E1) E.truelist=E1.truelistE.falselist=E1.falselistE->id1 relop id2 E.truelist=makelist(nextquad);E.falselist=makelist(nextquad+1);emit(j relop id1.place id2.place,0);emit(j,-,-0);E->id E.truelist=makelist(nextquad)E.falselist=makelist(nextquad+1);emit(j relop, id.place,-0)emit(j,-,-0);

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3