首页 > 代码库 > 201506110248--编译原理

201506110248--编译原理

#include<stdio.h>#define N 100int a[100];int keyWord(char key[100],int num);/*char guanJianZi[]={"if","int","include","cout","float","else","main","return"};  int guanJianZiNum=8;//记录上面的数组里面有几个关键字方便下面的程序使用  //{"this","include","int","float","if","else","return"};      char suanFu[]={‘+‘,‘-‘,‘*‘,‘/‘,‘=‘};  int suanFuNum=5;//记录上面的数组里面有几个算符方便下面的程序使用      char jieFu[]={ ‘;‘ , ‘{‘ , ‘}‘ , ‘[‘ , ‘]‘ };  int jieFuNum=5;//记录上面的数组里面有几个界符方便下面的程序使用      //记录是不是关键字如果为1就是关键字如果为0的话就不是关键字方便于关键字和标识符做区分  int flag=0;      void using namepace std();*/main(){    //int i,n;    printf(".各种单词符号对应的种别码\n:");    printf("单词符号\t种别码\t\t单词符号\t种别码\t\t\t");    printf("          begin           1                :              17         \n");    printf("  if              2                :=             18         \n");    printf("  then            3                <              20         \n");    printf("  while           4                <=             21         \n");    printf("  do              5                <>             22         \n");    printf("  end             6                >              23         \n");    printf("  l(l|d)          10               >=             24         \n");    printf("  dd*             11               =              25         \n");    printf("  +               13               ;              26         \n");    printf("  -               14               (              27         \n");    printf("  *               15               )              28         \n");    printf("  /               16               #               0         \n\n\n\n");    printf("请输入一句英文句子\n:");    printf("for example:Hello!YY.0\n");    /*do{        int class;        int w,c1,c;//w系单词符号,c1系种别码        printf("请输入你的选择(class)");        scanf("%d",&c);        switch(c){            //for(c1=1;c1<30;c1++)        case 1:            if(c1=‘1‘)                printf("(1,begin)");            break;        case 2:            if(c1=‘2‘)                printf("(2,if)");                break;        }    }while(0);*/}int keyWord(char key[100],int num){    int flag=0;    char key[100]={"begin","if","then","while","do","end"};    //String num[22]={‘1‘,‘2‘,‘3‘,‘4‘,‘5‘,‘6‘};    for(int i1=0;i1<=key.length;i1++)    {    }}

 

201506110248--编译原理