資源簡介
一個能編譯運行大部分C0語句的編譯器。北航大三上編譯原理課設作業,最終得分88。有充足的注釋說明,供需要的同學參考(切勿抄襲哦~)。

代碼片段和文件信息
//
//?Created?by?Andy?on?2017/11/22.
//
#include?“main.h“
bool?errorFlag?=?false;
string?errorMessages[]?=?{
????“Number?starts?with?zero.“
????“Number?too?large?or?too?long.“
????“!?without?=?backward.“
????“Empty?character.“
????“Illegal?character?between?‘‘.“
????“Character?more?than?one?or?‘?lost.“
????“Illegal?character?inside?string.“
????“String?longer?than?50.“
????“Unknown?word.“
????“Sign?before?zero.“
????“Number?error.“
????“Not?a?variable?or?function.“
????“Identifier?repeatedly?define.“
????“Char?const?error.“
????“Const?definition?type?error“
????“Array?index?error.“
????“Definition?head?error.“
????“Identifier?not?define.“
????“Invalid?factor.“
????“Identifier?kind?not?match.“
????“Step?length?couldn‘t?be?0.“
????“Case?element?not?a?constant.“
????“Parameter?count?exceeds.“
????“Illegal?type.“
????“Printf?symbol?lost.“
????“Scanf?symbol?lost.“
????“Return?symbol?lost.“
????“Default?symbol?lost.“
????“Colon?lost.“
????“Case?symbol?lost.“
????“Switch?symbol?lost.“
????“Plus?or?minus?lost.“
????“For?symbol?lost.“
????“If?symbol?lost.“
????“Becomes?symbol?lost.“
????“Void?symbol?lost.“
????“Left?brace?lost.“
????“Right?brace?lost.“
????“Left?parenthesis?lost.“
????“Right?parenthesis?lost.“
????“Right?bracket?lost.“
????“Identifier?lost.“
????“Semicolon?lost.“
????“Assignment?symbol?lost.“
????“Type?definition?lost.“
????“Step?length?lost“
????“Statement?error“
????“Illegal?syntax.“
};
string?warningMessage[]?=?{
????“Type?conflicts.“?//?0
};
bool?skipFlag?=?false;
bool?inNexts(symbol?nexts[]?symbol?tempSy)?{
????for?(int?i?=?0;?i?????????if?(nexts[i]?==?tempSy)?{
????????????return?true;
????????}
????}
????return?false;
}
void?error(int?errorNum)?{
????static?int?currentLine?=?-1;
????if?(currentLine?!=?linePtr)?{?//?Error?in?a?new?line?accepted
????????currentLine?=?linePtr;
????????if?(!errorFlag)?{?//?Used?to?avoid?mips?code?generation
????????????errorFlag?=?true;
????????}
????????cout?<“[Line?“<????}
}
void?skipUntil(symbol?nexts[])?{
????while?(!inNexts(nexts?sy))?{
????????insymbol();
????}
????skipFlag?=?true;
}
void?warn(int?warnNum)?{
????cout?<“[Line?“<}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-03-11?15:21??C0_Compiler-master\
?????文件??????????49??2018-03-11?15:21??C0_Compiler-master\.gitignore
?????文件?????????523??2018-03-11?15:21??C0_Compiler-master\README.md
?????文件????????2343??2018-03-11?15:21??C0_Compiler-master\error&warn.cpp
?????文件????????6521??2018-03-11?15:21??C0_Compiler-master\idTable.cpp
?????文件????????4505??2018-03-11?15:21??C0_Compiler-master\infixNotation.cpp
?????文件???????24003??2018-03-11?15:21??C0_Compiler-master\infixOpt.cpp
?????文件????????7082??2018-03-11?15:21??C0_Compiler-master\lexical.cpp
?????文件????????2254??2018-03-11?15:21??C0_Compiler-master\main.cpp
?????文件????????5666??2018-03-11?15:21??C0_Compiler-master\main.h
?????文件???????56725??2018-03-11?15:21??C0_Compiler-master\parser.cpp
?????文件???????21335??2018-03-11?15:21??C0_Compiler-master\target.cpp
?????文件???????27273??2018-03-11?15:21??C0_Compiler-master\targetOpt.cpp
?????文件?????????325??2018-03-11?15:21??C0_Compiler-master\tools.cpp
?????文件?????????419??2018-03-11?15:21??C0_Compiler-master\tools.h
- 上一篇:cdslmd.exe
- 下一篇:miniImagenet 數據集 百度云 鏈接
評論
共有 條評論