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

  • 大小: 13.48MB
    文件類(lèi)型: .rar
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-07-02
  • 語(yǔ)言: 其他
  • 標(biāo)簽: seulex??lex??

資源簡(jiǎn)介

seulex, 編譯原理課程設(shè)計(jì)做的一個(gè)lex工具,實(shí)現(xiàn)的了基本功能,就是生成的詞法分析器有點(diǎn)兒臃腫,大家可以改進(jìn)一下~

資源截圖

代碼片段和文件信息

//?GraphFA.cpp:?implementation?of?the?GraphFA?class.
//
//////////////////////////////////////////////////////////////////////

#include?“GraphFA.h“
#include?
#include?

using?namespace?std;

#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////

#define?NONE?“ε“
#define?ISALPHA(c)??????(?((c)?>=?‘a(chǎn)‘)?&&?((c)?<=?‘z‘)?||?((c)?>=?‘A‘)?&&?((c)?<=?‘Z‘)?||?((c)?>=?‘0‘)?&&?((c)?<=?‘9‘)?||?((c)?==?‘<‘)?||?((c)?==?‘>‘)?||?((c)?==?‘=‘)?||?((c)?==?‘.‘)?||?((c)?==?‘\\‘)?)
bool?UGreater(pair?pair);
const?char*?GraphFA::ErrStr[]?=?{
“非法字符“
“括號(hào)不匹配“
“錯(cuò)誤的運(yùn)算符位置“
};

bool?operator==(?GraphFA::ArcList&?leftGraphFA::ArcList&?right?)
{
for(GraphFA::ArcList::iterator?left_it(left.begin());left_it?!=?left.end();left_it++)
{
GraphFA::ArcList::iterator?right_it(right.begin());
while(right_it?!=?right.end()?
&&?(?left_it->dst?!=?right_it->dst
||?left_it->text?!=?right_it->text))
right_it++;
if(right_it?==?right.end()) //沒(méi)找到
return?false;
}
return?true;
}

GraphFA::GraphFA()
{

}

GraphFA::~GraphFA()
{

}

int?GraphFA::AddStat()
{
stats.push_back(ArcList());
return?stats.size()?-?1;
}

void?GraphFA::AddArc(?int?srcint?dstconst?string&?text?)
{
Arc?arc;
arc.dst?=?dst;
arc.text?=?text;
stats[src].push_front(arc);
}

namespace //子算法集
{
string?Format(const?string&?regexvector&?v) //v?記錄冗余的連接符
{
string?s;
s?=?regex[0];
v.push_back(0);
for(unsigned?int?i?=?1;i? {
if(?(ISALPHA(regex[i])?
||?regex[i]?==?‘(‘)?
&&?(ISALPHA(regex[i-1])?||?regex[i-1]?==?‘)‘?||?regex[i-1]?==?‘*‘)?)
{
s?+=?‘&‘;
v.push_back(v.back()+1);
}
s?+=?regex[i];
v.push_back(v.back());
}
????????//MessageBox(NULL?s.c_str()?NULL?0);
return?s;
}

int?Check(const?string&?regex)
{
unsigned?int?i?=?0;
while(i? &&?(ISALPHA(regex[i])?
||?regex[i]?==?‘(‘?
||?regex[i]?==?‘)‘?
||?regex[i]?==?‘|‘?
||?regex[i]?==?‘*‘
))
i++;
if(i? return?i?+?1;
return?0;
}


}

/************************************************************************
算法:
1.格式化正則表達(dá)式,新增連接運(yùn)算符
2.遍歷正則式,
??符號(hào)--判斷優(yōu)先級(jí)--進(jìn)符號(hào)棧/擴(kuò)展子NFA,
??字符--轉(zhuǎn)換-->thompson構(gòu)造,壓入起始狀態(tài)進(jìn)棧
************************************************************************/



/************************************************************************
算法二:
使用正則表達(dá)式文法構(gòu)造NFA
文法:
R?::=?T{|T}
T?::=?F{&F}
F?::=?P{*}
P?::=?(E)|i
************************************************************************/
bool?GraphFA::checkOR(?const?std::string&?regexint&?posReachEnds&?sub?)
{
if(!checkAND(regexpossub))
return?false;
while(regex[pos]?==?‘|‘)
{
pos++;
Re

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----

?????文件?????919040??2010-01-17?01:56??Lexxer\Debug\Lexxer.exe

?????文件????2332396??2010-01-17?01:56??Lexxer\Debug\Lexxer.ilk

?????文件????6564864??2010-01-17?01:56??Lexxer\Debug\Lexxer.pdb

?????文件????3995648??2010-01-15?17:32??Lexxer\Debug\TestDFA.exe

?????文件?????438656??2010-01-15?17:32??Lexxer\Debug\TestDFA.ilk

?????文件????3009536??2010-01-15?17:32??Lexxer\Debug\TestDFA.pdb

?????文件????3807232??2010-01-17?02:01??Lexxer\Debug\TestLex.exe

?????文件?????604332??2010-01-17?02:01??Lexxer\Debug\TestLex.ilk

?????文件????3214336??2010-01-17?02:01??Lexxer\Debug\TestLex.pdb

?????文件????????554??2010-01-17?01:15??Lexxer\Lexxer\aaa.lex

?????文件???????6544??2010-01-17?01:56??Lexxer\Lexxer\Debug\BuildLog.htm

?????文件????1539887??2010-01-16?23:02??Lexxer\Lexxer\Debug\GraphFA.obj

?????文件????????663??2010-01-15?17:32??Lexxer\Lexxer\Debug\Lexxer.exe.embed.manifest

?????文件????????728??2010-01-15?17:32??Lexxer\Lexxer\Debug\Lexxer.exe.embed.manifest.res

?????文件????????621??2010-01-17?01:56??Lexxer\Lexxer\Debug\Lexxer.exe.intermediate.manifest

?????文件????1147029??2010-01-17?01:56??Lexxer\Lexxer\Debug\lexxer.obj

?????文件?????????65??2010-01-17?01:56??Lexxer\Lexxer\Debug\mt.dep

?????文件?????838656??2010-01-17?01:56??Lexxer\Lexxer\Debug\vc90.idb

?????文件?????872448??2010-01-17?01:56??Lexxer\Lexxer\Debug\vc90.pdb

?????文件??????12674??2010-01-16?23:01??Lexxer\Lexxer\GraphFA.cpp

?????文件???????1993??2010-01-15?13:27??Lexxer\Lexxer\GraphFA.h

?????文件???????8927??2010-01-17?01:56??Lexxer\Lexxer\lexxer.cpp

?????文件???????4058??2010-01-15?17:22??Lexxer\Lexxer\Lexxer.vcproj

?????文件???????1433??2010-01-17?02:05??Lexxer\Lexxer\Lexxer.vcproj.petzold-laptop.petzold.user

?????文件?????896683??2010-01-17?01:58??Lexxer\Lexxer\out.cpp

?????文件?????????19??2010-01-17?01:28??Lexxer\Lexxer\sample.txt

?????文件????7769088??2010-01-17?02:05??Lexxer\Lexxer.ncb

?????文件???????1802??2010-01-17?01:35??Lexxer\Lexxer.sln

????..A..H.?????25088??2010-01-17?02:05??Lexxer\Lexxer.suo

?????文件????????113??2010-01-17?02:01??Lexxer\output.txt

............此處省略48個(gè)文件信息

評(píng)論

共有 條評(píng)論