• 大小: 21KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-05-24
  • 语言: 其他
  • 标签:

资源简介

输入数据示例: while (a3+15)>0xa do if x2 = 07 then while y 10 goto L2 goto L0 L2: if x2 = 7 goto L3 goto L1 L3: if y < z goto L4 goto L1 L4: t2 = x * y t3 = t2 / z y = t3 goto L3 goto L1 L0: // S.next

资源截图

代码片段和文件信息

#include
#include
#include
#include
#include
char input[200]mech[10];        /*input存放最先输入的字符串,在输入的过程中,就进行了预处理*/
char ech[100][10];
char echattr[100][10];
char nch[10];
char Fplace[10]Eplace[10]Tplace[10]TTplace[10]EEplace[10]E1place[10]E2place[10]idplace[10]Splace[10]Snext[10]Ctrue[10]Cfalse[10]Sbegin[10];
char S1next[10]S2next[10];
char Fcode[50]Ecode[50]Tcode[50]TTcode[50]EEcode[50]E1code[50]E2code[50]idcode[50]Scode[50]Ccode[50];
int temp=1;
int label=0;
int stack;
int nuattr;
int flag=0;
char attr[10];
int number=0;
int now;
void init(char *ch)
{
    char newc[10];
    newc[0]=NULL;
    strcpy(chnewc);
}
int S();
int SS();
int E();
int C();
int CC();
int T();
int TT();
int EE();
int F();
int scan();
void newtemp(char *ch)
{
    sprintf(attr“%d“temp);
    strcpy(ch“t“);
    strcat(chattr);
    temp++;
}
void newlabel(char *ch)
{
    sprintf(attr“%d“label);
    strcpy(ch“L“);
    strcat(chattr);
    label++;
}
main()
{
    int i=0j=0t;
    char c;
    char c1[2];
    c1[1]=‘\0‘;
    printf(“Please input the String end with #:\n“);    /*以#代表结束*/
    do
    {
        c=getchar();
        if(c==‘ ‘)
        {
            if(i==0)
            {
                while(c==‘ ‘)
                {
                    c=getchar();
                }
                input[i]=c;
                i++;
            }
            else
            {
                while(c==‘ ‘)
                {
                    c=getchar();
                }
                input[i]=‘ ‘;
                i++;
                input[i]=c;
                i++;
            }
        }
        else
        {
            input[i]=c;
            i++;
        }
    }while(c!=‘#‘);                                   /*输入字符串,输入的过程中进行预处理,去掉多余的空格*/
    i=0;
    while(input[i]!=‘#‘)
    {
        c1[0]=input[i];
        if(c1[0]==‘+‘||c1[0]==‘-‘||c1[0]==‘*‘||c1[0]==‘/‘||c1[0]==‘>‘||c1[0]==‘<‘||c1[0]==‘=‘||c1[0]==‘(‘||c1[0]==‘)‘)
        {
            if(strlen(mech)!=0)
            {
                t=scan(mech);
                if(t==15)
                {
                    sprintf(attr“%d“nuattr);
                    strcpy(echattr[j]attr);
                    strcpy(mech“int10“);
                }
                if(t==16)
                {
                    sprintf(attr“%d“nuattr);
                    strcpy(echattr[j]attr);
                    strcpy(mech“int16“);
                }
                if(t==17)
                {
                    sprintf(attr“%d“nuattr);
                    strcpy(echattr[j]attr);
                    strcpy(mech“int8“);
                }
                if(t==18)
                {
                    strcpy(echattr[j]attr);
                    strcpy(mech“i“);
                }
                strcpy(ech[j]mech);
                strcpy(

评论

共有 条评论

相关资源