資源簡介
編譯原理上機實習源代碼。 題目:C語言小子集編譯程序的實現 3、實現功能: (1)詞法分析 掃描源程序,根據詞法規則,識別單詞,填寫相應的符號表。 (2)語法分析 對由源程序作語法分析,確定是否屬于C語言小子集,同時揭示出程序的內在結構。 (3)語法錯誤檢查 根據C語言小子集的文法規則設置檢測手段,通過查錯子程序或一些查錯語句,報告源程序出錯位置、性質等,直至整個程序結束為止。 (4)語義分析與目標代碼生成 在語法分析的基礎上,進行語義分析,生成輸入源程序的目標代碼。輸入源程序的目標代碼可以建立在一個假想的處理機(虛擬機)上,也可
代碼片段和文件信息
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
using?namespace?std;
string?file_name;
string?GetText();
string?GetWord(string?strint?iint&?j);?
int?DeleteNull(string?strint?i);
bool?IsBoundary(string?strint?i);?
bool?IsOperation(string?strint?i);?
void?Print(vector?>?v);?
vector?>?analyst(vector?vec);
bool?IsKey(string?str);
int?main()
{
????cout<<“******************************\n“;
????cout<<“**********詞法分析器**********\n“;
cout<<“******************************\n“;
????string?com1=“?“;
????string?com2=“\n“;?
????string?fileline=GetText();
????int?begin=0end=0;
????vector?array;
????do
????{
????????b
評論
共有 條評論