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

  • 大小: 12KB
    文件類(lèi)型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-09-11
  • 語(yǔ)言: C/C++
  • 標(biāo)簽: Lexc++??

資源簡(jiǎn)介

是使用C++書(shū)寫(xiě)的Lex工具,通過(guò)了基本的測(cè)試。

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
#include

#include?“source1.h“

ifstream?fin;
ofstream?fout;


main()
{


char?action[100][100];//用于記錄規(guī)則段動(dòng)作部分

////////////////////////////////////////////////////////定義段掃描,分析
fin.open(“test.l“ios::out);//打開(kāi)輸入文件
fout.open(“Seu_Lex.cpp“ios::out);//打凱輸出文件
char?c;
if(fin.get()!=‘%‘||fin.get()!=‘{‘){
cerr<<“Wrong?fileerror?1“< exit(0);
}
fin.get();
c=fin.get();
while(c!=‘%‘){
fout.put(c);
c=fin.get();
}
fin.get();
fin.get();
List?trans;//用于記錄定義段RE
char*?temp=new?char[100];
fin.getline(temp100);
while(temp[0]!=‘%‘||temp[1]!=‘%‘){
trans.AddTail(temp);
fin.getline(temp100);
}
// trans.print();




////////////////////////////////////////////////////////規(guī)則段掃描,分析
string?s;
stack?st;?
NFA?nfa1nfa2;
int?pos=0;

List?workl;//結(jié)果DFA

fin.getline(temp100‘?‘);
while(temp[0]!=‘%‘||temp[1]!=‘%‘){
s=string(temp);
RE?re(s);
bool?flag=true;
if(re.re[0]==‘{‘){//RE的替換(對(duì){num}等形式,用定義段RE替換)
for(ListNode*?p=trans.first;p!=NULL;p=p->link){
int?i=1;
flag=true;
while(re.re[i]!=‘}‘){
if(p->data[i-1]!=re.re[i]){
flag=false;
break;
}
i++;
}
if(flag){
re.re.erase(0i+1);
while(1){
if(p->data[0]!=‘:‘){
p->data.erase(01);
}
else{
p->data.erase(01);
break;
}
}


re.re.insert(0p->data);

}
}
if(re.re[0]==‘{‘){
cerr<<“Error2!!!“< exit(0);
}
}


re.extend();//擴(kuò)展
re.toPostOrder();//轉(zhuǎn)為后綴
for(int?i=0;i if(!re.isOp(re.re[i]))
st.push(NFA(re.re[i]));//不是運(yùn)算符?進(jìn)棧
else?if(re.re[i]==‘*‘){//‘*’運(yùn)算,出棧一個(gè),運(yùn)算后入棧
nfa1.copy(st.top());
nfa1.copy(nfa1.operate(nfa1STAR));
st.pop();
st.push(nfa1);
}
else?if(re.re[i]==‘~‘){//‘~’運(yùn)算,出棧兩個(gè),運(yùn)算后入棧
nfa1.copy(st.top());
st.pop();
nfa2.copy(st.top());
st.pop();
nfa1.copy(nfa2.operate(nfa1CONCAT));
st.push(nfa1);
}
else{//‘|’運(yùn)算,出棧兩個(gè),運(yùn)算后入棧
nfa1.copy(st.top());
st.pop();
nfa2.copy(st.top());
st.pop();
nfa1.copy(nfa2.operate(nfa1UNION));
st.push(nfa1);
}
}
nfa1.copy(st.top());

// nfa1.view();
DFA?dfa(nfa1);//轉(zhuǎn)DFA
// dfa.view();
dfa.minDFA();//最小化DFA
// dfa.view();

workl.AddTail(dfa);//DFA加入工作鏈表
st.pop();

fin.getline(action[pos]100);//記錄相應(yīng)動(dòng)作
fin.getline(temp100‘?‘);

pos++;
}


///////////////////////////////////////////////////////////轉(zhuǎn)換為代碼
string?code;
DFA?workdfa;

int?flag=0;
code=“int?analysis(string?s)\n{\n\tint?state=0;\n\tbool?match=false;\n\tint?i;\n\t“;
for(int?i=0;i fout.put(code[i]);

}


for(ListNode*?p=workl.first;p!=NULL;p=p->link)//對(duì)工作鏈表中每一個(gè)DFA
{
workdfa.copy(p->data);
code=workdfa.toCode();
for(i=0;i

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

?????文件???????3400??2008-05-08?00:02??Lex\源代碼\setlink.h

?????文件???????3873??2008-05-08?08:53??Lex\源代碼\SeuLex.cpp

?????文件??????14957??2008-05-08?00:45??Lex\源代碼\source1.cpp

?????文件???????2536??2008-05-08?00:28??Lex\源代碼\source1.h

?????文件???????2400??2008-05-08?08:40??Lex\源代碼\test.l

?????文件????????141??2009-04-02?19:17??Lex\源代碼\說(shuō)明.txt

?????文件???????1193??2008-05-08?08:57??Lex\生成代碼\matchtab.h

?????文件??????32059??2008-05-08?08:53??Lex\生成代碼\Seu_Lex.cpp

?????文件?????????63??2008-05-08?09:01??Lex\生成代碼\說(shuō)明.txt

?????目錄??????????0??2009-04-02?19:17??Lex\源代碼

?????目錄??????????0??2009-04-02?19:16??Lex\生成代碼

?????目錄??????????0??2009-03-14?02:38??Lex

-----------?---------??----------?-----??----

????????????????60622????????????????????12


評(píng)論

共有 條評(píng)論

相關(guān)資源