首页 > 代码库 > 词法转换
词法转换
#include<stdio.h>#define MAX 50main(){ char shuru[MAX]; do { printf("请输入想要识别的字符:(输入tuichu代表退出)\n"); scanf("%s",&shuru); if(strcmp(shuru,"begin") == 0) printf("符号为:%s,种别码为:1\n",shuru); else if(strcmp(shuru,"if") == 0) printf("符号为:%s,种别码为:2\n",shuru); else if(strcmp(shuru,"then") == 0) printf("符号为:%s,种别码为:3\n",shuru); else if(strcmp(shuru,"while") == 0) printf("符号为:%s,种别码为:4\n",shuru); else if(strcmp(shuru,"do") == 0) printf("符号为:%s,种别码为:5\n",shuru); else if(strcmp(shuru,"end") == 0) printf("符号为:%s,种别码为:6\n",shuru); else if(strcmp(shuru,"l(l|d)*") == 0) printf("符号为:%s,种别码为:10\n",shuru); else if(strcmp(shuru,"dd*") == 0) printf("符号为:%s,种别码为:11\n",shuru); else if(strcmp(shuru,"+") == 0) printf("符号为:%s,种别码为:13\n",shuru); else if(strcmp(shuru,"-") == 0) printf("符号为:%s,种别码为:14\n",shuru); else if(strcmp(shuru,"*") == 0) printf("符号为:%s,种别码为:15\n",shuru); else if(strcmp(shuru,"/") == 0) printf("符号为:%s,种别码为:16\n",shuru); else if(strcmp(shuru,":") == 0) printf("符号为:%s,种别码为:17\n",shuru); else if(strcmp(shuru,":=") == 0) printf("符号为:%s,种别码为:18\n",shuru); else if(strcmp(shuru,"<") == 0) printf("符号为:%s,种别码为:20\n",shuru); else if(strcmp(shuru,"<=") == 0) printf("符号为:%s,种别码为:21\n",shuru); else if(strcmp(shuru,"<>") == 0) printf("符号为:%s,种别码为:22\n",shuru); else if(strcmp(shuru,">") == 0) printf("符号为:%s,种别码为:23\n",shuru); else if(strcmp(shuru,">=") == 0) printf("符号为:%s,种别码为:24\n",shuru); else if(strcmp(shuru,"=") == 0) printf("符号为:%s,种别码为:25\n",shuru); else if(strcmp(shuru,";") == 0) printf("符号为:%s,种别码为:26\n",shuru); else if(strcmp(shuru,"(") == 0) printf("符号为:%s,种别码为:27\n",shuru); else if(strcmp(shuru,")") == 0) printf("符号为:%s,种别码为:28\n",shuru); else if(strcmp(shuru,"#") == 0) printf("符号为:%s,种别码为:0\n",shuru); else if(strcmp(shuru,"tuichu") == 0) { printf("退出成功!\n"); break; } else printf("无法识别此字符串!\n"); }while(-1);}
词法转换
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。