VC++6.0可以运行的程序如何在VS2008上运行
我在VC++6.0写的词法分析程序可以运行,但是不知道怎么在VS2008创建项目和文件的类型,初学者,麻烦指点!附上源代码!#include<stdio.h>#inclu...
我在VC++6.0写的词法分析程序可以运行,但是不知道怎么在VS2008创建项目和文件的类型,初学者,麻烦指点!附上源代码!
#include <stdio.h>
#include <string.h>
char prog[80],token[8];
char ch;
int syn,p,m,n,sum;
char *rwtab[6]={"begin","if","then","while","do","end"};
void scaner();
void main(){
p=0;
printf("\n please input string;\n");
do {
scanf("%c",&ch);
prog[p++] = ch;
}while (ch!='#');
p=0;
do{
scaner();
switch(syn) {
case 11: printf ("(syn,%d)\n",sum); break;
case -1:printf("error!\n");break;
default:printf("(%d,%s)\n",syn,token);
}
}while (syn!=0);
}
void scaner(){
for(n=0;n<8;n++) token[n]=NULL;
ch = prog[p++];
while(ch==' ')
ch = prog[p++];
if(ch>='a'&&ch<='z'){
m = 0;
while((ch>='a'&&ch<='z')||(ch>='0'&&ch<='9')){
token[m++] = ch;
ch = prog[p++];
}
token[m++]='\0';
--p;
syn=10;
for (n=0;n<6;n++)
if(strcmp(token,rwtab[n])==0){
syn = n+1;
break;
}
}
else
if(ch>='0'&&ch<='9'){
while (ch>='0'&&ch<='9'){
sum=sum*10+ch-'0';
ch = prog[p++];
}
--p;
syn=11;
}
else
switch(ch){
case'<':
m=0;token[m++]=ch;
ch = prog[p++];
if(ch=='>'){
syn=21;
token[m++]=ch;
}
else
if (ch=='='){
syn=22;
token[m++]=ch;
}
else{
syn=20;
--p;
}
break;
case'>':
token[m++] = ch;
ch = prog[p++];
if(ch=='='){
syn = 24;
token[m++] = ch;
}
else {
syn = 23;
--p;
}
break;
case':':
token[m++] = ch;
ch = prog[p++];
if(ch=='='){
syn = 18;
token[m++] = ch;
}
else {
syn = 17;
--p;
}
break;
case'+':
syn=13;token[0]=ch;break;
case'-':
syn=14;token[0]=ch;break;
case'*':
syn=15;token[0]=ch;break;
case'/':
syn=16;token[0]=ch;break;
case'=':
syn=25;token[0]=ch;break;
case';':
syn=26;token[0]=ch;break;
case'(':
syn=27;token[0]=ch;break;
case')':
syn=28;token[0]=ch;break;
case'#':
syn=0;token[0]=ch;break;
default:
syn=-1;
}
} 展开
#include <stdio.h>
#include <string.h>
char prog[80],token[8];
char ch;
int syn,p,m,n,sum;
char *rwtab[6]={"begin","if","then","while","do","end"};
void scaner();
void main(){
p=0;
printf("\n please input string;\n");
do {
scanf("%c",&ch);
prog[p++] = ch;
}while (ch!='#');
p=0;
do{
scaner();
switch(syn) {
case 11: printf ("(syn,%d)\n",sum); break;
case -1:printf("error!\n");break;
default:printf("(%d,%s)\n",syn,token);
}
}while (syn!=0);
}
void scaner(){
for(n=0;n<8;n++) token[n]=NULL;
ch = prog[p++];
while(ch==' ')
ch = prog[p++];
if(ch>='a'&&ch<='z'){
m = 0;
while((ch>='a'&&ch<='z')||(ch>='0'&&ch<='9')){
token[m++] = ch;
ch = prog[p++];
}
token[m++]='\0';
--p;
syn=10;
for (n=0;n<6;n++)
if(strcmp(token,rwtab[n])==0){
syn = n+1;
break;
}
}
else
if(ch>='0'&&ch<='9'){
while (ch>='0'&&ch<='9'){
sum=sum*10+ch-'0';
ch = prog[p++];
}
--p;
syn=11;
}
else
switch(ch){
case'<':
m=0;token[m++]=ch;
ch = prog[p++];
if(ch=='>'){
syn=21;
token[m++]=ch;
}
else
if (ch=='='){
syn=22;
token[m++]=ch;
}
else{
syn=20;
--p;
}
break;
case'>':
token[m++] = ch;
ch = prog[p++];
if(ch=='='){
syn = 24;
token[m++] = ch;
}
else {
syn = 23;
--p;
}
break;
case':':
token[m++] = ch;
ch = prog[p++];
if(ch=='='){
syn = 18;
token[m++] = ch;
}
else {
syn = 17;
--p;
}
break;
case'+':
syn=13;token[0]=ch;break;
case'-':
syn=14;token[0]=ch;break;
case'*':
syn=15;token[0]=ch;break;
case'/':
syn=16;token[0]=ch;break;
case'=':
syn=25;token[0]=ch;break;
case';':
syn=26;token[0]=ch;break;
case'(':
syn=27;token[0]=ch;break;
case')':
syn=28;token[0]=ch;break;
case'#':
syn=0;token[0]=ch;break;
default:
syn=-1;
}
} 展开
1个回答
浙江启扬智能科技有限公司
2023-06-12 广告
2023-06-12 广告
不一定要用Linux系统的。例如ARM9系列可以用WinCE系统。但是目前不建议用windows操作系统进行开发。因为目前支持WinCE的处理器平台偏低端;而且WinCE需要版权费用,在稳定性上,低于Linux系统。像启扬他们做了一些ARM...
点击进入详情页
本回答由浙江启扬智能科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询