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

  • 大小: 1.23MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-01
  • 語言: 其他
  • 標簽: IF-ELSE??LL(1)法??

資源簡介

IF-ELSE條件語句的翻譯程序設計(LL(1)法、輸出三地址表示)

資源截圖

代碼片段和文件信息

#include“xiaohu.h“
#include
#include
#include
#include
using?namespace?std;
LinearList?list;//用來存放讀取的輸入字符串
//remainString用來存放剩余輸入串,baseString用來存放原始字符串,并且是把分隔符去掉的,middleList用來處理三地址式時的中間鏈表
LinearList?remainStringbaseStringmiddleList;
//keyWordList存放關鍵字,separList存放分隔符,operaList存放運算符,variableList存放變量
LinearList?keyWordListseparListoperaListvariableList;
//grammarList用來存放分析棧的內容,這里用鏈表來代替棧來執行操作
LinearList?grammarList;
ofstream?*fout1=new?ofstream(“analysis.txt“);
ofstream?*fout2=new?ofstream(“words.txt“);
ofstream?*fout3=new?ofstream(“threeAdd.txt“);
//if-else文法
/*--------------------------------------------------------*/
/*
1:E--if?A?then?S?else?W
2:A--aB??3:A--(A)?4:?A--notA
5:B--+TB??6:B--?-TB???7:B--?*TB???8:B-/TB
9:B--TB??11:B--==TB??12:B-->=TB?13:B--<=TB
14:B--orTB?15:B--andTB
16:B--e?????//推導出空
17:T--a
18:S--a:=a+a;
19:W--a:=a*a;
*/
/*-------------------------------------------------------*/
//預測分析表
//1-19:所用推導式的序號?0:沒有推到公式?-1:推導出空
/*
???a??+??-??*??/??(??)??>??=??==??not??or??and??if??#
E??0??0??0??0??0??0??0??0??0???0??0???0???0?????0???0????1??0
A??2??0??0??0??0??3??0??0??0???0??0???0???4?????0???0????0??0
B??0??5??6??7??8??0?-1??10?9???13?12??11??0?????14??15???0??-1
T??17?0??0??0??0??0??0??0??0???0??0???0???0?????0???0????0??0??
S??18?0??0??0??0??0??0??0??0???0??0???0???0?????0???0????0??0
W??19?0??0??0??0??0??0??0??0???0??0???0???0?????0???0????0??0
*/
//把字符串轉換成字符指針,用于字符串比較
char?*?stringToCharP(string?s)
{
const?char?*c=s.c_str();
char?*copy=new?char[strlen(c)+1];
strcpy(copyc);
return?copy;
}
//詞法分析
//把字符轉換成字符串,對單詞處理時,把單詞都當成字符串
string?toString(char?c)
{
char?str[2]={c‘\0‘};
return?str;
}
//把字符串和數字連接起來,輸出三地址格式時用來控制地址,例如T1
string?merge(string?sint?no)
{
char?num=no+‘0‘;
char?str[2]={num‘\0‘};
s+=str;
return?s;
}
//判斷是否是分隔符
bool?isSeparator(char?c)
{
char?divide[]={‘‘‘;‘‘.‘‘(‘‘)‘‘{‘‘}‘};
for(int?i=0;i<7;i++)
if(c==divide[i])?return?true;
return?false;
}
//判斷是否是變量的組成元素
bool?isVariable(char?c)
{
if((c>=‘A‘&&c<=‘Z‘)||(c>=‘a‘&&c<=‘z‘)||(c>=‘0‘&&c<=‘9‘)||c==‘_‘)
return?true;
else?return?false;
}
//判斷是否是關鍵字,直接匹配
bool?isKeyWord(char?*c)
{
char?*keyWord[6]={“if““then““or““not““and““else“};
for(int?i=0;i<6;i++)
{
if(strcmp(ckeyWord[i])==0) return?true;
}
return?false;
}
//判斷是否是運算符的組成元素
bool?isOperator(char?c)
{
char?oElement[]={‘+‘‘-‘‘*‘‘/‘‘:‘‘=‘‘#‘‘>‘‘<‘};
for(int?i=0;i<9;i++)
if(c==oElement[i])?return?true;
return?false;
}
void?Lexical()
{
string?s;
//從ifelse.txt文件中讀取語句,進行詞法分析
ifstream?fin(“ifelse.txt“);
if(!fin)
{
cout<<“Can‘t?open?the?source?file!“< return;
}
while(getline(fins))
{
list.add(s);//把每一行語句加入到list鏈表中,然后對每行語句進行詞法分析
}
linkNode?*head=list.getFirst();
while(head!=NULL)
{
string?oneline=head->data;
for(int?i=0;i {
//

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

?????文件????1207296??2010-01-08?12:32??xiaohu2\xiaohu.ncb

?????文件????????872??2010-01-08?12:09??xiaohu2\xiaohu.sln

?????文件????????901??2010-01-08?08:51??xiaohu2\xiaohu.sln.old

????..A..H.?????11776??2010-01-08?12:32??xiaohu2\xiaohu.suo

????..A..H.??????9216??2010-01-08?11:00??xiaohu2\xiaohu.suo.old

?????文件???????4230??2010-01-08?12:09??xiaohu2\xiaohu.vcproj

?????文件???????3407??2010-01-08?08:55??xiaohu2\xiaohu.vcproj.7.10.old

?????文件???????1427??2010-01-08?12:32??xiaohu2\xiaohu.vcproj.XSIT-53C3F15323.xsit.user

?????文件???????7294??2010-01-08?12:32??xiaohu2\Debug\BuildLog.htm

?????文件?????????67??2010-01-08?12:32??xiaohu2\Debug\mt.dep

?????文件?????125952??2010-01-08?10:54??xiaohu2\Debug\vc70.idb

?????文件?????135168??2010-01-08?10:54??xiaohu2\Debug\vc70.pdb

?????文件?????183296??2010-01-08?12:32??xiaohu2\Debug\vc90.idb

?????文件?????200704??2010-01-08?12:32??xiaohu2\Debug\vc90.pdb

?????文件?????511488??2010-01-08?12:32??xiaohu2\Debug\xiaohu.exe

?????文件????????406??2010-01-08?12:10??xiaohu2\Debug\xiaohu.exe.embed.manifest

?????文件????????472??2010-01-08?12:10??xiaohu2\Debug\xiaohu.exe.embed.manifest.res

?????文件????????381??2010-01-08?12:32??xiaohu2\Debug\xiaohu.exe.intermediate.manifest

?????文件?????868676??2010-01-08?12:32??xiaohu2\Debug\xiaohu.ilk

?????文件?????570613??2010-01-08?12:32??xiaohu2\Debug\xiaohu.obj

?????文件????2870272??2010-01-08?12:32??xiaohu2\Debug\xiaohu.pdb

?????文件???????2170??2010-01-08?12:32??xiaohu2\文件文檔\analysis.txt

?????文件?????????47??2010-01-08?10:52??xiaohu2\文件文檔\ifelse.txt

?????文件????????289??2010-01-08?12:32??xiaohu2\文件文檔\words.txt

?????文件????????137??2010-01-08?12:32??xiaohu2\文件文檔\threeAdd.txt

?????文件??????15166??2010-01-08?12:32??xiaohu2\源代碼\xiaohu.cpp

?????文件???????3343??2010-01-08?09:03??xiaohu2\源代碼\xiaohu.h

?????目錄??????????0??2010-01-08?12:33??xiaohu2\Debug

?????目錄??????????0??2010-01-10?20:26??xiaohu2\文件文檔

?????目錄??????????0??2010-01-10?20:27??xiaohu2\源代碼

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

評論

共有 條評論