資源簡介
編譯原理課設,小型編譯器。支持將C語言代碼轉化成中間代碼輸出,以及匯編代碼輸出。
代碼片段和文件信息
#include?
#include?“code_gen.h“
??const?char*?printf_str?=?“printf“;
??const?char*?scanf_str??=?“scanf“;
??const?char*?gets_str???=?“gets“;
//?Emiting?an?intermediate?instruction?as?a?comment?before?the?its?translation
//?to?assembler?code.
void?CodeGenerator::EmitComment(std::string?comment)?{
??//assembler_code.push_back(str_helper::FormatString(“\t%s“?comment.c_str()));
??//?Remove?the?tab?character?at?the?begining?of?the?intermediate?instruction
??comment.erase(0?1);
??//?Remove?the?new?line?character?at?the?end?of?the?intermediate?instruction
??comment.erase(comment.length()?-?1?1);
??std::stringstream?s;
??s?<“\t;“?<??assembler_code_.push_back(s.str());
}
void?CodeGenerator::EmitLabel(const?std::string&?label)?{
??std::st
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????215??2013-12-29?22:37??comp\ba
?????文件????2342801??2013-12-30?11:03??comp\bin\Debug\comp.exe
?????文件???????1149??2013-12-29?22:31??comp\ccomp.h
?????文件??????14578??2013-12-30?11:03??comp\code_gen.cpp
?????文件???????1509??2013-12-29?22:32??comp\code_gen.h
?????文件???????1524??2013-12-29?23:13??comp\comp.cbp
?????文件???????1768??2013-12-30?11:32??comp\comp.depend
?????文件???????1717??2014-01-04?14:26??comp\comp.layout
?????文件???????7833??2013-12-29?22:32??comp\intermediate.cpp
?????文件???????4840??2013-12-29?22:33??comp\intermediate.h
?????文件???????6780??2013-12-29?22:33??comp\lexer.cpp
?????文件???????1764??2013-12-29?22:33??comp\lexer.h
?????文件???????2308??2013-12-29?23:13??comp\main.cpp
?????文件?????178799??2013-12-30?11:03??comp\obj\Debug\code_gen.o
?????文件?????115895??2013-12-29?23:10??comp\obj\Debug\intermediate.o
?????文件?????240296??2013-12-29?23:10??comp\obj\Debug\lexer.o
?????文件?????209919??2013-12-29?23:13??comp\obj\Debug\main.o
?????文件?????707141??2013-12-29?23:12??comp\obj\Debug\parser.o
?????文件??????24702??2013-12-29?22:37??comp\obj\Debug\str_helper.o
?????文件?????375135??2013-12-29?23:11??comp\obj\Debug\symbol_table.o
?????文件????????500??2013-12-29?22:39??comp\obj\Debug\test.o
?????文件??????32463??2013-12-29?23:12??comp\parser.cpp
?????文件???????3670??2013-12-29?22:34??comp\parser.h
?????文件???????1109??2013-12-29?22:35??comp\str_helper.cpp
?????文件????????577??2013-12-29?22:35??comp\str_helper.h
?????文件???????3941??2013-12-29?22:36??comp\symbol_table.cpp
?????文件???????7574??2013-12-29?23:10??comp\symbol_table.h
?????文件?????????89??2013-01-02?00:03??comp\test\1-char.c
?????文件?????????74??2014-01-04?13:57??comp\test\1-char.intermediate
?????文件????????465??2014-01-04?13:57??comp\test\1-char.s
............此處省略37個文件信息
評論
共有 條評論