91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

實驗課上寫的編譯原理的語義分析和四元式代碼的生成。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#define?reser?20
using?namespace?std;

char?*charstring?=?“abcdefghijklmnopqrstuvwxyz“;
char?*numstring =?“0123456789“;
char?*strstring =?“abcdefghijklmnopqrstuvwxyz0123456789“;
char?reserve[reser][10];
char?idshed[40][10]?opshed[40][10];
char?token[15]?id[15]?sym[15];
char?line[80]?tempp[240];
char?ch?temp?tem;
char?tx[10]?tn[4]?signt1[20]?signt2[20]?ju[20];
int cc?ii?k?kind?t?e4?=?0?e3?=?0?judge?=?1?row1?=?0;
int startc?idsh?=?0?opsh?=?0?tt?=?1?nn?=?1?adds?=?0?pp?=?0;
int li?=?0;
FILE?*fp;

void??getch(){
if?(?li?==?0?){
if?(?cc?==?ii?){
cc?=?1;?ii?=?0;

if?(?row1?==?1?)
fseek(?fp?-1?1?);??/*讀行首字符將指針退回一格,若是整個文本的開頭,則不需要*/
line[0]?=?fgetc(?fp?);
row1?=?1;

while?(?(?(temp?=?fgetc(?fp?)?)?!=?‘\n‘)?&&?(temp?!=?EOF)?){
line[cc++]?=?temp;
tempp[pp++]?=?temp;
}
line[cc++]?=?‘?‘;?/*將緩沖帶后加上一個空字符,以便行和行之間號區分?*/
tempp[pp++]?=?‘?‘;

while?(?(?(temp?=?fgetc(?fp?)?)?==?‘\n‘)?&&?(temp?!=?EOF)?);???????/*?跳過空行*/
line[cc]?=?‘\0‘;
}
tem?=?line[ii++];
ch?=?tem;
}?else
ch?=?tempp[pp++];
}

void?getnbc(){
getch();
while?(?ch?==?‘?‘?)
getch();
if?(?ch?==?‘{‘?){
do{
getch();
}?while?(?ch?==?‘}‘?);
getnbc();
}
}

//判斷ch是不是字母??
int?jchar(?char?ch?){
if?(?strchr(?charstring?ch?)?==?0?)
return?0;
else?return?1;
}

//判斷ch是不是數字
int??jnum(?char?ch?){
if?(?strchr(?numstring?ch?)?==?0?)
return?0;
else?return?1;
}

//判斷ch是不是字母或數字
int?jstr(?char?ch?){
if?(?strchr(?strstring?ch?)?==?0?)
return?0;
else?return?1;
}

void?advance(){
getnbc();
kind?=?0;

if?(?jchar(?ch?)?==?1?){
k?=?0;
do{
if?(?k? token[k++]?=?ch;
getch();
}?while?(?jstr(?ch?)?==?1?);

if?(?li?==?0?)
ii--;
else?pp--;

token[k]?=?‘\0‘;?????????????/*截去token中的無用字符*/

strcpy(?id?token?);
for?(?t?=?0;?t?<=?20;?t++?){
if?(?strcmp(?reserve[t]?id?)?==?0?)
break;
}
if?(?t?<=?20?)
kind?=?t;
else?kind?=?21;
strcpy(?sym?id?);
}?else
if?(?jnum(?ch?)?==?1?){
k?=?0;
do{
if?(?k? token[k++]?=?ch;
getch();
}
while?(?jstr(?ch?)?==?1?);

if?(?li?==?0?)
ii--;
else?pp--;
kind?=?22;
token[k]?=?‘\0‘;
strcpy(?sym?token?);
}?else?{
if?(?ch?==?‘.‘?)
kind?=?26;
k?=?0;
do{
sym[k++]?=?‘?‘;
}
while?(?k?!=?15?);
sym[0]?=?ch;
sym[1]?=?‘\0‘;
}
}

void??error(?int?n?){
judge?=?0;??????/*出錯退出,將judge=0*/
switch?(?n?){
case?0:?{?printf(?“?Error(0):Expect??‘:‘?\n“?);?break;?}
case?1:?{?printf(?“?Error(1):Expect??‘=‘?\n“?);?break;?}
case?2:?{?printf(?“?Error(2):Syntax?error?\n“?);?break;?}
case?3:?{?printf(?“?Error(3):Except??Operater?\n“?);?break;?}
case?4:?{?printf(?“?Error(4):Except??ID?or?NUM?\n“?);?break;?}
case?5:?{?printf(?“?Error(5):Except?‘;‘??\n“?);?break;?}
ca

評論

共有 條評論