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

  • 大小: 2.26MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2023-10-28
  • 語言: 其他
  • 標(biāo)簽:

資源簡介

東南大學(xué)編譯原理實驗 lex&&yacc

資源截圖

代碼片段和文件信息

#include?“l(fā)ex.h“
#include?
#include?
#include?
using?namespace?std;
#include



Lex::Lex()
{
inFile.open(“LexInput.txt“ios::in);
if(!inFile)
{
cerr<<“LexInput.txt?doesn‘t?exist“;
exit(1);
}

}

Lex::~Lex()
{

}

string?Lex::nextToken()
{
int?state?=?0;
char?ch;
string?str?=?““;
????while(1)
{
switch(state)
{
case?0:
ch?=?inFile.get();
if(isBlank(ch))
state?=?0;
else?if(ch==EOF)
{
state?=?1;
}
else?if(isLetter(ch))
{
state?=?2;
str?+=?ch;
}
else?if(isDigit(ch))
{
state?=?4;
str?+=?ch;
}
else?if(isDoubleOperator(ch))

{
if?(ch==‘!‘)
{
str?+=ch;
ch=inFile.get();
if?(ch!=‘=‘)
{
cerr?< state=8;
}
else
{
str?+=ch;
state=6;
}
}
else
{
str?+=ch;
ch=inFile.get();
if?(ch!=‘=‘)
{
?????????????????????????????spBack();
?????state=6;

}
?else
{
str?+=ch;
state=6;
}
}

}
else?if(isOperator(ch))
{
state?=?6;
str?+=?ch;
}
else?if(isSeparator(ch))
{
state?=?7;
str?+=?ch;
}
else
{
state=8;
str+=ch;
cerr?<
}
break;

case?1:
return?“#“;
break;
case?2:
ch?=?inFile.get();
if(?isLetter(ch)?||?isDigit(ch)?)
{
state?=?2;
str?+=?ch;
}
else
{
spBack();
state?=?3;
}
break;
case?3:
if(!isKeyword(str))
{
str?=?“Identifier:????????“+str;
state?=?0;
return?str;
}
else
{
str?=?“Keyword:???????????“+str;
state?=?0;
return?str;
}
break;
case?4:
ch?=?inFile.get();
if(isDigit(ch))
{
str?+=?ch;
state?=?4;
}
else
{
spBack();
state?=?5;
}
break;
case?5:
str?=?“Number:????????????“+str;
state?=?0;
return?str;
break;
case?6:
str?=?“Operator:??????????“+str;
state?=?0;
return?str;?
break;
case?7:
str?=?“Separator:?????????“+str;

state?=?0;
return?str;
break;
case?8:
ch?=?inFile.get();
if(?(!isLetter(ch)?)&&(!isDigit(ch))&&(!isBlank(ch))&&(!isOperator(ch))&&(!isDoubleOperator(ch))&&(!isSeparator(ch))?)
{
state?=?8;
str?+=?ch;
}
else
{
spBack();
state?=?0;
}

????????????????????cerr< str?=“Error:?????????????“+str;
return?str;
break;
default:
cerr?< exit(0);
break;
}
}
}

void?Lex::spBack()
{
inFile.seekg(-1ios::cur);???//讓文件指針從當(dāng)前位置向文件開始方向移動1個字節(jié)
}

bool?Lex::isBlank(char?ch)
{
ch

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????4601??2010-12-14?19:38??09008304_yacc\09008304_yacc.dsp

?????文件????????549??2010-12-14?19:38??09008304_yacc\09008304_yacc.dsw

?????文件??????58368??2010-12-29?00:31??09008304_yacc\09008304_yacc.ncb

?????文件??????54784??2010-12-29?00:31??09008304_yacc\09008304_yacc.opt

?????文件????????904??2010-12-29?00:22??09008304_yacc\09008304_yacc.plg

?????文件?????630866??2010-12-29?00:22??09008304_yacc\Debug\09008304_yacc.exe

?????文件?????915232??2010-12-29?00:22??09008304_yacc\Debug\09008304_yacc.ilk

?????文件????2195400??2010-12-29?00:16??09008304_yacc\Debug\09008304_yacc.pch

?????文件????1188864??2010-12-29?00:16??09008304_yacc\Debug\09008304_yacc.pdb

?????文件?????258156??2010-12-29?00:22??09008304_yacc\Debug\lex.obj

?????文件?????204491??2010-12-14?19:49??09008304_yacc\Debug\main.obj

?????文件?????292442??2010-12-14?19:49??09008304_yacc\Debug\syntax.obj

?????文件??????99328??2010-12-29?00:22??09008304_yacc\Debug\vc60.idb

?????文件?????126976??2010-12-29?00:16??09008304_yacc\Debug\vc60.pdb

?????文件???????4907??2010-12-14?19:50??09008304_yacc\lex.cpp

?????文件????????400??2010-12-14?19:49??09008304_yacc\lex.h

?????文件?????????25??2010-12-29?00:22??09008304_yacc\LexInput.txt

?????文件????????550??2010-12-14?19:31??09008304_yacc\main.cpp

?????文件?????????24??2010-12-29?00:22??09008304_yacc\outputLex.txt

?????文件????????612??2010-12-29?00:22??09008304_yacc\outputSyntax.txt

?????文件???????9424??2010-12-14?19:30??09008304_yacc\syntax.cpp

?????文件????????407??2010-12-14?19:33??09008304_yacc\syntax.h

?????文件?????374784??2010-12-29?00:31??編譯實驗報告?09008304.doc

?????文件???????4466??2010-12-02?22:10??09008304_lex\09008304_lex.dsp

?????文件????????547??2010-12-02?20:12??09008304_lex\09008304_lex.dsw

?????文件??????50176??2010-12-29?00:16??09008304_lex\09008304_lex.ncb

?????文件??????53760??2010-12-29?00:16??09008304_lex\09008304_lex.opt

?????文件????????878??2010-12-29?00:10??09008304_lex\09008304_lex.plg

?????文件?????585808??2010-12-29?00:10??09008304_lex\Debug\09008304_lex.exe

?????文件?????847900??2010-12-29?00:10??09008304_lex\Debug\09008304_lex.ilk

............此處省略18個文件信息

評論

共有 條評論

相關(guān)資源