首页 > 玄幻魔法 > 那么修女小姐要怎么办呢 > 假条,今天要写编译原理,来不及更新啦

假条,今天要写编译原理,来不及更新啦(2/2)

目录
好书推荐: 我家李白不可能是女装大佬 帝世无双 洪荒之太一神话 衍生空间大反派 罪恶之生存游戏 带着崩玉诸天 星墟战记 明星批发商 史上最强大妖 倾世锁魂

cout<setw(40)<w();

cout<“top[1].val*=top[0].val,pop()“;

}

elseif(s->id==14)

{

if((0).index->hasval&&(1).index->hasval)

{

doubletemp=().index->val;

();

().index->val/=

().index->text=to_string(().index->val);

}

else{

out=(1).index->text+“/“+(0).index->

(1).index->text=out;

(1).index->hasval=f

();

}

cout<setw(40)<w();

cout<“top[1].val/=top[0].val,pop()“;

}

elseif(s->id==15)

{

var[top].val=().index->val;

h(*s);

cout<setw(40)<w();

();

cout<“variable[top].val=“<().index->val;

();

top++;

}

elseif(s->id==16)

{

if((0).index->hasval&&(1).index->hasval){

doubletemp=().index->val;

();

().index->val=pow(().index->val,temp);

().index->text=to_string(().index->val);

}

else{

out=(1).index->text+“^“+(0).index->

(1).index->text=out;

(1).index->hasval=f

();

}

cout<setw(40)<w();

cout<“top[1].val=top[1].val^top[0].val,pop()“;

}

elseif(s->id==1

{

h(*s);

cout<setw(40)<w();

cout<“push(“<().index->val<“)“;

}

elseif(s->id==17)

{

if(var[top-1].name==““)

{

var[top-1].name=s->index->

stringtemp=to_string(var[top-1].val)+“=“+s->index->

cout<setw(40)<

cout<“variable[top].text=“<s->index->text<“,pop(3)“;

}

else

{

if(find_var(s->index->text)>=0)

{

s->index->val=var[find_var(s->index->text)].val;

h(*s);

cout<setw(40)<w();

cout<“find(“<s->index->text<“)=“<s->index->val;

}

else

{

s->index->hasval=f

hasundefine=

h(*s);

cout<setw(40)<w();

cout<“nodefine“<s->index->

}

}

}

}

}

intcount_p=0;

voidpost(node*s)//对树的后序遍历

{

if(s!=null){

post(s->child);

post(s->bro);

if(s->id<23&&s->id!=7&&s->id!=8&&s->id!=9)cout<s->

}

}

voidpost(my_stack<node>&stack,node*s)//对树的后序遍历

{

if(s!=null){

post(stack,s->child);

post(stack,s->bro);

if(s->id<23&&s->id!=7&&s->id!=8&&s->id!=9)

{

cout<setw(10)<left<count_p<““;

count_p++;

semanti_ana(stack,s);

cout<

}

}

}

intmain()

{

node*start=&s;

sheet=newnode[23];

sheet[0].text=“sin“;

sheet[1].text=“cos“;

sheet[2].text=“tg“;

sheet[3].text=“ctg“;

sheet[4].text=“log“;

sheet[5].text=“lg“;

sheet[6].text=“ln“;

sheet[7].text=“(“;

sheet[8].text=“)“;

sheet[9].text=“;“;

sheet[10].text=““;

sheet[11].text=“+“;

sheet[12].text=“-“;

sheet[13].text=“*“;

sheet[14].text=“/“;

sheet[15].text=“=“;

sheet[16].text=“^“;

sheet[17].text=“var“;

sheet[18].text=“con“;

sheet[19].text=“pi“;

sheet[20].text=“e“;

sheet[21].text=“#“;

sheet[22].text=“,“;

=23;t=“s“;

=24;t=“a“;

=25;t=“b“;

=26;t=“c“;

=27;t=“d“;

=28;t=“e“;

=29;t=“f“;

=30;t=“g“;

=31;t=“h“;

=32;t=“i“;

=33;t=“j“;

for(inti=0;i<23;i++)

sheet[i].id=i;

ifstre

n(“d:\\词法.txt“);

node*a=newnode[maxsize];//当前输入

charbuffer[256];

while(line(buffer,100))//读取输入内容,既词法分析结果

{

a[n].text=bu

intc1=a[n].d(“<“);

intc2=a[n].d(“,“);

intc3=a[n].d(“>“);

a[n].id=stoi(a[n].str(c2+1,c3-1).data());

if(a[n].id==19||a[n].id==20)a[n].id=18;

a[n].text=a[n].str(c1+1,c2-1);

n++;

}

a[n].text=“#“;

a[n].id=-1;

a[n].child=

a[n].bro=

se();

n++;

my_stack<node>s

h(a[n-1]);

h(s);

start=().i

n-=2;

cout<“**************************************************语法分析***************************************************“;

cout<“步骤栈内容当前输入操作“;

stringc=“--------------------------------------------------------------------------------------------------------------“;

cout<c<c;

ana(stack,a);

cout<“**************************************************语法分析***************************************************“;

cout<“**************************************************语义分析***************************************************“;

my_stack<node>l//语义分析栈

cout<

cout<“后缀式:“;

post(start);

cout<

cout<

cout<“步骤栈内容操作“;

cout<c<c;

post(lexme,start);

cout<“**************************************************语义分析***************************************************“;

ret

}

目录
新书推荐: 开局迎娶苏家神女,奖励重瞳体! 洪荒:三清也得乖乖叫我一声二叔 万古长生,葬尽诸天仙神 我将要一统大陆 武侠:杀敌爆修为,我功力滔天! 高武:从肝二郎神天赋开始变强(已改名:高武:从武道生到宇宙天尊) 摆烂就无敌,出生秒仙帝 长生万古,苟到大帝再出关! 巫师:我的称号面板 我在气运长河钓出个万古神朝
返回顶部