├── compile ├── .gitignore ├── .idea │ ├── .gitignore │ ├── artifacts │ │ └── compile_jar.xml │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── junitgenerator-prj-settings.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── Compiler │ ├── .idea │ │ ├── .gitignore │ │ ├── checkstyle-idea.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Lexical_analysis.iml │ └── src │ │ ├── AST │ │ ├── And.java │ │ ├── Arith.java │ │ ├── Array.java │ │ ├── Assign.java │ │ ├── Block.java │ │ ├── BlockItem.java │ │ ├── Break.java │ │ ├── ConstDef.java │ │ ├── Constant.java │ │ ├── Continue.java │ │ ├── Decl.java │ │ ├── Def.java │ │ ├── Expr.java │ │ ├── Fparam.java │ │ ├── Func.java │ │ ├── FuncR.java │ │ ├── Id.java │ │ ├── If.java │ │ ├── Logical.java │ │ ├── Lval.java │ │ ├── Node.java │ │ ├── Or.java │ │ ├── Print.java │ │ ├── Program.java │ │ ├── Ret.java │ │ ├── Scanf.java │ │ ├── Stmt.java │ │ ├── Temp.java │ │ ├── Unary.java │ │ ├── VarDef.java │ │ └── While.java │ │ ├── Compiler.java │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── Midcode │ │ └── midCode.java │ │ ├── Mipscode │ │ ├── Mips.java │ │ └── Mipscode.java │ │ ├── Optim │ │ ├── Optimize.java │ │ └── Register.java │ │ ├── Parsing_error.java │ │ ├── Parsing_mid.java │ │ ├── Sym.java │ │ ├── Symbol_table │ │ ├── FuncTable.java │ │ ├── IntergerTable.java │ │ └── Symbols │ │ │ ├── ArraySymbol.java │ │ │ ├── FuncSymbol.java │ │ │ ├── NorSymbol.java │ │ │ └── VarSymbol.java │ │ └── Word │ │ ├── FormatWord.java │ │ └── Word.java ├── compile.iml ├── error.txt ├── mips.txt ├── optimize.txt ├── out │ └── production │ │ └── compile │ │ └── META-INF │ │ └── MANIFEST.MF ├── output.txt └── testfile.txt ├── compile_优化前 ├── .gitignore ├── .idea │ ├── .gitignore │ ├── checkstyle-idea.xml │ ├── compiler.xml │ ├── junitgenerator-prj-settings.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ ├── uiDesigner.xml │ └── vcs.xml ├── Lexical_analysis │ ├── .idea │ │ ├── .gitignore │ │ ├── checkstyle-idea.xml │ │ ├── misc.xml │ │ └── modules.xml │ ├── Lexical_analysis.iml │ └── src │ │ ├── AST │ │ ├── And.java │ │ ├── Arith.java │ │ ├── Array.java │ │ ├── Assign.java │ │ ├── Block.java │ │ ├── BlockItem.java │ │ ├── Break.java │ │ ├── ConstDef.java │ │ ├── Constant.java │ │ ├── Continue.java │ │ ├── Decl.java │ │ ├── Def.java │ │ ├── Expr.java │ │ ├── Fparam.java │ │ ├── Func.java │ │ ├── FuncR.java │ │ ├── Id.java │ │ ├── If.java │ │ ├── Logical.java │ │ ├── Lval.java │ │ ├── Node.java │ │ ├── Or.java │ │ ├── Print.java │ │ ├── Program.java │ │ ├── Ret.java │ │ ├── Scanf.java │ │ ├── Stmt.java │ │ ├── Temp.java │ │ ├── Unary.java │ │ ├── VarDef.java │ │ └── While.java │ │ ├── Compiler.java │ │ ├── Midcode │ │ └── midCode.java │ │ ├── Mipscode │ │ ├── Mips.java │ │ └── Mipscode.java │ │ ├── Parsing.java │ │ ├── Parsingtemp.java │ │ ├── Sym.java │ │ ├── Symbol_table │ │ ├── FuncTable.java │ │ ├── IntergerTable.java │ │ └── Symbols │ │ │ ├── ArraySymbol.java │ │ │ ├── FuncSymbol.java │ │ │ ├── NorSymbol.java │ │ │ └── VarSymbol.java │ │ └── Word │ │ ├── FormatWord.java │ │ └── Word.java ├── compile.iml ├── error.txt ├── mips.txt ├── optimize.txt ├── output.txt └── testfile.txt ├── img ├── 1.png ├── 2.png ├── 3.png └── 4.png ├── mars.jar ├── readme.md ├── test_compile ├── .idea │ ├── .gitignore │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── test.iml ├── InstructionStatistics.txt ├── answer.txt ├── answer_temp.txt ├── compile.jar ├── header.txt ├── input.txt ├── judge_for_outputfile.py ├── mars.jar ├── mips.txt ├── optimize.txt ├── output.txt ├── output │ ├── A │ │ ├── output1.txt │ │ ├── output10.txt │ │ ├── output11.txt │ │ ├── output12.txt │ │ ├── output13.txt │ │ ├── output14.txt │ │ ├── output15.txt │ │ ├── output16.txt │ │ ├── output17.txt │ │ ├── output18.txt │ │ ├── output19.txt │ │ ├── output2.txt │ │ ├── output20.txt │ │ ├── output21.txt │ │ ├── output22.txt │ │ ├── output23.txt │ │ ├── output24.txt │ │ ├── output25.txt │ │ ├── output26.txt │ │ ├── output27.txt │ │ ├── output28.txt │ │ ├── output29.txt │ │ ├── output3.txt │ │ ├── output30.txt │ │ ├── output4.txt │ │ ├── output5.txt │ │ ├── output6.txt │ │ ├── output7.txt │ │ ├── output8.txt │ │ └── output9.txt │ ├── B │ │ ├── output1.txt │ │ ├── output10.txt │ │ ├── output11.txt │ │ ├── output12.txt │ │ ├── output13.txt │ │ ├── output14.txt │ │ ├── output15.txt │ │ ├── output16.txt │ │ ├── output17.txt │ │ ├── output18.txt │ │ ├── output19.txt │ │ ├── output2.txt │ │ ├── output20.txt │ │ ├── output21.txt │ │ ├── output22.txt │ │ ├── output23.txt │ │ ├── output24.txt │ │ ├── output25.txt │ │ ├── output26.txt │ │ ├── output27.txt │ │ ├── output28.txt │ │ ├── output29.txt │ │ ├── output3.txt │ │ ├── output30.txt │ │ ├── output4.txt │ │ ├── output5.txt │ │ ├── output6.txt │ │ ├── output7.txt │ │ ├── output8.txt │ │ └── output9.txt │ ├── C │ │ ├── output1.txt │ │ ├── output10.txt │ │ ├── output11.txt │ │ ├── output12.txt │ │ ├── output13.txt │ │ ├── output14.txt │ │ ├── output15.txt │ │ ├── output16.txt │ │ ├── output17.txt │ │ ├── output18.txt │ │ ├── output19.txt │ │ ├── output2.txt │ │ ├── output20.txt │ │ ├── output21.txt │ │ ├── output22.txt │ │ ├── output23.txt │ │ ├── output24.txt │ │ ├── output25.txt │ │ ├── output26.txt │ │ ├── output27.txt │ │ ├── output28.txt │ │ ├── output29.txt │ │ ├── output3.txt │ │ ├── output30.txt │ │ ├── output4.txt │ │ ├── output5.txt │ │ ├── output6.txt │ │ ├── output7.txt │ │ ├── output8.txt │ │ └── output9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output13.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output27.txt │ ├── output28.txt │ ├── output29.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output7.txt │ ├── output8.txt │ └── output9.txt ├── res.txt ├── testfile.txt └── testfiles │ ├── .DS_Store │ ├── A │ ├── input1.txt │ ├── input10.txt │ ├── input11.txt │ ├── input12.txt │ ├── input13.txt │ ├── input14.txt │ ├── input15.txt │ ├── input16.txt │ ├── input17.txt │ ├── input18.txt │ ├── input19.txt │ ├── input2.txt │ ├── input20.txt │ ├── input21.txt │ ├── input22.txt │ ├── input23.txt │ ├── input24.txt │ ├── input25.txt │ ├── input26.txt │ ├── input3.txt │ ├── input4.txt │ ├── input5.txt │ ├── input6.txt │ ├── input8.txt │ ├── input9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output13.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output8.txt │ ├── output9.txt │ ├── testfile1.txt │ ├── testfile10.txt │ ├── testfile11.txt │ ├── testfile12.txt │ ├── testfile13.txt │ ├── testfile14.txt │ ├── testfile15.txt │ ├── testfile16.txt │ ├── testfile17.txt │ ├── testfile18.txt │ ├── testfile19.txt │ ├── testfile2.txt │ ├── testfile20.txt │ ├── testfile21.txt │ ├── testfile22.txt │ ├── testfile23.txt │ ├── testfile24.txt │ ├── testfile25.txt │ ├── testfile26.txt │ ├── testfile3.txt │ ├── testfile4.txt │ ├── testfile5.txt │ ├── testfile6.txt │ ├── testfile8.txt │ └── testfile9.txt │ ├── B │ ├── input1.txt │ ├── input10.txt │ ├── input11.txt │ ├── input12.txt │ ├── input14.txt │ ├── input15.txt │ ├── input16.txt │ ├── input17.txt │ ├── input18.txt │ ├── input19.txt │ ├── input2.txt │ ├── input20.txt │ ├── input21.txt │ ├── input22.txt │ ├── input23.txt │ ├── input24.txt │ ├── input25.txt │ ├── input26.txt │ ├── input27.txt │ ├── input3.txt │ ├── input4.txt │ ├── input5.txt │ ├── input6.txt │ ├── input7.txt │ ├── input8.txt │ ├── input9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output27.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output7.txt │ ├── output8.txt │ ├── output9.txt │ ├── testfile1.txt │ ├── testfile10.txt │ ├── testfile11.txt │ ├── testfile12.txt │ ├── testfile14.txt │ ├── testfile15.txt │ ├── testfile16.txt │ ├── testfile17.txt │ ├── testfile18.txt │ ├── testfile19.txt │ ├── testfile2.txt │ ├── testfile20.txt │ ├── testfile21.txt │ ├── testfile22.txt │ ├── testfile23.txt │ ├── testfile24.txt │ ├── testfile25.txt │ ├── testfile26.txt │ ├── testfile27.txt │ ├── testfile3.txt │ ├── testfile4.txt │ ├── testfile5.txt │ ├── testfile6.txt │ ├── testfile7.txt │ ├── testfile8.txt │ └── testfile9.txt │ └── C │ ├── input1.txt │ ├── input10.txt │ ├── input11.txt │ ├── input12.txt │ ├── input13.txt │ ├── input14.txt │ ├── input15.txt │ ├── input16.txt │ ├── input17.txt │ ├── input18.txt │ ├── input19.txt │ ├── input2.txt │ ├── input20.txt │ ├── input21.txt │ ├── input22.txt │ ├── input23.txt │ ├── input24.txt │ ├── input25.txt │ ├── input26.txt │ ├── input27.txt │ ├── input28.txt │ ├── input29.txt │ ├── input3.txt │ ├── input4.txt │ ├── input5.txt │ ├── input6.txt │ ├── input7.txt │ ├── input8.txt │ ├── input9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output13.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output27.txt │ ├── output28.txt │ ├── output29.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output7.txt │ ├── output8.txt │ ├── output9.txt │ ├── testfile1.txt │ ├── testfile10.txt │ ├── testfile11.txt │ ├── testfile12.txt │ ├── testfile13.txt │ ├── testfile14.txt │ ├── testfile15.txt │ ├── testfile16.txt │ ├── testfile17.txt │ ├── testfile18.txt │ ├── testfile19.txt │ ├── testfile2.txt │ ├── testfile20.txt │ ├── testfile21.txt │ ├── testfile22.txt │ ├── testfile23.txt │ ├── testfile24.txt │ ├── testfile25.txt │ ├── testfile26.txt │ ├── testfile27.txt │ ├── testfile28.txt │ ├── testfile29.txt │ ├── testfile3.txt │ ├── testfile4.txt │ ├── testfile5.txt │ ├── testfile6.txt │ ├── testfile7.txt │ ├── testfile8.txt │ └── testfile9.txt └── 文档 ├── 《编译技术》课程设计总结文档.md ├── 《编译技术》课程设计总结文档.pdf ├── 代码生成测试样例库 └── testfiles │ ├── .DS_Store │ ├── A │ ├── input1.txt │ ├── input10.txt │ ├── input11.txt │ ├── input12.txt │ ├── input13.txt │ ├── input14.txt │ ├── input15.txt │ ├── input16.txt │ ├── input17.txt │ ├── input18.txt │ ├── input19.txt │ ├── input2.txt │ ├── input20.txt │ ├── input21.txt │ ├── input22.txt │ ├── input23.txt │ ├── input24.txt │ ├── input25.txt │ ├── input26.txt │ ├── input3.txt │ ├── input4.txt │ ├── input5.txt │ ├── input6.txt │ ├── input7.txt │ ├── input8.txt │ ├── input9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output13.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output7.txt │ ├── output8.txt │ ├── output9.txt │ ├── testfile1.txt │ ├── testfile10.txt │ ├── testfile11.txt │ ├── testfile12.txt │ ├── testfile13.txt │ ├── testfile14.txt │ ├── testfile15.txt │ ├── testfile16.txt │ ├── testfile17.txt │ ├── testfile18.txt │ ├── testfile19.txt │ ├── testfile2.txt │ ├── testfile20.txt │ ├── testfile21.txt │ ├── testfile22.txt │ ├── testfile23.txt │ ├── testfile24.txt │ ├── testfile25.txt │ ├── testfile26.txt │ ├── testfile3.txt │ ├── testfile4.txt │ ├── testfile5.txt │ ├── testfile6.txt │ ├── testfile7.txt │ ├── testfile8.txt │ └── testfile9.txt │ ├── B │ ├── input1.txt │ ├── input10.txt │ ├── input11.txt │ ├── input12.txt │ ├── input13.txt │ ├── input14.txt │ ├── input15.txt │ ├── input16.txt │ ├── input17.txt │ ├── input18.txt │ ├── input19.txt │ ├── input2.txt │ ├── input20.txt │ ├── input21.txt │ ├── input22.txt │ ├── input23.txt │ ├── input24.txt │ ├── input25.txt │ ├── input26.txt │ ├── input27.txt │ ├── input3.txt │ ├── input4.txt │ ├── input5.txt │ ├── input6.txt │ ├── input7.txt │ ├── input8.txt │ ├── input9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output13.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output27.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output7.txt │ ├── output8.txt │ ├── output9.txt │ ├── testfile1.txt │ ├── testfile10.txt │ ├── testfile11.txt │ ├── testfile12.txt │ ├── testfile13.txt │ ├── testfile14.txt │ ├── testfile15.txt │ ├── testfile16.txt │ ├── testfile17.txt │ ├── testfile18.txt │ ├── testfile19.txt │ ├── testfile2.txt │ ├── testfile20.txt │ ├── testfile21.txt │ ├── testfile22.txt │ ├── testfile23.txt │ ├── testfile24.txt │ ├── testfile25.txt │ ├── testfile26.txt │ ├── testfile27.txt │ ├── testfile3.txt │ ├── testfile4.txt │ ├── testfile5.txt │ ├── testfile6.txt │ ├── testfile7.txt │ ├── testfile8.txt │ └── testfile9.txt │ └── C │ ├── input1.txt │ ├── input10.txt │ ├── input11.txt │ ├── input12.txt │ ├── input13.txt │ ├── input14.txt │ ├── input15.txt │ ├── input16.txt │ ├── input17.txt │ ├── input18.txt │ ├── input19.txt │ ├── input2.txt │ ├── input20.txt │ ├── input21.txt │ ├── input22.txt │ ├── input23.txt │ ├── input24.txt │ ├── input25.txt │ ├── input26.txt │ ├── input27.txt │ ├── input28.txt │ ├── input29.txt │ ├── input3.txt │ ├── input4.txt │ ├── input5.txt │ ├── input6.txt │ ├── input7.txt │ ├── input8.txt │ ├── input9.txt │ ├── output1.txt │ ├── output10.txt │ ├── output11.txt │ ├── output12.txt │ ├── output13.txt │ ├── output14.txt │ ├── output15.txt │ ├── output16.txt │ ├── output17.txt │ ├── output18.txt │ ├── output19.txt │ ├── output2.txt │ ├── output20.txt │ ├── output21.txt │ ├── output22.txt │ ├── output23.txt │ ├── output24.txt │ ├── output25.txt │ ├── output26.txt │ ├── output27.txt │ ├── output28.txt │ ├── output29.txt │ ├── output3.txt │ ├── output4.txt │ ├── output5.txt │ ├── output6.txt │ ├── output7.txt │ ├── output8.txt │ ├── output9.txt │ ├── testfile1.txt │ ├── testfile10.txt │ ├── testfile11.txt │ ├── testfile12.txt │ ├── testfile13.txt │ ├── testfile14.txt │ ├── testfile15.txt │ ├── testfile16.txt │ ├── testfile17.txt │ ├── testfile18.txt │ ├── testfile19.txt │ ├── testfile2.txt │ ├── testfile20.txt │ ├── testfile21.txt │ ├── testfile22.txt │ ├── testfile23.txt │ ├── testfile24.txt │ ├── testfile25.txt │ ├── testfile26.txt │ ├── testfile27.txt │ ├── testfile28.txt │ ├── testfile29.txt │ ├── testfile3.txt │ ├── testfile4.txt │ ├── testfile5.txt │ ├── testfile6.txt │ ├── testfile7.txt │ ├── testfile8.txt │ └── testfile9.txt └── 编译文法.pdf /compile/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* -------------------------------------------------------------------------------- /compile/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /../../../:\compile\.idea/dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /compile/.idea/artifacts/compile_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/compile_jar 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /compile/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /compile/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /compile/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /compile/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile/Compiler/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /../../../../:\compile\Lexical_analysis\.idea/dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /compile/Compiler/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /compile/Compiler/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile/Compiler/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /compile/Compiler/Lexical_analysis.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/And.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | import java.util.ArrayList; 6 | 7 | public class And extends Node { 8 | ArrayList exprs; 9 | private int jump; 10 | 11 | public And(ArrayList exprs) { 12 | this.exprs = exprs; 13 | } 14 | 15 | public void gen(int k) { 16 | for (Expr e : exprs) 17 | e.canculculate(); 18 | 19 | jump = ++jumps; 20 | for (Expr e : exprs) { 21 | emit(new midCode(midCode.operation.BZ, "Jump" + jump, e.reduce().toString())); 22 | } 23 | emit(new midCode(midCode.operation.GOTO, "Jump" + k)); 24 | emit(new midCode(midCode.operation.Jump, "Jump" + jump)); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Assign.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Assign extends Stmt { 6 | Lval lval; 7 | Expr expr; 8 | 9 | public Assign(Lval lval, Expr expr) { 10 | this.lval = lval; 11 | this.expr = expr; 12 | } 13 | 14 | @Override 15 | public void gen() { 16 | // lval.canculculate(); 17 | expr.canculculate(); 18 | 19 | if (lval instanceof Id) { 20 | emit(new midCode(midCode.operation.ASSIGNOP, lval.reduce().toString(), expr.reduce().toString())); 21 | } else { 22 | emit(new midCode(midCode.operation.PUTARRAY, lval.getcontent(), lval.toString(), expr.reduce().toString())); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Block.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Symbol_table.IntergerTable; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class Block extends Stmt { 9 | static int count = 0; 10 | ArrayList items; 11 | int num; 12 | 13 | public Block(ArrayList items) { 14 | this.items = items; 15 | } 16 | 17 | public static int getCount() { 18 | return ++count; 19 | } 20 | 21 | @Override 22 | public void gen() { 23 | 24 | inttable = new IntergerTable(inttable); 25 | num = ++count; 26 | emit(new midCode(midCode.operation.LABEL, String.valueOf(num), "start")); 27 | for (BlockItem i : items) 28 | i.gen(); 29 | emit(new midCode(midCode.operation.LABEL, String.valueOf(num), "end")); 30 | inttable = inttable.getOut(); 31 | } 32 | 33 | public void gen(int k) { 34 | num = k; 35 | for (BlockItem i : items) 36 | i.gen(); 37 | emit(new midCode(midCode.operation.RET, null)); 38 | emit(new midCode(midCode.operation.LABEL, String.valueOf(num), "end")); 39 | inttable = inttable.getOut(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/BlockItem.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | public class BlockItem extends Node { 4 | } 5 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Break.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Break extends Stmt { 6 | @Override 7 | public void gen() { 8 | int k = loopstack.peek(); 9 | emit(new midCode(midCode.operation.GOTO, "Loop" + String.valueOf(k) + "end")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Constant.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Word.Word; 4 | 5 | public class Constant extends Expr { 6 | public Constant(Word op) { 7 | super(op); 8 | } 9 | 10 | // public Constant(ArrayList midCodes, int num) { 11 | // super( new Word(String.valueOf(num))); 12 | // } 13 | 14 | @Override 15 | public int calculate() { 16 | return Integer.parseInt(op.getContent()); 17 | } 18 | 19 | @Override 20 | public boolean canculculate() { 21 | isvalue = true; 22 | value = Integer.parseInt(op.getContent()); 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Continue.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Continue extends Stmt { 6 | @Override 7 | public void gen() { 8 | int k = loopstack.peek(); 9 | emit(new midCode(midCode.operation.GOTO, "Loop" + String.valueOf(k) + "begin")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Decl.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class Decl extends BlockItem { 6 | LinkedList defs; 7 | boolean isConst; 8 | 9 | public Decl(LinkedList defs, boolean isConst) { 10 | this.defs = defs; 11 | this.isConst = isConst; 12 | } 13 | 14 | @Override 15 | public void gen() { 16 | for (Def d : defs) 17 | d.gen(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Def.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | public class Def extends Node { 4 | Lval lval; 5 | 6 | public Def(Lval lval) { 7 | this.lval = lval; 8 | } 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Expr.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Word.Word; 4 | 5 | public class Expr extends Stmt { 6 | 7 | public Word op; 8 | public int value = 0; 9 | public boolean isvalue = false; 10 | 11 | public Expr(Word op) { 12 | this.op = op; 13 | } 14 | 15 | public Expr reduce() { 16 | return this; 17 | } 18 | 19 | @Override 20 | public void gen() { 21 | //reduce(); 22 | } 23 | 24 | public boolean canculculate() { 25 | return false; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return op.toString(); 31 | } 32 | 33 | public int calculate() { 34 | return 0; 35 | } 36 | 37 | public String getcontent() { 38 | return op.getContent(); 39 | } 40 | // public Expr reduce() { 41 | // return this; 42 | // } 43 | } 44 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Fparam.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Symbol_table.Symbols.ArraySymbol; 5 | import Symbol_table.Symbols.VarSymbol; 6 | 7 | public class Fparam extends Node { 8 | Id id; 9 | int level; 10 | Expr expr; 11 | 12 | public Fparam(Id id, int level, Expr expr) { 13 | this.id = id; 14 | this.level = level; 15 | this.expr = expr; 16 | } 17 | 18 | @Override 19 | public void gen() { 20 | // id.canculculate(); 21 | // expr.canculculate(); 22 | 23 | String s = id.getcontent(); 24 | if (level == 0) { 25 | emit(new midCode(midCode.operation.PARAM, s, String.valueOf("0"))); 26 | inttable.add(s, new VarSymbol(s, false, 0)); 27 | } else if (level == 1) { 28 | emit(new midCode(midCode.operation.PARAM, s, String.valueOf("1"))); 29 | inttable.add(s, new ArraySymbol(s, false, 1)); 30 | } else { 31 | int level2 = expr.calculate(); 32 | emit(new midCode(midCode.operation.PARAM, s, String.valueOf("2"), String.valueOf(level2))); 33 | inttable.add(s, new ArraySymbol(s, false, 2, level2)); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/FuncR.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class FuncR extends Expr { 9 | ArrayList Rparas; 10 | ArrayList Rafter = new ArrayList<>(); 11 | 12 | public FuncR(Word op, ArrayList rparas) { 13 | super(op); 14 | Rparas = rparas; 15 | } 16 | 17 | @Override 18 | public Expr reduce() { 19 | for (Expr ex : Rparas) 20 | ex.canculculate(); 21 | 22 | for (Expr e : Rparas) { 23 | Rafter.add(e.reduce()); 24 | } 25 | for (Expr s : Rafter) { 26 | if (s instanceof Array) 27 | emit(new midCode(midCode.operation.PUSH, s.op.getContent(), ((Array) s).temp.toString(), ((Array) s).num2)); 28 | else 29 | emit(new midCode(midCode.operation.PUSH, s.toString())); 30 | } 31 | emit(new midCode(midCode.operation.CALL, op.getContent())); 32 | int type = funcTable.get(op.getContent()).getReturntype(); 33 | if (type == 0) 34 | return this; 35 | else { 36 | Temp t = new Temp(op); 37 | emit(new midCode(midCode.operation.RETVALUE, t.toString())); 38 | return t; 39 | } 40 | } 41 | 42 | @Override 43 | public void gen() { 44 | reduce(); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "RET"; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/If.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class If extends Stmt { 6 | Or cond; 7 | Stmt stmt1; 8 | Stmt stmt2; 9 | int jump1; 10 | int jump2; 11 | 12 | 13 | public If(Or cond, Stmt stmt1, Stmt stmt2) { 14 | this.cond = cond; 15 | this.stmt1 = stmt1; 16 | this.stmt2 = stmt2; 17 | } 18 | 19 | @Override 20 | public void gen() { //删除语句存疑,先不进行删除 21 | if (stmt2 == null) { 22 | jump1 = ++jumps; 23 | cond.gen(jump1); 24 | if (stmt1 != null) 25 | stmt1.gen(); 26 | emit(new midCode(midCode.operation.Jump, "Jump" + jump1)); 27 | } else { 28 | jump1 = ++jumps; 29 | jump2 = ++jumps; 30 | cond.gen(jump1); 31 | if (stmt1 != null) 32 | stmt1.gen(); 33 | emit(new midCode(midCode.operation.GOTO, "Jump" + jump2)); 34 | emit(new midCode(midCode.operation.Jump, "Jump" + jump1)); 35 | stmt2.gen(); 36 | emit(new midCode(midCode.operation.Jump, "Jump" + jump2)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Lval.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Word.Word; 4 | 5 | public class Lval extends Expr { 6 | public Lval(Word op) { 7 | super(op); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Node.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | 4 | import Midcode.midCode; 5 | import Symbol_table.FuncTable; 6 | import Symbol_table.IntergerTable; 7 | 8 | import java.util.ArrayList; 9 | import java.util.LinkedList; 10 | import java.util.Stack; 11 | 12 | public class Node { 13 | public static ArrayList midCodes = new ArrayList<>(); 14 | public static IntergerTable inttable = new IntergerTable(); 15 | public static FuncTable funcTable = new FuncTable(); 16 | public static LinkedList stringss = new LinkedList<>(); 17 | static int labels = 0; 18 | static int jumps = 0; 19 | static Stack loopstack = new Stack<>(); 20 | 21 | public static ArrayList getMidCodes() { 22 | return midCodes; 23 | } 24 | 25 | public static LinkedList getStringss() { 26 | return stringss; 27 | } 28 | 29 | public int newlabel() { 30 | return ++labels; 31 | } 32 | 33 | public void emitlabel(int i) { 34 | midCodes.add(new midCode(midCode.operation.LABEL, String.valueOf(i))); 35 | } 36 | 37 | public void emit(midCode code) { 38 | midCodes.add(code); 39 | } 40 | 41 | public void gen() { 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Or.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | public class Or extends Node { 9 | List ands = new ArrayList<>(); 10 | private int jump; 11 | 12 | public Or(ArrayList ands) { 13 | this.ands = ands; 14 | } 15 | 16 | public void gen(int k) { 17 | jump = ++jumps; 18 | for (And and : ands) { 19 | and.gen(jump); 20 | } 21 | emit(new midCode(midCode.operation.GOTO, "Jump" + k)); 22 | emit(new midCode(midCode.operation.Jump, "Jump" + jump)); 23 | } 24 | 25 | public void gen(int k, boolean whi) { 26 | jump = ++jumps; 27 | for (And and : ands) { 28 | and.gen(jump); 29 | } 30 | emit(new midCode(midCode.operation.GOTO, "Loop" + String.valueOf(k) + "end")); 31 | emit(new midCode(midCode.operation.Jump, "Jump" + jump)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Program.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class Program extends Node { 6 | LinkedList decls = new LinkedList<>(); 7 | LinkedList funcs = new LinkedList<>(); 8 | 9 | public Program(LinkedList decls, LinkedList funcs) { 10 | this.decls = decls; 11 | this.funcs = funcs; 12 | } 13 | 14 | public void gen() { 15 | for (Decl d : decls) { 16 | d.gen(); 17 | } 18 | for (Func f : funcs) { 19 | f.gen(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Ret.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Ret extends Stmt { 6 | Expr expr; 7 | 8 | public Ret(Expr expr) { 9 | this.expr = expr; 10 | } 11 | 12 | @Override 13 | public void gen() { 14 | if (expr != null) 15 | expr.canculculate(); 16 | if (expr == null) { 17 | emit(new midCode(midCode.operation.RET, null)); 18 | } else { 19 | emit(new midCode(midCode.operation.RET, expr.reduce().toString())); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Scanf.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Scanf extends Stmt { 6 | Lval lval; 7 | 8 | public Scanf(Lval lval) { 9 | this.lval = lval; 10 | } 11 | 12 | @Override 13 | public void gen() { 14 | // emit(new midCode(midCode.operation.SCAN,lval.reduce().toString())); 15 | if (lval instanceof Id) { 16 | emit(new midCode(midCode.operation.SCAN, lval.reduce().toString())); 17 | } else { 18 | Temp temp = new Temp(null); 19 | emit(new midCode(midCode.operation.SCAN, temp.toString())); 20 | emit(new midCode(midCode.operation.PUTARRAY, lval.getcontent(), lval.toString(), temp.toString())); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Stmt.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | public class Stmt extends BlockItem { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/Temp.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Word.Word; 4 | 5 | public class Temp extends Expr { 6 | 7 | private static int count = 0; 8 | private int number = 0; 9 | 10 | public Temp(Word op) { 11 | super(op); 12 | this.number = ++count; 13 | } 14 | 15 | 16 | public String toString() { 17 | return "t&" + number; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /compile/Compiler/src/AST/While.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class While extends Stmt { 6 | Or Cond; 7 | Stmt stmt; 8 | int jump; 9 | 10 | public While(Or cond, Stmt stmt) { 11 | Cond = cond; 12 | this.stmt = stmt; 13 | } 14 | 15 | @Override 16 | public void gen() { 17 | jump = ++jumps; 18 | loopstack.push(jump); 19 | emit(new midCode(midCode.operation.Jump, "Loop" + jump + "begin")); 20 | Cond.gen(jump, true); 21 | if (stmt != null) 22 | stmt.gen(); 23 | emit(new midCode(midCode.operation.GOTO, "Loop" + String.valueOf(jump) + "begin")); 24 | emit(new midCode(midCode.operation.Jump, "Loop" + String.valueOf(jump) + "end")); 25 | loopstack.pop(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /compile/Compiler/src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: Compiler 3 | 4 | -------------------------------------------------------------------------------- /compile/Compiler/src/Symbol_table/FuncTable.java: -------------------------------------------------------------------------------- 1 | package Symbol_table; 2 | 3 | import Symbol_table.Symbols.FuncSymbol; 4 | 5 | import java.util.HashMap; 6 | 7 | public class FuncTable { 8 | private HashMap maps = new HashMap<>(); 9 | private FuncTable out; 10 | 11 | public FuncTable() { 12 | } 13 | 14 | public HashMap getMaps() { 15 | return maps; 16 | } 17 | 18 | public FuncTable getOut() { 19 | return out; 20 | } 21 | 22 | public void add(String s, FuncSymbol symbol) { 23 | maps.put(s, symbol); 24 | } 25 | 26 | public FuncSymbol get(String s) { 27 | return maps.get(s); 28 | } 29 | 30 | public boolean contains(String s) { 31 | return maps.containsKey(s); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /compile/Compiler/src/Symbol_table/IntergerTable.java: -------------------------------------------------------------------------------- 1 | package Symbol_table; 2 | 3 | import Symbol_table.Symbols.NorSymbol; 4 | 5 | import java.util.HashMap; 6 | 7 | public class IntergerTable { 8 | private HashMap maps = new HashMap<>(); 9 | private IntergerTable out = null; 10 | private int contentlength = 0; 11 | 12 | public IntergerTable() { 13 | 14 | } 15 | 16 | public IntergerTable(IntergerTable out) { 17 | this.out = out; 18 | } 19 | 20 | public void addlength(int len) { 21 | contentlength += len; 22 | } 23 | 24 | public int getContentlength() { 25 | return contentlength; 26 | } 27 | 28 | public HashMap getMaps() { 29 | return maps; 30 | } 31 | 32 | public IntergerTable getOut() { 33 | return out; 34 | } 35 | 36 | public void setOut(IntergerTable out) { 37 | this.out = out; 38 | } 39 | 40 | public void add(String s, NorSymbol symbol) { 41 | maps.put(s, symbol); 42 | } 43 | 44 | public boolean contains(String s) { 45 | return maps.containsKey(s); 46 | } 47 | 48 | public NorSymbol get(String s) { 49 | return maps.get(s); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /compile/Compiler/src/Symbol_table/Symbols/FuncSymbol.java: -------------------------------------------------------------------------------- 1 | package Symbol_table.Symbols; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class FuncSymbol { 6 | private String name; 7 | private ArrayList params; 8 | private int returntype; //0=void 1=int 9 | 10 | public FuncSymbol(String name, ArrayList params, int returntype) { 11 | this.name = name; 12 | this.params = params; 13 | this.returntype = returntype; 14 | } 15 | 16 | public FuncSymbol(int returntype) { 17 | this.returntype = returntype; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public ArrayList getParams() { 25 | return params; 26 | } 27 | 28 | public int getReturntype() { 29 | return returntype; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /compile/Compiler/src/Symbol_table/Symbols/VarSymbol.java: -------------------------------------------------------------------------------- 1 | package Symbol_table.Symbols; 2 | 3 | public class VarSymbol extends NorSymbol { 4 | private int value; 5 | 6 | public VarSymbol(String name, boolean isConst, int value) { 7 | super(name, isConst); 8 | this.value = value; 9 | } 10 | 11 | public VarSymbol(String name, boolean isConst) { 12 | super(name, isConst); 13 | } 14 | 15 | public VarSymbol(String name, int offset) { 16 | super(name, offset); 17 | } 18 | 19 | public int getValue() { 20 | return value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /compile/Compiler/src/Word/FormatWord.java: -------------------------------------------------------------------------------- 1 | package Word; 2 | 3 | public class FormatWord extends Word { 4 | private int num; 5 | private boolean correct; 6 | 7 | public FormatWord(int symnumber, String content, int line, int num, boolean correct) { 8 | super(symnumber, content, line); 9 | this.num = num; 10 | this.correct = correct; 11 | } 12 | 13 | public int getNum() { 14 | return num; 15 | } 16 | 17 | public boolean isCorrect() { 18 | return correct; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /compile/Compiler/src/Word/Word.java: -------------------------------------------------------------------------------- 1 | package Word; 2 | 3 | public class Word { 4 | private final int symnumber; 5 | private final String content; 6 | private int line; 7 | 8 | public Word(int symnumber, String content, int line) { 9 | this.symnumber = symnumber; 10 | this.content = content; 11 | this.line = line; 12 | } 13 | 14 | public Word() { 15 | this.symnumber = 0; 16 | this.content = ""; 17 | } 18 | 19 | public Word(String content) { 20 | this.symnumber = 0; 21 | this.content = content; 22 | } 23 | 24 | public int getSymnumber() { 25 | return symnumber; 26 | } 27 | 28 | public String getContent() { 29 | return content; 30 | } 31 | 32 | public int getLine() { 33 | return line; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return content; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /compile/compile.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /compile/error.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compile/out/production/compile/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: Compiler 3 | 4 | -------------------------------------------------------------------------------- /compile_优化前/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* -------------------------------------------------------------------------------- /compile_优化前/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /../../../:\compile\.idea/dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /compile_优化前/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /compile_优化前/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile_优化前/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile_优化前/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /compile_优化前/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /compile_优化前/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /../../../../:\compile\Lexical_analysis\.idea/dataSources/ 6 | /dataSources.local.xml 7 | # Editor-based HTTP Client requests 8 | /httpRequests/ 9 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/.idea/checkstyle-idea.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/Lexical_analysis.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/And.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class And extends Node{ 9 | ArrayList exprs=new ArrayList<>(); 10 | private int jump; 11 | public And(ArrayList exprs) { 12 | this.exprs=exprs; 13 | } 14 | 15 | public void gen(int k) { 16 | jump=++jumps; 17 | for(Expr e:exprs){ 18 | emit(new midCode(midCode.operation.BZ,"Jump"+jump,e.reduce().toString())); 19 | } 20 | emit(new midCode(midCode.operation.GOTO,"Jump"+k)); 21 | emit(new midCode(midCode.operation.Jump,String.valueOf(jump))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Assign.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Assign extends Stmt { 6 | Lval lval; 7 | Expr expr; 8 | 9 | public Assign(Lval lval, Expr expr) { 10 | this.lval = lval; 11 | this.expr = expr; 12 | } 13 | 14 | @Override 15 | public void gen() { 16 | if (lval instanceof Id) { 17 | emit(new midCode(midCode.operation.ASSIGNOP, lval.reduce().toString(), expr.reduce().toString())); 18 | } else { 19 | emit(new midCode(midCode.operation.PUTARRAY, lval.getcontent(),lval.toString(),expr.reduce().toString())); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Block.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Symbol_table.IntergerTable; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class Block extends Stmt { 9 | ArrayList items; 10 | static int count=0; 11 | int num; 12 | 13 | public Block(ArrayList items) { 14 | this.items = items; 15 | } 16 | 17 | @Override 18 | public void gen() { 19 | inttable=new IntergerTable(inttable); 20 | num=++count; 21 | emit(new midCode(midCode.operation.LABEL,String.valueOf(num),"start")); 22 | for(BlockItem i:items) 23 | i.gen(); 24 | emit(new midCode(midCode.operation.LABEL,String.valueOf(num),"end")); 25 | inttable=inttable.getOut(); 26 | } 27 | 28 | public void gen(int k){ 29 | num=k; 30 | for(BlockItem i:items) 31 | i.gen(); 32 | emit(new midCode(midCode.operation.RET,null)); 33 | emit(new midCode(midCode.operation.LABEL,String.valueOf(num),"end")); 34 | inttable=inttable.getOut(); 35 | } 36 | 37 | public static int getCount() { 38 | return ++count; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/BlockItem.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | public class BlockItem extends Node{ 4 | } 5 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Break.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Break extends Stmt{ 6 | @Override 7 | public void gen() { 8 | int k=loopstack.peek(); 9 | emit(new midCode(midCode.operation.GOTO,"Loop"+String.valueOf(k)+"end")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Constant.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class Constant extends Expr { 9 | public Constant( Word op) { 10 | super( op); 11 | } 12 | 13 | public Constant(ArrayList midCodes, int num) { 14 | super( new Word(String.valueOf(num))); 15 | } 16 | 17 | @Override 18 | public int calculate() { 19 | return Integer.parseInt(op.getContent()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Continue.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Continue extends Stmt{ 6 | @Override 7 | public void gen() { 8 | int k=loopstack.peek(); 9 | emit(new midCode(midCode.operation.GOTO,"Loop"+String.valueOf(k)+"begin")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Decl.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class Decl extends BlockItem { 6 | LinkedList defs; 7 | boolean isConst; 8 | 9 | public Decl(LinkedList defs, boolean isConst) { 10 | this.defs = defs; 11 | this.isConst = isConst; 12 | } 13 | 14 | @Override 15 | public void gen() { 16 | for(Def d:defs) 17 | d.gen(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Def.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Def extends Node { 6 | Lval lval; 7 | 8 | public Def(Lval lval) { 9 | this.lval = lval; 10 | } 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Expr.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class Expr extends Stmt { 9 | 10 | public Word op; 11 | 12 | public Expr( Word op) { 13 | this.op = op; 14 | } 15 | 16 | public Expr reduce() { 17 | return this; 18 | } 19 | 20 | @Override 21 | public void gen() { 22 | //reduce(); 23 | } 24 | 25 | @Override 26 | public String toString() { 27 | return op.toString(); 28 | } 29 | 30 | public int calculate() { 31 | return 0; 32 | } 33 | 34 | public String getcontent(){ 35 | return op.getContent(); 36 | } 37 | // public Expr reduce() { 38 | // return this; 39 | // } 40 | } 41 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Fparam.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Symbol_table.Symbols.ArraySymbol; 5 | 6 | public class Fparam extends Node { 7 | Id id; 8 | int level; 9 | Expr expr; 10 | 11 | public Fparam(Id id, int level, Expr expr) { 12 | this.id = id; 13 | this.level = level; 14 | this.expr = expr; 15 | } 16 | 17 | @Override 18 | public void gen() { 19 | String s=id.getcontent(); 20 | if(level==0){ 21 | emit(new midCode(midCode.operation.PARAM,s,String.valueOf("0"))); 22 | }else if(level==1){ 23 | emit(new midCode(midCode.operation.PARAM,s,String.valueOf("1"))); 24 | inttable.add(s,new ArraySymbol(s,false,1)); 25 | }else{ 26 | int level2=expr.calculate(); 27 | emit(new midCode(midCode.operation.PARAM,s,String.valueOf("2"),String.valueOf(level2))); 28 | inttable.add(s,new ArraySymbol(s,false,2,level2)); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/FuncR.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class FuncR extends Expr { 9 | ArrayList Rparas; 10 | ArrayList Rafter = new ArrayList<>(); 11 | 12 | public FuncR(Word op, ArrayList rparas) { 13 | super(op); 14 | Rparas = rparas; 15 | } 16 | 17 | @Override 18 | public Expr reduce() { 19 | for (Expr e : Rparas) { 20 | Rafter.add(e.reduce()); 21 | } 22 | for (Expr s : Rafter) { 23 | if (s instanceof Array) 24 | emit(new midCode(midCode.operation.PUSH, s.op.getContent(),((Array) s).temp.toString(),((Array) s).num2)); 25 | else 26 | emit(new midCode(midCode.operation.PUSH, s.toString())); 27 | } 28 | emit(new midCode(midCode.operation.CALL, op.getContent())); 29 | int type = funcTable.get(op.getContent()).getReturntype(); 30 | if (type == 0) 31 | return this; 32 | else { 33 | Temp t = new Temp(op); 34 | emit(new midCode(midCode.operation.RETVALUE, t.toString())); 35 | return t; 36 | } 37 | } 38 | 39 | @Override 40 | public void gen() { 41 | reduce(); 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "RET"; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Id.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Symbol_table.IntergerTable; 5 | import Symbol_table.Symbols.ArraySymbol; 6 | import Symbol_table.Symbols.VarSymbol; 7 | import Word.Word; 8 | 9 | import java.util.ArrayList; 10 | 11 | public class Id extends Lval{ 12 | 13 | public Id(Word op) { 14 | super(op); 15 | } 16 | 17 | @Override 18 | public int calculate() { 19 | 20 | IntergerTable table=inttable; 21 | VarSymbol sym=null; 22 | while(table!=null){ 23 | if(table.contains(op.getContent())){ 24 | sym = (VarSymbol) table.get(op.getContent()); 25 | break; 26 | } 27 | table=table.getOut(); 28 | } 29 | 30 | return sym.getValue(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/If.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class If extends Stmt { 6 | Or cond; 7 | Stmt stmt1; 8 | Stmt stmt2; 9 | int jump1; 10 | int jump2; 11 | 12 | 13 | public If(Or cond, Stmt stmt1, Stmt stmt2) { 14 | this.cond = cond; 15 | this.stmt1 = stmt1; 16 | this.stmt2 = stmt2; 17 | } 18 | 19 | @Override 20 | public void gen() { //删除语句存疑,先不进行删除 21 | if (stmt2 == null) { 22 | jump1 = ++jumps; 23 | cond.gen(jump1); 24 | if (stmt1 != null) 25 | stmt1.gen(); 26 | emit(new midCode(midCode.operation.Jump, String.valueOf(jump1))); 27 | } else { 28 | jump1 = ++jumps; 29 | jump2 = ++jumps; 30 | cond.gen(jump1); 31 | if (stmt1 != null) 32 | stmt1.gen(); 33 | emit(new midCode(midCode.operation.GOTO, "Jump" + jump2)); 34 | emit(new midCode(midCode.operation.Jump, String.valueOf(jump1))); 35 | stmt2.gen(); 36 | emit(new midCode(midCode.operation.Jump, String.valueOf(jump2))); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Logical.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | public class Logical extends Expr{ 7 | private Expr expr1,expr2; 8 | 9 | public Logical(Word op,Expr expr1,Expr expr2) { 10 | super(op); 11 | this.expr1=expr1; 12 | this.expr2=expr2; 13 | } 14 | 15 | public Expr reduce() { 16 | Temp t=new Temp(op); 17 | String midop=op.getContent(); 18 | midCode.operation ope= midCode.operation.DEBUG; 19 | if(midop.equals("<")){ 20 | ope= midCode.operation.LSSOP; 21 | } else if(midop.equals("<=")){ 22 | ope= midCode.operation.LEQOP; 23 | }else if(midop.equals(">")){ 24 | ope= midCode.operation.GREOP; 25 | }else if(midop.equals(">=")){ 26 | ope= midCode.operation.GEQOP; 27 | }else if(midop.equals("==")){ 28 | ope= midCode.operation.EQLOP; 29 | }else if(midop.equals("!=")){ 30 | ope=midCode.operation.NEQOP; 31 | } 32 | 33 | emit(new midCode(ope,t.toString(),expr1.reduce().toString(),expr2.reduce().toString())); 34 | return t; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Lval.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Word.Word; 4 | 5 | public class Lval extends Expr{ 6 | public Lval(Word op) { 7 | super(op); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Node.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | 4 | import Midcode.midCode; 5 | import java.util.ArrayList; 6 | import java.util.LinkedList; 7 | import java.util.Stack; 8 | 9 | import Symbol_table.FuncTable; 10 | import Symbol_table.IntergerTable; 11 | 12 | public class Node { 13 | public static ArrayList midCodes=new ArrayList<>(); 14 | public static IntergerTable inttable=new IntergerTable(); 15 | public static FuncTable funcTable=new FuncTable(); 16 | public static LinkedList stringss=new LinkedList<>(); 17 | static int labels=0; 18 | static int jumps=0; 19 | static Stack loopstack=new Stack<>(); 20 | 21 | 22 | public int newlabel() { 23 | return ++labels; 24 | } 25 | 26 | public void emitlabel(int i){ 27 | midCodes.add(new midCode(midCode.operation.LABEL,String.valueOf(i))); 28 | } 29 | 30 | public void emit(midCode code){ 31 | midCodes.add(code); 32 | } 33 | 34 | public static ArrayList getMidCodes() { 35 | return midCodes; 36 | } 37 | 38 | public void gen(){ 39 | 40 | } 41 | 42 | public static LinkedList getStringss() { 43 | return stringss; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Or.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | public class Or extends Node{ 10 | List ands=new ArrayList<>(); 11 | private int jump; 12 | public Or(ArrayList ands) { 13 | this.ands=ands; 14 | } 15 | 16 | public void gen(int k){ 17 | jump=++jumps; 18 | for(And and:ands){ 19 | and.gen(jump); 20 | } 21 | emit(new midCode(midCode.operation.GOTO,"Jump"+k)); 22 | emit(new midCode(midCode.operation.Jump,String.valueOf(jump))); 23 | } 24 | public void gen(int k,boolean whi){ 25 | jump=++jumps; 26 | for(And and:ands){ 27 | and.gen(jump); 28 | } 29 | emit(new midCode(midCode.operation.GOTO,"Loop" +String.valueOf(k)+"end")); 30 | emit(new midCode(midCode.operation.Jump,String.valueOf(jump))); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Program.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import java.util.LinkedList; 4 | 5 | public class Program extends Node { 6 | LinkedList decls=new LinkedList<>(); 7 | LinkedList funcs=new LinkedList<>(); 8 | 9 | public Program(LinkedList decls, LinkedList funcs) { 10 | this.decls = decls; 11 | this.funcs = funcs; 12 | } 13 | 14 | public void gen(){ 15 | for(Decl d:decls){ 16 | d.gen(); 17 | } 18 | for(Func f:funcs){ 19 | f.gen(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Ret.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Ret extends Stmt { 6 | Expr expr; 7 | 8 | public Ret(Expr expr) { 9 | this.expr = expr; 10 | } 11 | 12 | @Override 13 | public void gen() { 14 | if(expr==null){ 15 | emit(new midCode(midCode.operation.RET,null)); 16 | }else{ 17 | emit(new midCode(midCode.operation.RET,expr.reduce().toString())); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Scanf.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class Scanf extends Stmt{ 6 | Lval lval; 7 | 8 | public Scanf(Lval lval) { 9 | this.lval = lval; 10 | } 11 | 12 | @Override 13 | public void gen() { 14 | // emit(new midCode(midCode.operation.SCAN,lval.reduce().toString())); 15 | if (lval instanceof Id) { 16 | emit(new midCode(midCode.operation.SCAN,lval.reduce().toString())); 17 | } else { 18 | Temp temp=new Temp(null); 19 | emit(new midCode(midCode.operation.SCAN,temp.toString())); 20 | emit(new midCode(midCode.operation.PUTARRAY, lval.getcontent(),lval.toString(),temp.toString())); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Stmt.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | public class Stmt extends BlockItem{ 4 | 5 | } 6 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Temp.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | import java.util.ArrayList; 7 | 8 | public class Temp extends Expr { 9 | 10 | private static int count=0; 11 | private int number=0; 12 | 13 | public Temp( Word op) { 14 | super( op); 15 | this.number = ++count; 16 | } 17 | 18 | 19 | public String toString() { 20 | return "t&"+number; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/Unary.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | import Word.Word; 5 | 6 | public class Unary extends Expr{ 7 | public Expr exp; 8 | public Unary(Word op, Expr expr) { 9 | super(op); 10 | this.exp=expr; 11 | } 12 | 13 | @Override 14 | public int calculate() { 15 | if(op.getContent().equals("-")) 16 | return exp.calculate()*(-1); 17 | else 18 | return exp.calculate(); 19 | } 20 | 21 | @Override 22 | public Expr reduce() { 23 | if(op.getContent().equals("+")){ 24 | return exp.reduce(); 25 | }else if(op.getContent().equals("-")){ 26 | Temp t=new Temp(op); 27 | emit(new midCode(midCode.operation.MINUOP,t.toString(),"0",exp.reduce().toString())); 28 | return t; 29 | }else if(op.getContent().equals("!")){ 30 | Temp t=new Temp(op); 31 | emit(new midCode(midCode.operation.EQLOP,t.toString(),"0",exp.reduce().toString())); 32 | return t; 33 | }else{ 34 | return null; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/AST/While.java: -------------------------------------------------------------------------------- 1 | package AST; 2 | 3 | import Midcode.midCode; 4 | 5 | public class While extends Stmt { 6 | Or Cond; 7 | Stmt stmt; 8 | int jump; 9 | 10 | public While(Or cond, Stmt stmt) { 11 | Cond = cond; 12 | this.stmt = stmt; 13 | } 14 | 15 | @Override 16 | public void gen() { 17 | jump = ++jumps; 18 | loopstack.push(jump); 19 | emit(new midCode(midCode.operation.Jump, String.valueOf(jump), "begin")); 20 | Cond.gen(jump, true); 21 | if (stmt != null) 22 | stmt.gen(); 23 | emit(new midCode(midCode.operation.GOTO, "Loop" + String.valueOf(jump) + "begin")); 24 | emit(new midCode(midCode.operation.Jump, String.valueOf(jump), "end")); 25 | loopstack.pop(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/Symbol_table/FuncTable.java: -------------------------------------------------------------------------------- 1 | package Symbol_table; 2 | 3 | import Symbol_table.Symbols.FuncSymbol; 4 | import Symbol_table.Symbols.NorSymbol; 5 | 6 | import java.util.HashMap; 7 | 8 | public class FuncTable { 9 | private HashMap maps=new HashMap<>(); 10 | private FuncTable out; 11 | 12 | public FuncTable() { 13 | } 14 | 15 | public HashMap getMaps() { 16 | return maps; 17 | } 18 | 19 | public FuncTable getOut() { 20 | return out; 21 | } 22 | 23 | public void add(String s, FuncSymbol symbol){ 24 | maps.put(s,symbol); 25 | } 26 | 27 | public FuncSymbol get(String s){ 28 | return maps.get(s); 29 | } 30 | 31 | public boolean contains(String s){ 32 | return maps.containsKey(s); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/Symbol_table/IntergerTable.java: -------------------------------------------------------------------------------- 1 | package Symbol_table; 2 | 3 | import Symbol_table.Symbols.FuncSymbol; 4 | import Symbol_table.Symbols.NorSymbol; 5 | 6 | import java.util.HashMap; 7 | 8 | public class IntergerTable { 9 | private HashMap maps=new HashMap<>(); 10 | private IntergerTable out=null; 11 | private int contentlength=0; 12 | 13 | public IntergerTable() { 14 | 15 | } 16 | 17 | public void addlength(int len){ 18 | contentlength+=len; 19 | } 20 | 21 | public int getContentlength() { 22 | return contentlength; 23 | } 24 | 25 | public IntergerTable(IntergerTable out) { 26 | this.out = out; 27 | } 28 | 29 | public HashMap getMaps() { 30 | return maps; 31 | } 32 | 33 | public IntergerTable getOut() { 34 | return out; 35 | } 36 | 37 | public void add(String s,NorSymbol symbol){ 38 | maps.put(s,symbol); 39 | } 40 | 41 | public boolean contains(String s){ 42 | return maps.containsKey(s); 43 | } 44 | 45 | public NorSymbol get(String s){ 46 | return maps.get(s); 47 | } 48 | 49 | public void setOut(IntergerTable out) { 50 | this.out = out; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/Symbol_table/Symbols/FuncSymbol.java: -------------------------------------------------------------------------------- 1 | package Symbol_table.Symbols; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class FuncSymbol { 6 | private String name; 7 | private ArrayList params; 8 | private int returntype; //0=void 1=int 9 | 10 | public FuncSymbol(String name, ArrayList params, int returntype) { 11 | this.name = name; 12 | this.params = params; 13 | this.returntype = returntype; 14 | } 15 | 16 | public FuncSymbol(int returntype) { 17 | this.returntype = returntype; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public ArrayList getParams() { 25 | return params; 26 | } 27 | 28 | public int getReturntype() { 29 | return returntype; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/Symbol_table/Symbols/VarSymbol.java: -------------------------------------------------------------------------------- 1 | package Symbol_table.Symbols; 2 | 3 | public class VarSymbol extends NorSymbol { 4 | private int value; 5 | 6 | public VarSymbol(String name,boolean isConst, int value) { 7 | super(name,isConst); 8 | this.value = value; 9 | } 10 | public VarSymbol(String name,boolean isConst) { 11 | super(name,isConst); 12 | } 13 | 14 | public VarSymbol(String name, int offset) { 15 | super(name, offset); 16 | } 17 | 18 | public int getValue() { 19 | return value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/Word/FormatWord.java: -------------------------------------------------------------------------------- 1 | package Word; 2 | 3 | public class FormatWord extends Word { 4 | private int num; 5 | private boolean correct; 6 | 7 | public FormatWord(int symnumber, String content, int line, int num, boolean correct) { 8 | super(symnumber, content, line); 9 | this.num = num; 10 | this.correct = correct; 11 | } 12 | 13 | public int getNum() { 14 | return num; 15 | } 16 | 17 | public boolean isCorrect() { 18 | return correct; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /compile_优化前/Lexical_analysis/src/Word/Word.java: -------------------------------------------------------------------------------- 1 | package Word; 2 | 3 | public class Word { 4 | private final int symnumber; 5 | private final String content; 6 | private int line; 7 | 8 | public Word(int symnumber, String content, int line) { 9 | this.symnumber = symnumber; 10 | this.content = content; 11 | this.line = line; 12 | } 13 | 14 | public Word(){ 15 | this.symnumber=0; 16 | this.content=""; 17 | } 18 | 19 | public Word(String content){ 20 | this.symnumber=0; 21 | this.content=content; 22 | } 23 | 24 | public int getSymnumber() { 25 | return symnumber; 26 | } 27 | 28 | public String getContent() { 29 | return content; 30 | } 31 | 32 | public int getLine() { 33 | return line; 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return content; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /compile_优化前/compile.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /compile_优化前/error.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compile_优化前/optimize.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/compile_优化前/optimize.txt -------------------------------------------------------------------------------- /img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/img/1.png -------------------------------------------------------------------------------- /img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/img/2.png -------------------------------------------------------------------------------- /img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/img/3.png -------------------------------------------------------------------------------- /img/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/img/4.png -------------------------------------------------------------------------------- /mars.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/mars.jar -------------------------------------------------------------------------------- /test_compile/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /test_compile/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /test_compile/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /test_compile/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test_compile/.idea/test.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /test_compile/InstructionStatistics.txt: -------------------------------------------------------------------------------- 1 | DIV : 0 2 | MULT : 1 3 | JUMP/BRANCH : 83 4 | MEM : 148 5 | OTHER : 389 6 | FinalCycle : 886.5 -------------------------------------------------------------------------------- /test_compile/answer.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231076 4 | >/!~varg1 is:-1;~ 5 | >/!~varg2 is:-8;~ 6 | >/!~varg3 is:7;~ 7 | >/!~varg4 is:6;~ 8 | >/!~varg5 is:5;~ 9 | >/!~varg6 is:4;~ 10 | >/!~varg7 is:3;~ 11 | >/!~varg8 is:2;~ 12 | >/!~varg9 is:1;~ 13 | -------------------------------------------------------------------------------- /test_compile/answer_temp.txt: -------------------------------------------------------------------------------- 1 | 19231076 2 | >/!~varg1 is:-1;~ 3 | >/!~varg2 is:-8;~ 4 | >/!~varg3 is:7;~ 5 | >/!~varg4 is:6;~ 6 | >/!~varg5 is:5;~ 7 | >/!~varg6 is:4;~ 8 | >/!~varg7 is:3;~ 9 | >/!~varg8 is:2;~ 10 | >/!~varg9 is:1;~ 11 | -------------------------------------------------------------------------------- /test_compile/compile.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/compile.jar -------------------------------------------------------------------------------- /test_compile/header.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | -------------------------------------------------------------------------------- /test_compile/input.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /test_compile/mars.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/mars.jar -------------------------------------------------------------------------------- /test_compile/output.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231076 4 | >/!~varg1 is:-1;~ 5 | >/!~varg2 is:-8;~ 6 | >/!~varg3 is:7;~ 7 | >/!~varg4 is:6;~ 8 | >/!~varg5 is:5;~ 9 | >/!~varg6 is:4;~ 10 | >/!~varg7 is:3;~ 11 | >/!~varg8 is:2;~ 12 | >/!~varg9 is:1;~ 13 | -------------------------------------------------------------------------------- /test_compile/output/output1.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231204 4 | + is error! 5 | + is error! 6 | + is error! 7 | + is error! 8 | Break is error! 9 | a1+b1 is 3 10 | a2+b2 is -2 11 | -------------------------------------------------------------------------------- /test_compile/output/output10.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373025 4 | 1 5 | funi 6 | try 7 | try 8 | try 9 | try 10 | try 11 | try 12 | try 13 | -------------------------------------------------------------------------------- /test_compile/output/output11.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19182650 4 | this is d 5 | 4 6 | 5 7 | 4 8 | 5 9 | 2 10 | -------------------------------------------------------------------------------- /test_compile/output/output12.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19182623 4 | -------------------------------------------------------------------------------- /test_compile/output/output13.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 10, 30972, -5 4 | -------------------------------------------------------------------------------- /test_compile/output/output14.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373372 4 | fact[10] = 3628800 5 | fact[1] = 1 6 | fact[2] = 2 7 | fact[3] = 6 8 | fact[4] = 24 9 | fact[5] = 120 10 | fact[6] = 720 11 | fact[7] = 5040 12 | fact[8] = 40320 13 | -------------------------------------------------------------------------------- /test_compile/output/output15.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373479 4 | print int : 0 5 | print int : 2 6 | print int : 2 7 | print int : 0 8 | print int : 41 9 | print int : 61 10 | print int : 4884 11 | print int : -45015 12 | -------------------------------------------------------------------------------- /test_compile/output/output16.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373373 4 | j : 4, k : 10, l : 4 5 | a! = 720, num = 5 6 | 6 7 | scanf a, b to get gcd and lcm 8 | gcd is 5 9 | lcm is 30 10 | -6 11 | scanf a to get Fibonacci 12 | fib is 8 13 | -------------------------------------------------------------------------------- /test_compile/output/output17.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373682 4 | hello? 12345 12345 12345 5 | func1 done! 6 | func2 done! 7 | func3 input = 0 8 | func3 done! 9 | 204 204 100 100 20400 100 0 100 100 10 | func4 done! 11 | -------------------------------------------------------------------------------- /test_compile/output/output18.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373719 4 | 0 -2 5 | 0 2 6 | 4 7 | 0 8 | -------------------------------------------------------------------------------- /test_compile/output/output19.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373135 4 | l_const_0, should be 0: 0 5 | l_const_1, should be 1: 1 6 | l_const_3, should be 2: 2 7 | l_const_5[2], l_const_6[0][1], should be 3, 1: 3, 1 8 | l_var_0, should be 0: 0 9 | l_var_1, should be 2: 2 10 | l_var_3, should be 4: 4 11 | l_var_5, should be 5: 5 12 | l_var_6[2], l_var_7[0][1], should be 3, 1: 3, 1 -------------------------------------------------------------------------------- /test_compile/output/output2.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 18375200 4 | -163900461 5 | -628 6 | -925500 7 | ppgod7mi 8 | 4396yoga7 9 | 2333 10 | 11 | 12 | 13 | 632917 is not a prime, with factor 41. 14 | The 30th Fibonacci num is 832040. -------------------------------------------------------------------------------- /test_compile/output/output20.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373061 4 | 0 5 | 1 6 | 0 7 | 0 8 | 1 9 | 0 10 | 1 11 | 0 12 | t:1 13 | -------------------------------------------------------------------------------- /test_compile/output/output21.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | gcd is 1 4 | gcd is 1 5 | gcd is 1 6 | gcd is 2 7 | invaild input! 8 | invaild input! 9 | gcd is 9 10 | -------------------------------------------------------------------------------- /test_compile/output/output22.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373034 4 | 1 5 | 1 6 | 0 7 | 1 8 | 0 9 | 10 10 | 8 11 | 9 12 | 10 -------------------------------------------------------------------------------- /test_compile/output/output23.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373044 4 | s+1=2 5 | m=0 6 | m=1 7 | m=0 8 | m=0 9 | m=1 10 | m=2 11 | m=3 12 | before break 13 | -------------------------------------------------------------------------------- /test_compile/output/output24.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373022 4 | b:-19260604 5 | Bool1 is false! 6 | 1919820 7 | 1932053504 8 | -------------------------------------------------------------------------------- /test_compile/output/output25.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373341 4 | the num is 851 5 | the num is 11 6 | the num is 13 7 | the num is 12341 8 | 11 is odd! 9 | 13 is odd! 10 | max of 11 and 13 is 13 11 | min of 11 and 13 is 11 12 | No, 12341 is not a prime! It has a factor 7 13 | -------------------------------------------------------------------------------- /test_compile/output/output26.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373276 4 | !()*+,-./0123456789:;<>=?@[]^_`~{}| 5 | qwertyuiopasd 6 | fghjklzxcvbnmQWERTYUIOPASD 7 | FGHJKLZXCVBNM0 8 | 72 23 9 | addSum: 105, 45 10 | -2169 11 | 1008-6 12 | end -------------------------------------------------------------------------------- /test_compile/output/output27.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373315 4 | this is a yu ju ky 5 | unbelievable! 6 | var_a from getint() is 1 7 | getint is 1 8 | tmp 9 | tmp 10 | tmp 11 | tmp 12 | tmp 13 | -------------------------------------------------------------------------------- /test_compile/output/output28.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373332 4 | Stmt-3(Block): c = 2, d = 46 5 | Stmt-3(Block): e = 4, f = 829 6 | Stmt-4(if) check finish! 7 | Stmt-5,6 check finish! 8 | Stmt-7 check finish! 9 | Stmt-8 check finish! 10 | 11 | FormatChar. 12 | 13 13 | -------------------------------------------------------------------------------- /test_compile/output/output29.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373348 4 | Got a number: 233! 5 | 247 6 | Got a number: 1! 7 | -3 8 | Got a number: 42! 9 | 738 10 | Got a number: -15! 11 | 1711 12 | Got a number: 0! 13 | 3667 14 | -------------------------------------------------------------------------------- /test_compile/output/output3.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231177 4 | 1 5 | 23 6 | 3 7 | 4 8 | 52 9 | 6 10 | 7 11 | 8 12 | 99 13 | 10 14 | appear 15 | 20 16 | not 17 | 30 18 | not 19 | 40 20 | not 21 | 50 22 | not 23 | 60 24 | not 25 | 99 26 | not 27 | 99 28 | not 29 | 99 30 | not 31 | print123 32 | 123 33 | /****/123 34 | /**/123 35 | print return value : 36 | in : 5 ,out = 50 37 | in : 5 ,out = 50 38 | -------------------------------------------------------------------------------- /test_compile/output/output4.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231204 4 | The score is 56. 5 | Yes! 6 | Yes! 7 | Yes! 8 | No! -------------------------------------------------------------------------------- /test_compile/output/output5.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 16061069 4 | input an integer,judge if it is prime number,10 groups in total 5 | input > 0 is needed 6 | input > 0 is needed 7 | 1 is not concerned 8 | 2 is a prime number 9 | 3 is a prime number 10 | 4 is not a prime number 11 | 5 is a prime number 12 | 6 is not a prime number 13 | 7 is a prime number 14 | 8 is not a prime number 15 | while times is 22 in total 16 | -------------------------------------------------------------------------------- /test_compile/output/output6.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231177 4 | _ = 1; a = 20; b = 30; c = 460; 5 | 20+30=50; 460-1=459; 50*459=22950; 459/50=9; 22950mod30=0 6 | 50+459+22950=23459; 459-22950-9=-22500; 22950*9*0=0; 0/50/459=0; 9mod0mod50=9 7 | 10+17-23*37/43mod71-17*23+43=-340=-340 8 | 10+(17-23)*37/43mod(71-37)*-340=1710 9 | all chars : !()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~ 10 | 5!+7+3=130 11 | max: 2147483647 ; min : -2147483647 ; sum : 0 12 | 19231177 13 | -------------------------------------------------------------------------------- /test_compile/output/output7.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19373755 4 | n = -864 5 | n = -7938 6 | n = 10 7 | n = -15 8 | n = 861 9 | n = 0 10 | test_if done! 11 | test_while done! 12 | test_break_continue done! 13 | -------------------------------------------------------------------------------- /test_compile/output/output8.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19182650 4 | 1 5 | 2 6 | 3 7 | 4 8 | 5 9 | 6 10 | 21 11 | 1 12 | 6 13 | -------------------------------------------------------------------------------- /test_compile/output/output9.txt: -------------------------------------------------------------------------------- 1 | MARS 4.5 Copyright 2003-2014 Pete Sanderson and Kenneth Vollmar 2 | 3 | 19231076 4 | >/!~varg1 is:-1;~ 5 | >/!~varg2 is:-8;~ 6 | >/!~varg3 is:7;~ 7 | >/!~varg4 is:6;~ 8 | >/!~varg5 is:5;~ 9 | >/!~varg6 is:4;~ 10 | >/!~varg7 is:3;~ 11 | >/!~varg8 is:2;~ 12 | >/!~varg9 is:1;~ 13 | -------------------------------------------------------------------------------- /test_compile/res.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/res.txt -------------------------------------------------------------------------------- /test_compile/testfiles/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/.DS_Store -------------------------------------------------------------------------------- /test_compile/testfiles/A/input10.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input11.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/A/input12.txt -------------------------------------------------------------------------------- /test_compile/testfiles/A/input13.txt: -------------------------------------------------------------------------------- 1 | 123 2 | 456 3 | 12 4 | 324 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input14.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 0 3 | 1 4 | 6 5 | 8 6 | 20 7 | 30 8 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input15.txt: -------------------------------------------------------------------------------- 1 | 200 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input16.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 60 7 | 70 8 | 80 9 | 90 10 | 100 11 | 1100 12 | 1200 13 | 1300 14 | 1400 15 | 1500 16 | 16000 17 | 17000 18 | 18000 19 | 19000 20 | 24000 21 | 20000 22 | 21000 23 | 22000 24 | 23000 25 | 25000 26 | 0 27 | 1 28 | 550 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input17.txt: -------------------------------------------------------------------------------- 1 | 33 2 | 28 3 | 501 4 | 233 5 | 114 6 | 711 7 | 266 8 | 500 9 | 77 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input18.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input19.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input2.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 1998 3 | 3 4 | 23 5 | 2021 6 | 9 7 | 23 8 | 168 9 | 5 10 | 21 11 | 2020 12 | 1 13 | 1 14 | 2010 15 | 2 16 | 28 17 | 2010 18 | 1 19 | 1 20 | 1998 21 | 2 22 | 25 23 | 1997 24 | 5 25 | 24 26 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input20.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input21.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input22.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input23.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input24.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 3 4 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input25.txt: -------------------------------------------------------------------------------- 1 | 24 2 | 27 3 | 342526 4 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/input26.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input3.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input4.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/A/input4.txt -------------------------------------------------------------------------------- /test_compile/testfiles/A/input5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/A/input5.txt -------------------------------------------------------------------------------- /test_compile/testfiles/A/input6.txt: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input8.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 -------------------------------------------------------------------------------- /test_compile/testfiles/A/input9.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 12 -------------------------------------------------------------------------------- /test_compile/testfiles/A/output10.txt: -------------------------------------------------------------------------------- 1 | 19373528 2 | f2() flag : 3 3 | f2() flag : 3 4 | flag = 1 : c1 = 3, c2 = -1 5 | f2() flag : 2 6 | f2() flag : 4 7 | flag = 0 : c1 = 13, c2 = -1 8 | f2() flag : 2 9 | f2() flag : 4 10 | flag = 0 : c1 = 23, c2 = -1 -------------------------------------------------------------------------------- /test_compile/testfiles/A/output11.txt: -------------------------------------------------------------------------------- 1 | 19182620 2 | 0 3 | 1 4 | 2 5 | 2 6 | 1 7 | 2 8 | 19182620 9 | 19182620 10 | 19182620 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output12.txt: -------------------------------------------------------------------------------- 1 | 19182636 2 | ! is ok 3 | < is ok 4 | > is ok 5 | <= is ok 6 | >= is ok 7 | == != is ok 8 | or is ok 9 | the priority of and/or is ok 10 | 6 7 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output13.txt: -------------------------------------------------------------------------------- 1 | 19373330 2 | max of mnpq is 456 3 | i or m ? 456 4 | out1 456 out2 229044 5 | sum of array var33 is 5583 6 | squ sum of s3 3 7 | max of four number 314721 8 | Kirov reporrrting 1 9 | For the Union 7 10 | okmotherfuckeroveridontwanttobehornyanymoreijustwanttobehappy 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output15.txt: -------------------------------------------------------------------------------- 1 | 19373354 2 | 2 -402114823 3 | 3 423174272 4 | 5 375872692 5 | 7 915987033 6 | 11 -34179219 7 | 13 1498631475 8 | 17 -1060809599 9 | 19 423174272 10 | 23 915987033 11 | 29 1498631475 12 | 31 1640319187 13 | 37 375872692 14 | 41 -2143283456 15 | 43 -34179219 16 | 47 1640319187 17 | 53 375872692 18 | 59 -34179219 19 | 61 1498631475 20 | 67 423174272 21 | 71 915987033 22 | 73 -2143283456 23 | 79 1640319187 24 | 83 423174272 25 | 89 -2143283456 26 | 97 -1060809599 27 | 101 375872692 28 | 103 915987033 29 | 107 -34179219 30 | 109 1498631475 31 | 113 -1060809599 32 | 127 1640319187 33 | 131 423174272 34 | 137 -2143283456 35 | 139 -34179219 36 | 149 375872692 37 | 151 915987033 38 | 157 1498631475 39 | 163 423174272 40 | 167 915987033 41 | 173 1498631475 42 | 179 423174272 43 | 181 375872692 44 | 191 1640319187 45 | 193 -1060809599 46 | 197 375872692 47 | 199 915987033 48 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output16.txt: -------------------------------------------------------------------------------- 1 | 19373459 2 | val20: 0, val21:5369, val22:4821, val23:4682, val24:8093 3 | val30: 0, val32: 7303, val34: 6137 4 | val40: 0, val42:-1, val43:0, val44:-1 5 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output17.txt: -------------------------------------------------------------------------------- 1 | 19373487 2 | the result is:4 3 | the result is:4 4 | out of range!! 5 | the result is:6 6 | the result is:4 7 | out of range!! 8 | the result is:6 9 | the result is:5 10 | the result is:4 -------------------------------------------------------------------------------- /test_compile/testfiles/A/output18.txt: -------------------------------------------------------------------------------- 1 | 19373311 2 | 123 3 | 123 4 | 123 5 | 123 6 | 123 7 | 4 5 6 8 | 36 9 | 16 10 | 10 11 | 63 12 | 36 13 | 1 2 3 14 | 4 5 6 15 | 7 8 9 16 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output19.txt: -------------------------------------------------------------------------------- 1 | 19373135 2 | global g_var_6[1][0]:1, g_var_6[1][1]:1 3 | local l_var_4:1, l_var_5:1, l_var_6:1, l_var_7:10, l_var_8:100 4 | exp l_var_4:1 5 | exp l_var_5:0 6 | exp l_var_6:0 7 | if l_var_4:3 8 | while l_var_5:0 9 | while l_var_5:0 10 | getint l_var_6:1 -------------------------------------------------------------------------------- /test_compile/testfiles/A/output2.txt: -------------------------------------------------------------------------------- 1 | 16061069 2 | input groups 3 | input your birth year,month,day,ep:1998 1 1 4 | input current year,month,day,ep:2020 2 2 5 | you have lived 8585 days 6 | input your birth year,month,day,ep:1998 1 1 7 | input current year,month,day,ep:2020 2 2 8 | you have lived 676288 days 9 | input your birth year,month,day,ep:1998 1 1 10 | input current year,month,day,ep:2020 2 2 11 | please input time legally 12 | input your birth year,month,day,ep:1998 1 1 13 | input current year,month,day,ep:2020 2 2 14 | please input time legally 15 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output20.txt: -------------------------------------------------------------------------------- 1 | 19373163 2 | -+-114514 = 114514 3 | -+-114514 > 0 4 | -+- 6 + 7 * (6 -9) / 3 / 2 = 3 5 | var10[1] = 3 6 | var13 = 1 7 | func1() = 0 8 | func3(+-12) = -12 9 | func4(1, var4, var6) = 3 10 | func4(const1, var6[1], var6) = -2 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output21.txt: -------------------------------------------------------------------------------- 1 | 19373384 2 | const and var // decl and def test 3 | expected result: 579, output: 579 4 | function (def and )call test 5 | expected result: {{589, 21}, {599, 31}}, output: {{589, 21}, {599, 31}} 6 | LExp test, falling into infinite loop indicates an error -- pass 7 | simple echo test, get a integer and read back: 42 8 | 9 | 10 | ================================================================================ 11 | PASSED 12 | ================================================================================ 13 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output22.txt: -------------------------------------------------------------------------------- 1 | 19373408 all weak points 2 | L and Eq is ok (no params) 3 | Rel is ok (with params) 4 | Add is ok 5 | getint is ok 6 | -1 7 | -1 8 | 1 9 | 1 10 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output23.txt: -------------------------------------------------------------------------------- 1 | 19373421 2 | const_var1+const_var2=:3 3 | const_array1[1]=:2 4 | array2[0]:=3 5 | g(2):=6 6 | 123456789 7 | 1 8 | 5 9 | 6 10 | AK!!! -------------------------------------------------------------------------------- /test_compile/testfiles/A/output24.txt: -------------------------------------------------------------------------------- 1 | 19373235 2 | Testing Short-circuit evaluation : 0 1 1 0 1 0 1 1 0 1 1 1 3 | Testing func_pass_array(int a[][4) ...... 4 | 1 2 3 4 5 | 5 6 7 8 6 | 10 11 12 13 7 | Testing func_pass_PartArray(int a[]) ...... 5 6 7 8 8 | Testing func_pass_arrayElement(int a) ...... 3 9 | Testing complex calculate ...... result = -10. 10 | Testing D2array traversal and assignment. 11 | Array array_E: 12 | 0 1 2 13 | 1 2 3 14 | Testing func_if_D2array(a[][3], b) ...... 15 | 0 1 3 16 | 1 2 0 17 | Loop 7 times, once continue, once break. Symbol j = 5. func_while(x, y)is done! 18 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output25.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | m = 3, n = 24, mm = 27, nn = 342526 3 | max of mm and nn: 342526; min of mm and nn: 27 4 | mainConst1 = 10 5 | Sum of normalConst: 35 6 | 24 is even! 7 | Sum of array: 3 8 | sum of array: 24 9 | Contains odd! 10 | 27 and 342526 contains at least an odd! 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output26.txt: -------------------------------------------------------------------------------- 1 | 19373630 2 | 1 3 | 120 4 | 720 5 | 5040 6 | 1 7 | 2 8 | 4 9 | 3 10 | 30250 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output3.txt: -------------------------------------------------------------------------------- 1 | 19373734 2 | 19373734 3 | 19373734 4 | 19373734 5 | 19373734 6 | 19373734 7 | 19373734 8 | 19373734 9 | 19373734 10 | 19373734 -------------------------------------------------------------------------------- /test_compile/testfiles/A/output4.txt: -------------------------------------------------------------------------------- 1 | 19231258 OK1 2 | OK2 3 | OK3 4 | OK4 5 | OK5 6 | OK6 7 | OK7 8 | OK8 9 | OK9 -------------------------------------------------------------------------------- /test_compile/testfiles/A/output5.txt: -------------------------------------------------------------------------------- 1 | 19231011 2 | start checking for logic expressions 3 | check for AND calculation: successfully! 4 | check for OR calculation: successfully! 5 | check for short-circuit calculation: successfully! 6 | end checking 7 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output6.txt: -------------------------------------------------------------------------------- 1 | 19231248-250 2 | 19231248 3 | 19231248 4 | 19231248 5 | 19231248 6 | 19231248 7 | 19231248 8 | 19231248 9 | 19231248 10 | 19231248 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/output8.txt: -------------------------------------------------------------------------------- 1 | 19182619 2 | CscanfOK 3 | DscanfOK 4 | sb:2 5 | continueOK 6 | breakOK 7 | 0Func2OK 8 | Func3OK 9 | Func4OK 10 | end -------------------------------------------------------------------------------- /test_compile/testfiles/A/output9.txt: -------------------------------------------------------------------------------- 1 | 19373573 2 | 4 3 | 6 4 | judgeB 2,3 = -1 5 | Hello 12 6 | 10 7 | 0-1 8 | -10 9 | 01 10 | 10 11 | 31 -------------------------------------------------------------------------------- /test_compile/testfiles/A/testfile11.txt: -------------------------------------------------------------------------------- 1 | 2 | void de() 3 | { 4 | return; 5 | } 6 | 7 | int keke(int i,int j) 8 | { 9 | i=i+j; 10 | return 0; 11 | } 12 | 13 | int jian() 14 | { 15 | int x,y,z; 16 | x=getint(); 17 | y=getint(); 18 | z=x-y; 19 | return z; 20 | } 21 | 22 | int main() 23 | { 24 | printf("19182620\n"); 25 | int a,b,c,d, e,f,g=+1,h,j,k,l,o=-1; 26 | int i=2,n,m,flag=0; 27 | n=getint(); 28 | while(i=e) 71 | { 72 | if(e<=f) 73 | { 74 | if(f!=g) 75 | { 76 | if(c>1) 77 | { 78 | a=1; 79 | } 80 | 81 | 82 | } 83 | 84 | } 85 | } 86 | } 87 | keke(a,b); 88 | 89 | printf("%d\n%d\n%d\n%d\n",d,e,f,g); 90 | printf("19182620\n"); 91 | printf("19182620\n"); 92 | printf("19182620\n"); 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /test_compile/testfiles/A/testfile4.txt: -------------------------------------------------------------------------------- 1 | int getlogictrue() { 2 | return 1; 3 | } 4 | int main() { 5 | printf("19231258 "); 6 | if (!0 == 1 && 1 == 1) { 7 | printf("OK1\n"); 8 | } 9 | if (1 == 1 && 1 == 1 && 1 == 1 || 2 == 1 && 1 == 1) { 10 | printf("OK2\n"); 11 | } 12 | if (+-1 == -+-+0 && 1 == 1 && 2 == 2) { 13 | ; 14 | } else { 15 | printf("OK3\n"); 16 | } 17 | if (1 || 2 == 3) { 18 | printf("OK4\n"); 19 | } 20 | if (0 || 0 && 3) { 21 | ; 22 | } else { 23 | printf("OK5\n"); 24 | } 25 | if (0 || 1 && 2) { 26 | printf("OK6\n"); 27 | } 28 | if (1 >= 0 == 1 && 1 || 2 && 3 == 1 > 0) { 29 | printf("OK7\n"); 30 | } else { 31 | printf("OK7\n"); 32 | } 33 | if (1 + 1 > 0 != !1 && 7 || 8 && !7 == 0) { 34 | printf("OK8\n"); 35 | } 36 | if (!(getlogictrue() * 1) >= 0) { 37 | printf("OK9\n"); 38 | } 39 | return 0; 40 | } -------------------------------------------------------------------------------- /test_compile/testfiles/B/input1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/input1.txt -------------------------------------------------------------------------------- /test_compile/testfiles/B/input10.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input11.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 2 3 | 3 4 | 1 5 | 0 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/input12.txt -------------------------------------------------------------------------------- /test_compile/testfiles/B/input14.txt: -------------------------------------------------------------------------------- 1 | 1150 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input15.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input16.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/input16.txt -------------------------------------------------------------------------------- /test_compile/testfiles/B/input17.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 19123412 3 | 53 4 | 12142344 5 | 89 6 | 12354123 7 | 35 8 | 32151245 9 | 65 10 | 21532521 11 | 93 12 | 21654212 13 | 13 14 | 12312654 15 | 89 16 | 56335232 17 | 87 18 | 15687643 19 | 78 20 | 56323432 21 | 78 22 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input18.txt: -------------------------------------------------------------------------------- 1 | 123 2 | 0 3 | -234 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input19.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input2.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input20.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input21.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/input21.txt -------------------------------------------------------------------------------- /test_compile/testfiles/B/input22.txt: -------------------------------------------------------------------------------- 1 | 11 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input23.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 9 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input24.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/input24.txt -------------------------------------------------------------------------------- /test_compile/testfiles/B/input25.txt: -------------------------------------------------------------------------------- 1 | 23 2 | 26 3 | 353 4 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input26.txt: -------------------------------------------------------------------------------- 1 | 13 2 | 29 3 | 37 4 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input27.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input3.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input4.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/input4.txt -------------------------------------------------------------------------------- /test_compile/testfiles/B/input5.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input6.txt: -------------------------------------------------------------------------------- 1 | 12308760 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input7.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/B/input8.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/input9.txt: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output1.txt: -------------------------------------------------------------------------------- 1 | 19373749 2 | 4 3 | 2 4 | no 5 | 0 6 | 0 7 | 0 8 | 1 9 | 1 10 | -1 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output10.txt: -------------------------------------------------------------------------------- 1 | 19373330 2 | n 4 3 | p 25 4 | i 1 5 | sum of two D 3 6 | const D + 10 is 10 -_- 7 | after sort 1 1 3 4 5 8 | Squ const2 + 101 115 9 | slee882641 10 | sadhiukashjfasodifd51023sad65saf1erwg0fdss5a6d1asd56sa0ds55saad511sa2d31asd556gdsfsadsa 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output11.txt: -------------------------------------------------------------------------------- 1 | 19182616 2 | 5 is a prime number 3 | c and d are both positive 4 | 2 5 | 3 6 | 4 7 | 1 8 | 2 9 | 5 10 | 6 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output12.txt: -------------------------------------------------------------------------------- 1 | 19182622 2 | 19182622 3 | 19182622 4 | 19182622 5 | 19182622 6 | 19182622 7 | 19182622 8 | 19182622 9 | 19182622 10 | 19182622 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output14.txt: -------------------------------------------------------------------------------- 1 | 19373459 2 | f1: 8221 3 | f0: 0 4 | ori00:5577 5 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output15.txt: -------------------------------------------------------------------------------- 1 | 19373479 2 | print int : 2 3 | print int : 2 4 | print int : 0 5 | print int : 41 6 | print int : 61 7 | print int : 4884 8 | print int : -45015 9 | print int : 10432 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output16.txt: -------------------------------------------------------------------------------- 1 | 19373466 2 | const declaration: const int a[4][2]={{1, 2}, {3, 4}, {5, 6}, {7, 8}}, b[2][1] = {{9}, {10}} 3 | global var declaration: int c[1][2]={{11, 12}} 4 | global var declaration(not initialized): des[4][1], des2[4][2] 5 | use ConstDef in FuncFParam (exactly, the len of array) 6 | calculate a * b, your result is des[4][1] = {{29}, {67}, {105}, {143}} 7 | calculate des * c 8 | then calculate the sum of each row(store in rowSum[4]) 9 | your result is (4 row): 667, 1541, 2415, 3289 10 | finish 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output18.txt: -------------------------------------------------------------------------------- 1 | 19373755 2 | n1 = 100 3 | n2-5 = -30 4 | n2 + n3 = -15 5 | n2 * n3 = -250 6 | ! ()*+,-./0123456789:; 7 | <=>?@ 8 | ABCDEFGHIJKLMNOPQRSTUVWXYZ 9 | []^_` 10 | abcdefghijklmnopqrstuvwxyz{|}~ -------------------------------------------------------------------------------- /test_compile/testfiles/B/output19.txt: -------------------------------------------------------------------------------- 1 | 19373135 2 | test func, should be 2: 2 3 | test func, should be 2: 2 4 | test Exp, should be 5: 5 5 | test Block, should be 2: 2 6 | test if, should be 2, 2: 2, 2 7 | test while, should be 6: 6 8 | test break continue, should be 0, 1: 0, 1 9 | test printf, should be 2: 2 10 | test getint, should be 1: 1 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output2.txt: -------------------------------------------------------------------------------- 1 | 19231007 2 | input recurrent cycle: 3 | cycle is: 2 4 | input initial value: 5 | initial value is: 2 6 | your input is good 7 | A = 7 8 | B = 3 9 | C = 1 10 | final value is: 1010 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output20.txt: -------------------------------------------------------------------------------- 1 | 19373408 all weak points 2 | L and Eq is ok (no params) 3 | Rel is ok (with params) 4 | Add is ok1 5 | Add is ok2 6 | -1 7 | -1 8 | 1 9 | 1 10 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output21.txt: -------------------------------------------------------------------------------- 1 | 19373384 2 | [1, 3, 5, 7, 9, 11, 2, 9, 7, 8] 3 | [2, 5, 4, 8, 9, 6, 3, 7, 1, 1] 4 | Inner product: expect 324, output: 324 5 | SBC step 1: expect:[12, 25, 26, 42, 49, 44, 17, 43, 21, 23] 6 | output:[12, 25, 26, 42, 49, 44, 17, 43, 21, 23] 7 | SBC step 2 and EWM: expect:[70, 350, 276, 904, 1170, 666, 144, 784, 50, 54] 8 | output:[70, 350, 276, 904, 1170, 666, 144, 784, 50, 54] 9 | 10 | 11 | ================================================================================ 12 | PASSED 13 | ================================================================================ 14 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output22.txt: -------------------------------------------------------------------------------- 1 | 19373339 2 | 2 3 | 3 4 | 4 5 | 13 6 | 2 7 | 123456 8 | 123456 9 | 123456 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output23.txt: -------------------------------------------------------------------------------- 1 | 19373611 2 | 19373611 3 | 19373611 4 | Please input base number a: 5 | Please input base number b: 6 | The No.0 number is -4. 7 | The No.1 number is 0. 8 | The No.2 number is 5. 9 | The No.3 number is 14. 10 | The No.4 number is 45. -------------------------------------------------------------------------------- /test_compile/testfiles/B/output24.txt: -------------------------------------------------------------------------------- 1 | 19373063 2 | 1.localVirable1 = 11,localVirable2 = 10 3 | 2. 4 | [2][0]:10|10 , [2]:-7|30 5 | [1][0]:8|8 , [1]:-8|20 6 | [0][0]:6|6 , [0]:-9|10 7 | 9? 8 | 3.function of kinds of parameters testified 9 | 4.non exp testified -------------------------------------------------------------------------------- /test_compile/testfiles/B/output25.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | m = 6, n = 23, mm = 26, nn = 353 3 | max of mm and nn: 353; min of mm and nn: 26 4 | mainConst1 = 10 5 | Sum of normalConst: 35 6 | 23 is odd! 7 | Sum of array: 6 8 | sum of array: 24 9 | array contains 4 even number! 10 | All even! 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output26.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | m = 3, n = 13, mm = 29, nn = 37 3 | max of mm and nn: 37; min of mm and nn: 29 4 | mainConst1 = 10 5 | Sum of normalConst: 66 6 | 13 is odd! 7 | Sum of array: 3 8 | sum of array: 24 9 | array contains 3 even number! 10 | All even! 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output27.txt: -------------------------------------------------------------------------------- 1 | 1837518218183751821837518218375182 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output3.txt: -------------------------------------------------------------------------------- 1 | 19231111 2 | 0 2 3 0 3 | 0 2 3 0 4 | 6 2 12 6 5 | 23 20 55 48 6 | 5 7 | true 8 | true 9 | 2 10 | 123 11 | 123 12 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output4.txt: -------------------------------------------------------------------------------- 1 | 19231047 2 | climb 0 : 1 3 | climb 3 : 3 4 | climb 6 : 13 5 | test return1 : 14 6 | test climb sum 7 : 21 7 | test product - sum : 2854 8 | test nest 1 : 13 9 | test nest 2 : 89 10 | test file -------------------------------------------------------------------------------- /test_compile/testfiles/B/output5.txt: -------------------------------------------------------------------------------- 1 | 19231177 2 | b=5 3 | 20 4 | 30 5 | testBlock : b=1524 6 | result = 79626240 7 | 1 2 3 4 sum is : 10 8 | line1 is:11111;line2 is : 22222; line3 is : 33333; 9 | 1+2=3 10 | 1+2=3 11 | 19231177 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output6.txt: -------------------------------------------------------------------------------- 1 | 19231150 2 | what you enter in is:12308760 3 | _a=5 4 | array_c[0] is:1 5 | array_d[0][0] is:1 6 | array_d[1][0] is:2 7 | _a=10 8 | _a=103 9 | 2 2 2 3 3 3 3 5 29 131 10 | Over -------------------------------------------------------------------------------- /test_compile/testfiles/B/output7.txt: -------------------------------------------------------------------------------- 1 | 19231188111111111 -------------------------------------------------------------------------------- /test_compile/testfiles/B/output8.txt: -------------------------------------------------------------------------------- 1 | 19231076 2 | >/!~varg1 is:1;~ 3 | >/!~varg2 is:6;~ 4 | >/!~varg3 is:7;~ 5 | >/!~varg4 is:6;~ 6 | >/!~varg5 is:5;~ 7 | >/!~varg6 is:4;~ 8 | >/!~varg7 is:3;~ 9 | >/!~varg8 is:2;~ 10 | >/!~varg9 is:-1;~ 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/B/output9.txt: -------------------------------------------------------------------------------- 1 | 193733852345678910 -------------------------------------------------------------------------------- /test_compile/testfiles/B/testfile11.txt: -------------------------------------------------------------------------------- 1 | const int MAX = 6; 2 | 3 | int main() 4 | { 5 | printf("19182616\n"); 6 | int a = 0; 7 | int num = 0; 8 | int i = 2; 9 | int c,d; 10 | int j = 1, sum; 11 | int k; 12 | num = getint(); 13 | c = getint(); 14 | d = getint(); 15 | sum = getint(); 16 | k = getint(); 17 | if(num >= 2) 18 | { 19 | while(i0 && d>0) 36 | { 37 | printf("c and d are both positive\n"); 38 | } 39 | else 40 | { 41 | printf("Neither c nor d are positive\n"); 42 | } 43 | 44 | while(1) 45 | { 46 | sum = sum + 1; 47 | printf("%d\n", sum); 48 | j = j + 1; 49 | if(j > 3)break; 50 | } 51 | while(k= 3){ 5 | printf("%d\n",id); 6 | i = i - 1; 7 | } 8 | while(i > 0){ 9 | printf("%d\n",id); 10 | i = i - 1; 11 | } 12 | int j = 0; 13 | while(j <= 3){ 14 | printf("%d\n",id); 15 | j = j + 1; 16 | } 17 | while(j < 5){ 18 | printf("%d\n",id); 19 | j = j + 1; 20 | } 21 | return; 22 | } 23 | 24 | int playID(int id) 25 | { 26 | int i = 0; 27 | while(i < id){ 28 | i = i + 1; 29 | if(i == 711){ 30 | continue; 31 | } 32 | if(i == 19182622){ 33 | break; 34 | } 35 | } 36 | return i; 37 | } 38 | int block(){return 1;} 39 | 40 | int main() 41 | { 42 | const int id = 19182622; 43 | printMyID(id); 44 | while(0); 45 | return 0; 46 | } -------------------------------------------------------------------------------- /test_compile/testfiles/B/testfile14.txt: -------------------------------------------------------------------------------- 1 | const int Mod = 10007; 2 | 3 | const int Map[2][2] = { 4 | {1, 1}, 5 | {1, 0} 6 | }, Bound[2] = {2, 2}; 7 | 8 | int T, f[2] = {1, 0}; 9 | int ori[2][2] = { 10 | {1, 0}, 11 | {0, 0} 12 | }; 13 | 14 | void calc(int a[][2], int b[][2]) { 15 | int i = 0, j = 0, k = 0; 16 | int Map[2][2]; 17 | while (i < Bound[0]) { 18 | j = 0; 19 | while (j < Bound[1]) { 20 | k = 0; 21 | int sum = 0; 22 | while (k < Bound[0]) { 23 | sum = (sum + a[i][k] * b[k][j] % Mod) % Mod; 24 | k = k + 1; 25 | } 26 | Map[i][j] = sum; 27 | j = j + 1; 28 | } 29 | i = i + 1; 30 | } 31 | i = 0; 32 | j = 0; 33 | while (i < Bound[0]) { 34 | while (j < Bound[1]) { 35 | a[i][j] = Map[i][j]; 36 | j = j + 1; 37 | } 38 | i = i + 1; 39 | } 40 | } 41 | 42 | int getans(int a[]) { 43 | int i = 0, sum = 0; 44 | while (i < Bound[0]) { 45 | sum = sum + a[i]; 46 | i = i + 1; 47 | } 48 | return sum; 49 | } 50 | 51 | void Copy(int a[][2]) { 52 | a[0][0] = Map[0][0]; a[0][1] = Map[0][1]; 53 | a[1][0] = Map[1][0]; a[1][1] = Map[1][1]; 54 | } 55 | 56 | int main() { 57 | printf("19373459\n"); 58 | T = getint(); 59 | int temp[2][2]; 60 | Copy(temp); 61 | while (T) { 62 | if (T / 2 * 2 != T) { 63 | calc(ori, temp); 64 | } else {} 65 | T = T / 2; 66 | calc(temp, temp); 67 | } 68 | int i = 0; 69 | while (i < Bound[0]) { 70 | printf("f%d: %d\n", f[i], getans(ori[i])); 71 | i = i + 1; 72 | } 73 | printf("ori00:%d\n", ori[0][0]); 74 | return 0; 75 | } -------------------------------------------------------------------------------- /test_compile/testfiles/B/testfile5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/B/testfile5.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/input1.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input10.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/input10.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input11.txt: -------------------------------------------------------------------------------- 1 | 5 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/input12.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input13.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input14.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input15.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input16.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 15 3 | 6 4 | 6 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input17.txt: -------------------------------------------------------------------------------- 1 | 12345 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input18.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | -1 5 | 1 6 | 2 7 | 2 8 | -1 9 | 2 10 | 2 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input19.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/input19.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input2.txt: -------------------------------------------------------------------------------- 1 | 54633487 2 | 632917 3 | 30 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input20.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input21.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 2 4 | 3 5 | 3 6 | 4 7 | 2 8 | 4 9 | 0 10 | 1 11 | 1 12 | 0 13 | 123456789 14 | 987654321 15 | -1 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input22.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input23.txt: -------------------------------------------------------------------------------- 1 | 0 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input24.txt: -------------------------------------------------------------------------------- 1 | 19260817 2 | 114514 3 | 1919810 4 | 4 5 | 16 6 | 13 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input25.txt: -------------------------------------------------------------------------------- 1 | 11 2 | 13 3 | 12341 4 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input26.txt: -------------------------------------------------------------------------------- 1 | 33 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input27.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input28.txt: -------------------------------------------------------------------------------- 1 | 6 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input29.txt: -------------------------------------------------------------------------------- 1 | 233 2 | 1 3 | 42 4 | -15 5 | 0 6 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input3.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 23 3 | 3 4 | 4 5 | 52 6 | 6 7 | 7 8 | 8 9 | 99 10 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input4.txt: -------------------------------------------------------------------------------- 1 | 56 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input5.txt: -------------------------------------------------------------------------------- 1 | -4 2 | 0 3 | 1 4 | 2 5 | 3 6 | 4 7 | 5 8 | 6 9 | 7 10 | 8 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/input6.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/input6.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input7.txt: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /test_compile/testfiles/C/input8.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/input8.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/input9.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output1.txt: -------------------------------------------------------------------------------- 1 | 19231204 2 | + is error! 3 | + is error! 4 | + is error! 5 | + is error! 6 | Break is error! 7 | a1+b1 is 3 8 | a2+b2 is -2 9 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output10.txt: -------------------------------------------------------------------------------- 1 | 19373025 2 | 1 3 | funi 4 | try 5 | try 6 | try 7 | try 8 | try 9 | try 10 | try -------------------------------------------------------------------------------- /test_compile/testfiles/C/output11.txt: -------------------------------------------------------------------------------- 1 | 19182650 2 | this is d 3 | 4 4 | 5 5 | 4 6 | 5 7 | 2 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output12.txt: -------------------------------------------------------------------------------- 1 | 19182623 2 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output13.txt: -------------------------------------------------------------------------------- 1 | 10, 30972, -5 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output14.txt: -------------------------------------------------------------------------------- 1 | 19373372 2 | fact[10] = 3628800 3 | fact[1] = 1 4 | fact[2] = 2 5 | fact[3] = 6 6 | fact[4] = 24 7 | fact[5] = 120 8 | fact[6] = 720 9 | fact[7] = 5040 10 | fact[8] = 40320 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output15.txt: -------------------------------------------------------------------------------- 1 | 19373479 2 | print int : 0 3 | print int : 2 4 | print int : 2 5 | print int : 0 6 | print int : 41 7 | print int : 61 8 | print int : 4884 9 | print int : -45015 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output16.txt: -------------------------------------------------------------------------------- 1 | 19373373 2 | j : 4, k : 10, l : 4 3 | a! = 720, num = 5 4 | 6 5 | scanf a, b to get gcd and lcm 6 | gcd is 5 7 | lcm is 30 8 | -6 9 | scanf a to get Fibonacci 10 | fib is 8 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output17.txt: -------------------------------------------------------------------------------- 1 | 19373682 2 | hello? 12345 12345 12345 3 | func1 done! 4 | func2 done! 5 | func3 input = 0 6 | func3 done! 7 | 204 204 100 100 20400 100 0 100 100 8 | func4 done! 9 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output18.txt: -------------------------------------------------------------------------------- 1 | 19373719 2 | 0 -2 3 | 0 2 4 | 4 5 | 0 6 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output19.txt: -------------------------------------------------------------------------------- 1 | 19373135 2 | l_const_0, should be 0: 0 3 | l_const_1, should be 1: 1 4 | l_const_3, should be 2: 2 5 | l_const_5[2], l_const_6[0][1], should be 3, 1: 3, 1 6 | l_var_0, should be 0: 0 7 | l_var_1, should be 2: 2 8 | l_var_3, should be 4: 4 9 | l_var_5, should be 5: 5 10 | l_var_6[2], l_var_7[0][1], should be 3, 1: 3, 1 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output2.txt: -------------------------------------------------------------------------------- 1 | 18375200 2 | -163900461 3 | -628 4 | -925500 5 | ppgod7mi 6 | 4396yoga7 7 | 2333 8 | 9 | 10 | 11 | 632917 is not a prime, with factor 41. 12 | The 30th Fibonacci num is 832040. -------------------------------------------------------------------------------- /test_compile/testfiles/C/output20.txt: -------------------------------------------------------------------------------- 1 | 19373061 2 | 0 3 | 1 4 | 0 5 | 0 6 | 1 7 | 0 8 | 1 9 | 0 10 | t:1 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output21.txt: -------------------------------------------------------------------------------- 1 | gcd is 1 2 | gcd is 1 3 | gcd is 1 4 | gcd is 2 5 | invaild input! 6 | invaild input! 7 | gcd is 9 8 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output22.txt: -------------------------------------------------------------------------------- 1 | 19373034 2 | 1 3 | 1 4 | 0 5 | 1 6 | 0 7 | 10 8 | 8 9 | 9 10 | 10 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output23.txt: -------------------------------------------------------------------------------- 1 | 19373044 2 | s+1=2 3 | m=0 4 | m=1 5 | m=0 6 | m=0 7 | m=1 8 | m=2 9 | m=3 10 | before break -------------------------------------------------------------------------------- /test_compile/testfiles/C/output24.txt: -------------------------------------------------------------------------------- 1 | 19373022 2 | b:-19260604 3 | Bool1 is false! 4 | 1919820 5 | 1932053504 6 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output25.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | the num is 851 3 | the num is 11 4 | the num is 13 5 | the num is 12341 6 | 11 is odd! 7 | 13 is odd! 8 | max of 11 and 13 is 13 9 | min of 11 and 13 is 11 10 | No, 12341 is not a prime! It has a factor 7 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output26.txt: -------------------------------------------------------------------------------- 1 | 19373276 2 | !()*+,-./0123456789:;<>=?@[]^_`~{}| 3 | qwertyuiopasd 4 | fghjklzxcvbnmQWERTYUIOPASD 5 | FGHJKLZXCVBNM0 6 | 72 23 7 | addSum: 105, 45 8 | -2169 9 | 1008-6 10 | end -------------------------------------------------------------------------------- /test_compile/testfiles/C/output27.txt: -------------------------------------------------------------------------------- 1 | 19373315 2 | this is a yu ju ky 3 | unbelievable! 4 | var_a from getint() is 1 5 | getint is 1 6 | tmp 7 | tmp 8 | tmp 9 | tmp 10 | tmp 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output28.txt: -------------------------------------------------------------------------------- 1 | 19373332 2 | Stmt-3(Block): c = 2, d = 46 3 | Stmt-3(Block): e = 4, f = 829 4 | Stmt-4(if) check finish! 5 | Stmt-5,6 check finish! 6 | Stmt-7 check finish! 7 | Stmt-8 check finish! 8 | 9 | FormatChar. 10 | 13 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output29.txt: -------------------------------------------------------------------------------- 1 | 19373348 2 | Got a number: 233! 3 | 247 4 | Got a number: 1! 5 | -3 6 | Got a number: 42! 7 | 738 8 | Got a number: -15! 9 | 1711 10 | Got a number: 0! 11 | 3667 12 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output3.txt: -------------------------------------------------------------------------------- 1 | 19231177 2 | 1 3 | 23 4 | 3 5 | 4 6 | 52 7 | 6 8 | 7 9 | 8 10 | 99 11 | 10 12 | appear 13 | 20 14 | not 15 | 30 16 | not 17 | 40 18 | not 19 | 50 20 | not 21 | 60 22 | not 23 | 99 24 | not 25 | 99 26 | not 27 | 99 28 | not 29 | print123 30 | 123 31 | /****/123 32 | /**/123 33 | print return value : 34 | in : 5 ,out = 50 35 | in : 5 ,out = 50 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output4.txt: -------------------------------------------------------------------------------- 1 | 19231204 2 | The score is 56. 3 | Yes! 4 | Yes! 5 | Yes! 6 | No! -------------------------------------------------------------------------------- /test_compile/testfiles/C/output5.txt: -------------------------------------------------------------------------------- 1 | 16061069 2 | input an integer,judge if it is prime number,10 groups in total 3 | input > 0 is needed 4 | input > 0 is needed 5 | 1 is not concerned 6 | 2 is a prime number 7 | 3 is a prime number 8 | 4 is not a prime number 9 | 5 is a prime number 10 | 6 is not a prime number 11 | 7 is a prime number 12 | 8 is not a prime number 13 | while times is 22 in total 14 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/output6.txt: -------------------------------------------------------------------------------- 1 | 19231177 2 | _ = 1; a = 20; b = 30; c = 460; 3 | 20+30=50; 460-1=459; 50*459=22950; 459/50=9; 22950mod30=0 4 | 50+459+22950=23459; 459-22950-9=-22500; 22950*9*0=0; 0/50/459=0; 9mod0mod50=9 5 | 10+17-23*37/43mod71-17*23+43=-340=-340 6 | 10+(17-23)*37/43mod(71-37)*-340=1710 7 | all chars : !()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~ 8 | 5!+7+3=130 9 | max: 2147483647 ; min : -2147483647 ; sum : 0 10 | 19231177 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output7.txt: -------------------------------------------------------------------------------- 1 | 19373755 2 | n = -864 3 | n = -7938 4 | n = 10 5 | n = -15 6 | n = 861 7 | n = 0 8 | test_if done! 9 | test_while done! 10 | test_break_continue done! -------------------------------------------------------------------------------- /test_compile/testfiles/C/output8.txt: -------------------------------------------------------------------------------- 1 | 19182650 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 21 9 | 1 10 | 6 -------------------------------------------------------------------------------- /test_compile/testfiles/C/output9.txt: -------------------------------------------------------------------------------- 1 | 19231076 2 | >/!~varg1 is:-1;~ 3 | >/!~varg2 is:-8;~ 4 | >/!~varg3 is:7;~ 5 | >/!~varg4 is:6;~ 6 | >/!~varg5 is:5;~ 7 | >/!~varg6 is:4;~ 8 | >/!~varg7 is:3;~ 9 | >/!~varg8 is:2;~ 10 | >/!~varg9 is:1;~ 11 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile1.txt: -------------------------------------------------------------------------------- 1 | const int a1 = 1, a2 = +3, a3 = 8; 2 | int b1 = 0 + 2, b2 = -5, b3 = +6; 3 | 4 | int main() { 5 | printf("19231204"); 6 | printf("\n"); 7 | int n = 10; 8 | while (n) { 9 | n = n - 1; 10 | if (n < b3) { 11 | continue; 12 | printf("Continue is error!\n"); 13 | } 14 | if (n < a1) { 15 | break; 16 | printf("Break is error!And < is error!\n"); 17 | } 18 | if (n == a2) { 19 | printf("+ is correct!\n"); 20 | } else { 21 | printf("+ is error!\n"); 22 | } 23 | if (n == b1) { 24 | break; 25 | } 26 | } 27 | if (n != b1) { 28 | if (n == 0) { 29 | printf("Break is error!\n"); 30 | } else { 31 | printf("Continue is error!\n"); 32 | } 33 | } 34 | printf("a1+b1 is %d\n", a1 + b1); 35 | printf("a2+b2 is %d\n", a2 + b2); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile10.txt: -------------------------------------------------------------------------------- 1 | const int ci=1; 2 | const int ciexp=1+1*1/1%1-1; 3 | const int ca=1,cb=2; 4 | int i=-+1; 5 | int iexp=1+1*1/1%1-1; 6 | int a=1,b=2; 7 | void funv(int a,int b) {{ 8 | printf("funv\n"); 9 | }} 10 | int funi(int a){ 11 | printf("funi\n"); 12 | return 0; 13 | } 14 | int funvnop(){ 15 | return 0; 16 | } 17 | int main() { 18 | int ma1,ma2,ma3,ma4; 19 | printf("19373025\n"); 20 | ma1=1; 21 | ma2=1+1; 22 | ma3=1; 23 | ma4=1; 24 | if(ma1!=ma2) { 25 | int mif1=1; 26 | printf("%d\n",mif1); 27 | } else { 28 | return 0; 29 | } 30 | if(ma1==ma3){ 31 | funi(ma1); 32 | } 33 | if(ma1!=ma3){ 34 | funvnop(); 35 | } 36 | if(ma1>=ma3){ 37 | 38 | } 39 | if(ma2<=ma3){ 40 | funvnop(); 41 | } 42 | if(ma1>ma3){ 43 | funvnop(); 44 | } 45 | if(ma2= 2) _6 = 1; 17 | else _6 = 0; 18 | while (_5 <= _4 / 2) { 19 | if (_4 % _5 == 0) { 20 | _6 = 0; 21 | break; 22 | } 23 | _5 = _5 + 1; 24 | } 25 | if (_6 == 0)printf("%d is not a prime, with factor %d.\n", _4, _5); 26 | else printf("%d is a prime.\n", _4); 27 | _7 = getint(); 28 | _8 = 1; 29 | _9 = 1; 30 | _2 = 2; 31 | while (_2 < _7) { 32 | _3 = (_8 + _9) % 1000007; 33 | _8 = _9; 34 | _9 = _3; 35 | _2 = _2 + 1; 36 | } 37 | printf("The %dth Fibonacci num is %d.", _7, _9); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile20.txt: -------------------------------------------------------------------------------- 1 | 2 | int isPrime(int m) { 3 | int i; 4 | i = 2; 5 | while (i < m) { 6 | if (m % i == 0) 7 | return 0; 8 | i = i + 1; 9 | } 10 | return 1; 11 | } 12 | 13 | 14 | void check_group(int t[]) { 15 | int i; 16 | i = 0; 17 | while (i < 2) { 18 | int tmp; 19 | tmp = t[i]; 20 | tmp = isPrime(tmp); 21 | printf("%d\n", tmp); 22 | i = i + 1; 23 | } 24 | 25 | 26 | } 27 | 28 | int test(int t[][2]) { 29 | if (!t[0][1]) { 30 | ; 31 | } 32 | return 0; 33 | } 34 | 35 | int main() { 36 | 37 | printf("19373061\n"); 38 | int num; 39 | num = 30; 40 | printf("%d\n", isPrime(num)); 41 | num = 31; 42 | printf("%d\n", isPrime(num)); 43 | int tmp[3][2] = {{111, 2222},{3, 4},{5, 6}}; 44 | check_group(tmp[0]); 45 | check_group(tmp[1]); 46 | check_group(tmp[2]); 47 | 48 | int t; 49 | t = 1; 50 | while (t > 0) { 51 | if (t < 10) 52 | break; 53 | t = t + 1; 54 | } 55 | printf("t:%d\n", t); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile21.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/testfile21.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile23.txt: -------------------------------------------------------------------------------- 1 | 2 | int a,b=2+0; 3 | int c=3+0; 4 | int d=4; 5 | 6 | void shayemeiyou(){ 7 | int m; 8 | } 9 | int yi(){ 10 | return 1; 11 | } 12 | int pidoubushi(int n){ 13 | return 0; 14 | } 15 | int mult(int g,int k){ 16 | return g*k; 17 | } 18 | int main(){ 19 | int i=0; 20 | int m; 21 | int s=1; 22 | printf("19373044\n"); 23 | printf("s+1=%d\n",s+1); 24 | m=getint(); 25 | printf("m=%d\n",m); 26 | { 27 | } 28 | if(!m){ 29 | m=m+yi(); 30 | } 31 | printf("m=%d\n",m); 32 | if(m==1){ 33 | m=m-1; 34 | } 35 | else; 36 | printf("m=%d\n",m); 37 | while(m!=3){ 38 | printf("m=%d\n",m); 39 | m=-+-((mult(m,1)/1+1)%4); 40 | } 41 | i=mult(m,1); 42 | printf("m=%d\n",m); 43 | while(m>0){ 44 | if(m<=0){ 45 | continue; 46 | } 47 | printf("before break\n"); 48 | break; 49 | } 50 | if(m>=0){ 51 | } 52 | return 0; 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile29.txt: -------------------------------------------------------------------------------- 1 | const int A = 1; 2 | const int B = 2, C = 3, D = 4; 3 | 4 | int n = 10; 5 | int m = 20, p = 99, q = 66; 6 | 7 | void f0() { 8 | return; 9 | } 10 | 11 | int f1(int x) { 12 | if (x >= 0) { 13 | x = x + 1;;;; 14 | } 15 | 16 | if (x <= 0) { 17 | x = x + 1; 18 | } else { 19 | } 20 | 21 | { 22 | x = x + 1; 23 | } 24 | 25 | while (x < 0) { 26 | x = -x; 27 | } 28 | 29 | while (x > 0) { 30 | x = -x; 31 | continue; 32 | } 33 | 34 | while (x == 0) 35 | x = x + 1; 36 | 37 | while (x != 0) { 38 | break; 39 | } 40 | 41 | while (1) { 42 | while (!1) { 43 | } 44 | break; 45 | } 46 | 47 | return x; 48 | } 49 | 50 | int f2(int x, int y, int z) { 51 | int a; 52 | a = x + n * B - m / C + z % (A + B) + 233 + -y + f1(y); 53 | a = a * +A; 54 | return x + y + a; 55 | } 56 | 57 | int gi() { 58 | int r; 59 | r = getint(); 60 | printf("Got a number: "); 61 | printf("%d!\n", r); 62 | return r; 63 | } 64 | 65 | int main() { 66 | printf("19373348\n"); 67 | 68 | int a = f2(1, 2, gi()); 69 | f0(); 70 | printf("%d\n", a); 71 | printf("%d\n", f1(gi())); 72 | int b = f2(a, A, gi()), c, d; 73 | printf("%d\n", b); 74 | c = f2(b, n, gi()); 75 | printf("%d\n", c); 76 | printf("%d\n", f2(c, gi(), q)); 77 | d = 0; 78 | return d; 79 | } 80 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile3.txt: -------------------------------------------------------------------------------- 1 | //#include 2 | const int a = 9; 3 | const int b = a; 4 | int d = a; 5 | 6 | //int getint(){ 7 | // int n; 8 | // scanf("%d",&n); 9 | // return n; 10 | // 11 | //} 12 | int mycheck(int a){ 13 | if (a == 1) return 10; 14 | if (a==2) return 20; 15 | if (a==4) return 40 ; 16 | else if (a==5) return 50; 17 | else if (a == 6) return 60; 18 | if (a==3) return 30 ;else return 99 ; 19 | return 0; 20 | return 1; 21 | } 22 | 23 | void testGetInt(){ 24 | int i = 0; 25 | 26 | while(i<9){ 27 | int temp; 28 | temp = getint(); 29 | printf("%d\n",temp); 30 | i = i + 1; 31 | } 32 | } 33 | 34 | 35 | int main(){ 36 | const int in1 = 89; 37 | const int in2 = in1; 38 | int vin1 = in1; 39 | int vin2 = vin1; 40 | int vin3 = in2; 41 | int vin4 = a + b; 42 | int vin5 = d; 43 | 44 | 45 | printf("%d\n",19231177); 46 | testGetInt(); 47 | int a = 1; 48 | while(a<10){ 49 | printf("%d\n",mycheck(a)); 50 | if (mycheck(a) < mycheck(mycheck(a)/20) ){ 51 | printf("appear\n"); 52 | }else{ 53 | printf("not\n"); 54 | } 55 | a = a + 1; 56 | } 57 | int a1 = 1,a2 = 2,a3 = 3; 58 | printf("print123\n"); 59 | printf("%d%d%d\n",1,2,3); 60 | printf("/****/%d%d%d\n",1,a2,a3); 61 | printf("/**/%d%d%d\n",a1,a2,a3); 62 | printf("print return value :\n"); 63 | int temp = 5; 64 | printf("in : 5 ,out = %d\n",mycheck(5)); 65 | printf("in : 5 ,out = %d\n",mycheck(temp)); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile4.txt: -------------------------------------------------------------------------------- 1 | const int max_number = 100; 2 | const int min_number = 0; 3 | int a = 0; 4 | int main(){ 5 | printf("19231204"); 6 | printf("\n"); 7 | int score; 8 | int b = 30; 9 | score = getint(); 10 | if (score >= min_number){ 11 | printf("The score is %d.\n",score); 12 | } 13 | a = 4 / 2; 14 | if (a == 2){ 15 | printf("Yes!\n"); 16 | } 17 | a = 3 + 5; 18 | if (a != 8){ 19 | printf("No!\n"); 20 | }else{ 21 | printf("Yes!\n"); 22 | } 23 | a = 10 * 10; 24 | if (a <= max_number){ 25 | printf("Yes!\n"); 26 | } 27 | if (a < max_number){ 28 | printf("Yes!\n"); 29 | } 30 | if (a > b) { 31 | printf("No!"); 32 | }else { 33 | printf("Yes!"); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile6.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/test_compile/testfiles/C/testfile6.txt -------------------------------------------------------------------------------- /test_compile/testfiles/C/testfile8.txt: -------------------------------------------------------------------------------- 1 | int aa(int b[][3]) 2 | { 3 | int w; 4 | w=b[0][0]+b[0][1]+b[0][2]+b[1][0]+b[1][1]+b[1][2]; 5 | return w; 6 | } 7 | int main() 8 | { 9 | printf("19182650\n"); 10 | const int a[2][3]={{1,2,3},{4,5,6}}; 11 | int b[2][3]={{1,2,3},{4,5,6}}; 12 | int c[2][3]; 13 | int d; 14 | d=aa(b); 15 | c[0][0]=b[0][0]; 16 | c[0][1]=b[0][1]; 17 | c[0][2]=b[0][2]; 18 | c[1][0]=b[1][0]; 19 | c[1][1]=b[1][1]; 20 | c[1][2]=b[1][2]; 21 | printf("%d\n",a[0][0]); 22 | printf("%d\n",a[0][1]); 23 | printf("%d\n",a[0][2]); 24 | printf("%d\n",a[1][0]); 25 | printf("%d\n",a[1][1]); 26 | printf("%d\n",a[1][2]); 27 | printf("%d\n",d); 28 | printf("%d\n",c[0][0]); 29 | printf("%d\n",c[1][2]); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /文档/《编译技术》课程设计总结文档.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/《编译技术》课程设计总结文档.pdf -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/.DS_Store -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input10.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input11.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/A/input12.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input13.txt: -------------------------------------------------------------------------------- 1 | 123 2 | 456 3 | 12 4 | 324 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input14.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 0 3 | 1 4 | 6 5 | 8 6 | 20 7 | 30 8 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input15.txt: -------------------------------------------------------------------------------- 1 | 200 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input16.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 60 7 | 70 8 | 80 9 | 90 10 | 100 11 | 1100 12 | 1200 13 | 1300 14 | 1400 15 | 1500 16 | 16000 17 | 17000 18 | 18000 19 | 19000 20 | 24000 21 | 20000 22 | 21000 23 | 22000 24 | 23000 25 | 25000 26 | 0 27 | 1 28 | 550 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input17.txt: -------------------------------------------------------------------------------- 1 | 33 2 | 28 3 | 501 4 | 233 5 | 114 6 | 711 7 | 266 8 | 500 9 | 77 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input18.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input19.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input2.txt: -------------------------------------------------------------------------------- 1 | 4 2 | 1998 3 | 3 4 | 23 5 | 2021 6 | 9 7 | 23 8 | 168 9 | 5 10 | 21 11 | 2020 12 | 1 13 | 1 14 | 2010 15 | 2 16 | 28 17 | 2010 18 | 1 19 | 1 20 | 1998 21 | 2 22 | 25 23 | 1997 24 | 5 25 | 24 26 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input20.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input21.txt: -------------------------------------------------------------------------------- 1 | 42 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input22.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input23.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input24.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 3 4 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input25.txt: -------------------------------------------------------------------------------- 1 | 24 2 | 27 3 | 342526 4 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input26.txt: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input3.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input4.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/A/input4.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/A/input5.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input6.txt: -------------------------------------------------------------------------------- 1 | 4 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input7.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | 12 4 | 23 5 | 34 6 | 45 7 | 2 8 | 2 9 | 34 10 | 45 11 | 56 12 | 67 13 | 1 14 | 3 15 | 4 16 | 1 17 | 1 18 | 1 19 | 1 20 | 2 21 | 2 22 | 2 23 | 2 24 | 3 25 | 3 26 | 3 27 | 3 28 | 1 29 | 2 30 | 4 31 | 4 32 | 3 33 | 1 34 | 1 35 | 2 36 | 3 37 | 3 38 | 12 39 | 23 40 | 54 41 | 32 42 | 12 43 | 21 44 | 34 45 | 12 46 | 54 47 | 2 48 | 2 49 | 1 50 | 1 51 | 1 52 | 1 53 | 2 54 | 34 55 | 54 56 | 2 57 | 3 58 | 1 59 | 2 60 | 2 61 | 2 62 | 1 63 | 3 64 | 12 65 | 23 66 | 34 67 | 3 68 | 4 69 | 1 70 | 1 71 | 2 72 | 3 73 | 4 74 | 3 75 | 2 76 | 12 77 | 23 78 | 23 79 | 34 80 | 45 81 | 56 82 | 1 83 | 1 84 | 5 85 | 12 86 | 23 87 | 34 88 | 45 89 | 56 90 | 1 91 | 3 92 | 12 93 | 23 94 | 34 95 | 3 96 | 1 97 | 1 98 | 1 99 | 1 100 | 1 101 | 2 102 | 2 103 | 2 104 | 2 105 | 14 106 | 325 107 | 231434 108 | 1233 109 | 2 110 | 2 111 | 810975 112 | 114514 113 | 13 114 | 31 115 | 3 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input8.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 3 4 | 4 5 | 5 6 | 6 7 | 7 8 | 8 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/input9.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 12 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output10.txt: -------------------------------------------------------------------------------- 1 | 19373528 2 | f2() flag : 3 3 | f2() flag : 3 4 | flag = 1 : c1 = 3, c2 = -1 5 | f2() flag : 2 6 | f2() flag : 4 7 | flag = 0 : c1 = 13, c2 = -1 8 | f2() flag : 2 9 | f2() flag : 4 10 | flag = 0 : c1 = 23, c2 = -1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output11.txt: -------------------------------------------------------------------------------- 1 | 19182620 2 | 0 3 | 1 4 | 2 5 | 2 6 | 1 7 | 2 8 | 19182620 9 | 19182620 10 | 19182620 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output12.txt: -------------------------------------------------------------------------------- 1 | 19182636 2 | ! is ok 3 | < is ok 4 | > is ok 5 | <= is ok 6 | >= is ok 7 | == != is ok 8 | or is ok 9 | the priority of and/or is ok 10 | 6 7 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output13.txt: -------------------------------------------------------------------------------- 1 | 19373330 2 | max of mnpq is 456 3 | i or m ? 456 4 | out1 456 out2 229044 5 | sum of array var33 is 5583 6 | squ sum of s3 3 7 | max of four number 314721 8 | Kirov reporrrting 1 9 | For the Union 7 10 | okmotherfuckeroveridontwanttobehornyanymoreijustwanttobehappy 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output15.txt: -------------------------------------------------------------------------------- 1 | 19373354 2 | 2 -402114823 3 | 3 423174272 4 | 5 375872692 5 | 7 915987033 6 | 11 -34179219 7 | 13 1498631475 8 | 17 -1060809599 9 | 19 423174272 10 | 23 915987033 11 | 29 1498631475 12 | 31 1640319187 13 | 37 375872692 14 | 41 -2143283456 15 | 43 -34179219 16 | 47 1640319187 17 | 53 375872692 18 | 59 -34179219 19 | 61 1498631475 20 | 67 423174272 21 | 71 915987033 22 | 73 -2143283456 23 | 79 1640319187 24 | 83 423174272 25 | 89 -2143283456 26 | 97 -1060809599 27 | 101 375872692 28 | 103 915987033 29 | 107 -34179219 30 | 109 1498631475 31 | 113 -1060809599 32 | 127 1640319187 33 | 131 423174272 34 | 137 -2143283456 35 | 139 -34179219 36 | 149 375872692 37 | 151 915987033 38 | 157 1498631475 39 | 163 423174272 40 | 167 915987033 41 | 173 1498631475 42 | 179 423174272 43 | 181 375872692 44 | 191 1640319187 45 | 193 -1060809599 46 | 197 375872692 47 | 199 915987033 48 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output16.txt: -------------------------------------------------------------------------------- 1 | 19373459 2 | val20: 0, val21:5369, val22:4821, val23:4682, val24:8093 3 | val30: 0, val32: 7303, val34: 6137 4 | val40: 0, val42:-1, val43:0, val44:-1 5 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output17.txt: -------------------------------------------------------------------------------- 1 | 19373487 2 | the result is:4 3 | the result is:4 4 | out of range!! 5 | the result is:6 6 | the result is:4 7 | out of range!! 8 | the result is:6 9 | the result is:5 10 | the result is:4 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output18.txt: -------------------------------------------------------------------------------- 1 | 19373311 2 | 123 3 | 123 4 | 123 5 | 123 6 | 123 7 | 4 5 6 8 | 36 9 | 16 10 | 10 11 | 63 12 | 36 13 | 1 2 3 14 | 4 5 6 15 | 7 8 9 16 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output19.txt: -------------------------------------------------------------------------------- 1 | 19373135 2 | global g_var_6[1][0]:1, g_var_6[1][1]:1 3 | local l_var_4:1, l_var_5:1, l_var_6:1, l_var_7:10, l_var_8:100 4 | exp l_var_4:1 5 | exp l_var_5:0 6 | exp l_var_6:0 7 | if l_var_4:3 8 | while l_var_5:0 9 | while l_var_5:0 10 | getint l_var_6:1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output2.txt: -------------------------------------------------------------------------------- 1 | 16061069 2 | input groups 3 | input your birth year,month,day,ep:1998 1 1 4 | input current year,month,day,ep:2020 2 2 5 | you have lived 8585 days 6 | input your birth year,month,day,ep:1998 1 1 7 | input current year,month,day,ep:2020 2 2 8 | you have lived 676288 days 9 | input your birth year,month,day,ep:1998 1 1 10 | input current year,month,day,ep:2020 2 2 11 | please input time legally 12 | input your birth year,month,day,ep:1998 1 1 13 | input current year,month,day,ep:2020 2 2 14 | please input time legally 15 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output20.txt: -------------------------------------------------------------------------------- 1 | 19373163 2 | -+-114514 = 114514 3 | -+-114514 > 0 4 | -+- 6 + 7 * (6 -9) / 3 / 2 = 3 5 | var10[1] = 3 6 | var13 = 1 7 | func1() = 0 8 | func3(+-12) = -12 9 | func4(1, var4, var6) = 3 10 | func4(const1, var6[1], var6) = -2 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output21.txt: -------------------------------------------------------------------------------- 1 | 19373384 2 | const and var // decl and def test 3 | expected result: 579, output: 579 4 | function (def and )call test 5 | expected result: {{589, 21}, {599, 31}}, output: {{589, 21}, {599, 31}} 6 | LExp test, falling into infinite loop indicates an error -- pass 7 | simple echo test, get a integer and read back: 42 8 | 9 | 10 | ================================================================================ 11 | PASSED 12 | ================================================================================ 13 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output22.txt: -------------------------------------------------------------------------------- 1 | 19373408 all weak points 2 | L and Eq is ok (no params) 3 | Rel is ok (with params) 4 | Add is ok 5 | getint is ok 6 | -1 7 | -1 8 | 1 9 | 1 10 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output23.txt: -------------------------------------------------------------------------------- 1 | 19373421 2 | const_var1+const_var2=:3 3 | const_array1[1]=:2 4 | array2[0]:=3 5 | g(2):=6 6 | 123456789 7 | 1 8 | 5 9 | 6 10 | AK!!! -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output24.txt: -------------------------------------------------------------------------------- 1 | 19373235 2 | Testing Short-circuit evaluation : 0 1 1 0 1 0 1 1 0 1 1 1 3 | Testing func_pass_array(int a[][4) ...... 4 | 1 2 3 4 5 | 5 6 7 8 6 | 10 11 12 13 7 | Testing func_pass_PartArray(int a[]) ...... 5 6 7 8 8 | Testing func_pass_arrayElement(int a) ...... 3 9 | Testing complex calculate ...... result = -10. 10 | Testing D2array traversal and assignment. 11 | Array array_E: 12 | 0 1 2 13 | 1 2 3 14 | Testing func_if_D2array(a[][3], b) ...... 15 | 0 1 3 16 | 1 2 0 17 | Loop 7 times, once continue, once break. Symbol j = 5. func_while(x, y)is done! 18 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output25.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | m = 3, n = 24, mm = 27, nn = 342526 3 | max of mm and nn: 342526; min of mm and nn: 27 4 | mainConst1 = 10 5 | Sum of normalConst: 35 6 | 24 is even! 7 | Sum of array: 3 8 | sum of array: 24 9 | Contains odd! 10 | 27 and 342526 contains at least an odd! 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output26.txt: -------------------------------------------------------------------------------- 1 | 19373630 2 | 1 3 | 120 4 | 720 5 | 5040 6 | 1 7 | 2 8 | 4 9 | 3 10 | 30250 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output3.txt: -------------------------------------------------------------------------------- 1 | 19373734 2 | 19373734 3 | 19373734 4 | 19373734 5 | 19373734 6 | 19373734 7 | 19373734 8 | 19373734 9 | 19373734 10 | 19373734 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output4.txt: -------------------------------------------------------------------------------- 1 | 19231258 OK1 2 | OK2 3 | OK3 4 | OK4 5 | OK5 6 | OK6 7 | OK7 8 | OK8 9 | OK9 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output5.txt: -------------------------------------------------------------------------------- 1 | 19231011 2 | start checking for logic expressions 3 | check for AND calculation: successfully! 4 | check for OR calculation: successfully! 5 | check for short-circuit calculation: successfully! 6 | end checking 7 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output6.txt: -------------------------------------------------------------------------------- 1 | 19231248-250 2 | 19231248 3 | 19231248 4 | 19231248 5 | 19231248 6 | 19231248 7 | 19231248 8 | 19231248 9 | 19231248 10 | 19231248 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output7.txt: -------------------------------------------------------------------------------- 1 | 19182604 2 | 0 3 | 1 4 | 2 5 | 3 6 | 4 7 | 5 8 | 6 9 | 7 10 | 8 11 | 12 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output8.txt: -------------------------------------------------------------------------------- 1 | 19182619 2 | CscanfOK 3 | DscanfOK 4 | sb:2 5 | continueOK 6 | breakOK 7 | 0Func2OK 8 | Func3OK 9 | Func4OK 10 | end -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/output9.txt: -------------------------------------------------------------------------------- 1 | 19373573 2 | 4 3 | 6 4 | judgeB 2,3 = -1 5 | Hello 12 6 | 10 7 | 0-1 8 | -10 9 | 01 10 | 10 11 | 31 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/testfile11.txt: -------------------------------------------------------------------------------- 1 | 2 | void de() 3 | { 4 | return; 5 | } 6 | 7 | int keke(int i,int j) 8 | { 9 | i=i+j; 10 | return 0; 11 | } 12 | 13 | int jian() 14 | { 15 | int x,y,z; 16 | x=getint(); 17 | y=getint(); 18 | z=x-y; 19 | return z; 20 | } 21 | 22 | int main() 23 | { 24 | printf("19182620\n"); 25 | int a,b,c,d, e,f,g=+1,h,j,k,l,o=-1; 26 | int i=2,n,m,flag=0; 27 | n=getint(); 28 | while(i=e) 71 | { 72 | if(e<=f) 73 | { 74 | if(f!=g) 75 | { 76 | if(c>1) 77 | { 78 | a=1; 79 | } 80 | 81 | 82 | } 83 | 84 | } 85 | } 86 | } 87 | keke(a,b); 88 | 89 | printf("%d\n%d\n%d\n%d\n",d,e,f,g); 90 | printf("19182620\n"); 91 | printf("19182620\n"); 92 | printf("19182620\n"); 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/A/testfile4.txt: -------------------------------------------------------------------------------- 1 | int getlogictrue() { 2 | return 1; 3 | } 4 | int main() { 5 | printf("19231258 "); 6 | if (!0 == 1 && 1 == 1) { 7 | printf("OK1\n"); 8 | } 9 | if (1 == 1 && 1 == 1 && 1 == 1 || 2 == 1 && 1 == 1) { 10 | printf("OK2\n"); 11 | } 12 | if (+-1 == -+-+0 && 1 == 1 && 2 == 2) { 13 | ; 14 | } else { 15 | printf("OK3\n"); 16 | } 17 | if (1 || 2 == 3) { 18 | printf("OK4\n"); 19 | } 20 | if (0 || 0 && 3) { 21 | ; 22 | } else { 23 | printf("OK5\n"); 24 | } 25 | if (0 || 1 && 2) { 26 | printf("OK6\n"); 27 | } 28 | if (1 >= 0 == 1 && 1 || 2 && 3 == 1 > 0) { 29 | printf("OK7\n"); 30 | } else { 31 | printf("OK7\n"); 32 | } 33 | if (1 + 1 > 0 != !1 && 7 || 8 && !7 == 0) { 34 | printf("OK8\n"); 35 | } 36 | if (!(getlogictrue() * 1) >= 0) { 37 | printf("OK9\n"); 38 | } 39 | return 0; 40 | } -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/input1.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input10.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input11.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 2 3 | 3 4 | 1 5 | 0 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/input12.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input13.txt: -------------------------------------------------------------------------------- 1 | 6 2 | 4 3 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input14.txt: -------------------------------------------------------------------------------- 1 | 1150 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input15.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input16.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/input16.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input17.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 19123412 3 | 53 4 | 12142344 5 | 89 6 | 12354123 7 | 35 8 | 32151245 9 | 65 10 | 21532521 11 | 93 12 | 21654212 13 | 13 14 | 12312654 15 | 89 16 | 56335232 17 | 87 18 | 15687643 19 | 78 20 | 56323432 21 | 78 22 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input18.txt: -------------------------------------------------------------------------------- 1 | 123 2 | 0 3 | -234 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input19.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input2.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 2 3 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input20.txt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input21.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/input21.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input22.txt: -------------------------------------------------------------------------------- 1 | 11 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input23.txt: -------------------------------------------------------------------------------- 1 | 5 2 | 9 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input24.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/input24.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input25.txt: -------------------------------------------------------------------------------- 1 | 23 2 | 26 3 | 353 4 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input26.txt: -------------------------------------------------------------------------------- 1 | 13 2 | 29 3 | 37 4 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input27.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input3.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input4.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/input4.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input5.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input6.txt: -------------------------------------------------------------------------------- 1 | 12308760 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input7.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input8.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/input9.txt: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output1.txt: -------------------------------------------------------------------------------- 1 | 19373749 2 | 4 3 | 2 4 | no 5 | 0 6 | 0 7 | 0 8 | 1 9 | 1 10 | -1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output10.txt: -------------------------------------------------------------------------------- 1 | 19373330 2 | n 4 3 | p 25 4 | i 1 5 | sum of two D 3 6 | const D + 10 is 10 -_- 7 | after sort 1 1 3 4 5 8 | Squ const2 + 101 115 9 | slee882641 10 | sadhiukashjfasodifd51023sad65saf1erwg0fdss5a6d1asd56sa0ds55saad511sa2d31asd556gdsfsadsa 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output11.txt: -------------------------------------------------------------------------------- 1 | 19182616 2 | 5 is a prime number 3 | c and d are both positive 4 | 2 5 | 3 6 | 4 7 | 1 8 | 2 9 | 5 10 | 6 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output12.txt: -------------------------------------------------------------------------------- 1 | 19182622 2 | 19182622 3 | 19182622 4 | 19182622 5 | 19182622 6 | 19182622 7 | 19182622 8 | 19182622 9 | 19182622 10 | 19182622 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output14.txt: -------------------------------------------------------------------------------- 1 | 19373459 2 | f1: 8221 3 | f0: 0 4 | ori00:5577 5 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output15.txt: -------------------------------------------------------------------------------- 1 | 19373479 2 | print int : 2 3 | print int : 2 4 | print int : 0 5 | print int : 41 6 | print int : 61 7 | print int : 4884 8 | print int : -45015 9 | print int : 10432 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output16.txt: -------------------------------------------------------------------------------- 1 | 19373466 2 | const declaration: const int a[4][2]={{1, 2}, {3, 4}, {5, 6}, {7, 8}}, b[2][1] = {{9}, {10}} 3 | global var declaration: int c[1][2]={{11, 12}} 4 | global var declaration(not initialized): des[4][1], des2[4][2] 5 | use ConstDef in FuncFParam (exactly, the len of array) 6 | calculate a * b, your result is des[4][1] = {{29}, {67}, {105}, {143}} 7 | calculate des * c 8 | then calculate the sum of each row(store in rowSum[4]) 9 | your result is (4 row): 667, 1541, 2415, 3289 10 | finish 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output18.txt: -------------------------------------------------------------------------------- 1 | 19373755 2 | n1 = 100 3 | n2-5 = -30 4 | n2 + n3 = -15 5 | n2 * n3 = -250 6 | ! ()*+,-./0123456789:; 7 | <=>?@ 8 | ABCDEFGHIJKLMNOPQRSTUVWXYZ 9 | []^_` 10 | abcdefghijklmnopqrstuvwxyz{|}~ -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output19.txt: -------------------------------------------------------------------------------- 1 | 19373135 2 | test func, should be 2: 2 3 | test func, should be 2: 2 4 | test Exp, should be 5: 5 5 | test Block, should be 2: 2 6 | test if, should be 2, 2: 2, 2 7 | test while, should be 6: 6 8 | test break continue, should be 0, 1: 0, 1 9 | test printf, should be 2: 2 10 | test getint, should be 1: 1 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output2.txt: -------------------------------------------------------------------------------- 1 | 19231007 2 | input recurrent cycle: 3 | cycle is: 2 4 | input initial value: 5 | initial value is: 2 6 | your input is good 7 | A = 7 8 | B = 3 9 | C = 1 10 | final value is: 1010 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output20.txt: -------------------------------------------------------------------------------- 1 | 19373408 all weak points 2 | L and Eq is ok (no params) 3 | Rel is ok (with params) 4 | Add is ok1 5 | Add is ok2 6 | -1 7 | -1 8 | 1 9 | 1 10 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output21.txt: -------------------------------------------------------------------------------- 1 | 19373384 2 | [1, 3, 5, 7, 9, 11, 2, 9, 7, 8] 3 | [2, 5, 4, 8, 9, 6, 3, 7, 1, 1] 4 | Inner product: expect 324, output: 324 5 | SBC step 1: expect:[12, 25, 26, 42, 49, 44, 17, 43, 21, 23] 6 | output:[12, 25, 26, 42, 49, 44, 17, 43, 21, 23] 7 | SBC step 2 and EWM: expect:[70, 350, 276, 904, 1170, 666, 144, 784, 50, 54] 8 | output:[70, 350, 276, 904, 1170, 666, 144, 784, 50, 54] 9 | 10 | 11 | ================================================================================ 12 | PASSED 13 | ================================================================================ 14 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output22.txt: -------------------------------------------------------------------------------- 1 | 19373339 2 | 2 3 | 3 4 | 4 5 | 13 6 | 2 7 | 123456 8 | 123456 9 | 123456 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output23.txt: -------------------------------------------------------------------------------- 1 | 19373611 2 | 19373611 3 | 19373611 4 | Please input base number a: 5 | Please input base number b: 6 | The No.0 number is -4. 7 | The No.1 number is 0. 8 | The No.2 number is 5. 9 | The No.3 number is 14. 10 | The No.4 number is 45. -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output24.txt: -------------------------------------------------------------------------------- 1 | 19373063 2 | 1.localVirable1 = 11,localVirable2 = 10 3 | 2. 4 | [2][0]:10|10 , [2]:-7|30 5 | [1][0]:8|8 , [1]:-8|20 6 | [0][0]:6|6 , [0]:-9|10 7 | 9? 8 | 3.function of kinds of parameters testified 9 | 4.non exp testified -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output25.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | m = 6, n = 23, mm = 26, nn = 353 3 | max of mm and nn: 353; min of mm and nn: 26 4 | mainConst1 = 10 5 | Sum of normalConst: 35 6 | 23 is odd! 7 | Sum of array: 6 8 | sum of array: 24 9 | array contains 4 even number! 10 | All even! 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output26.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | m = 3, n = 13, mm = 29, nn = 37 3 | max of mm and nn: 37; min of mm and nn: 29 4 | mainConst1 = 10 5 | Sum of normalConst: 66 6 | 13 is odd! 7 | Sum of array: 3 8 | sum of array: 24 9 | array contains 3 even number! 10 | All even! 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output27.txt: -------------------------------------------------------------------------------- 1 | 1837518218183751821837518218375182 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output3.txt: -------------------------------------------------------------------------------- 1 | 19231111 2 | 0 2 3 0 3 | 0 2 3 0 4 | 6 2 12 6 5 | 23 20 55 48 6 | 5 7 | true 8 | true 9 | 2 10 | 123 11 | 123 12 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output4.txt: -------------------------------------------------------------------------------- 1 | 19231047 2 | climb 0 : 1 3 | climb 3 : 3 4 | climb 6 : 13 5 | test return1 : 14 6 | test climb sum 7 : 21 7 | test product - sum : 2854 8 | test nest 1 : 13 9 | test nest 2 : 89 10 | test file -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output5.txt: -------------------------------------------------------------------------------- 1 | 19231177 2 | b=5 3 | 20 4 | 30 5 | testBlock : b=1524 6 | result = 79626240 7 | 1 2 3 4 sum is : 10 8 | line1 is:11111;line2 is : 22222; line3 is : 33333; 9 | 1+2=3 10 | 1+2=3 11 | 19231177 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output6.txt: -------------------------------------------------------------------------------- 1 | 19231150 2 | what you enter in is:12308760 3 | _a=5 4 | array_c[0] is:1 5 | array_d[0][0] is:1 6 | array_d[1][0] is:2 7 | _a=10 8 | _a=103 9 | 2 2 2 3 3 3 3 5 29 131 10 | Over -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output7.txt: -------------------------------------------------------------------------------- 1 | 19231188111111111 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output8.txt: -------------------------------------------------------------------------------- 1 | 19231076 2 | >/!~varg1 is:1;~ 3 | >/!~varg2 is:6;~ 4 | >/!~varg3 is:7;~ 5 | >/!~varg4 is:6;~ 6 | >/!~varg5 is:5;~ 7 | >/!~varg6 is:4;~ 8 | >/!~varg7 is:3;~ 9 | >/!~varg8 is:2;~ 10 | >/!~varg9 is:-1;~ 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/output9.txt: -------------------------------------------------------------------------------- 1 | 193733852345678910 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/testfile11.txt: -------------------------------------------------------------------------------- 1 | const int MAX = 6; 2 | 3 | int main() 4 | { 5 | printf("19182616\n"); 6 | int a = 0; 7 | int num = 0; 8 | int i = 2; 9 | int c,d; 10 | int j = 1, sum; 11 | int k; 12 | num = getint(); 13 | c = getint(); 14 | d = getint(); 15 | sum = getint(); 16 | k = getint(); 17 | if(num >= 2) 18 | { 19 | while(i0 && d>0) 36 | { 37 | printf("c and d are both positive\n"); 38 | } 39 | else 40 | { 41 | printf("Neither c nor d are positive\n"); 42 | } 43 | 44 | while(1) 45 | { 46 | sum = sum + 1; 47 | printf("%d\n", sum); 48 | j = j + 1; 49 | if(j > 3)break; 50 | } 51 | while(k= 3){ 5 | printf("%d\n",id); 6 | i = i - 1; 7 | } 8 | while(i > 0){ 9 | printf("%d\n",id); 10 | i = i - 1; 11 | } 12 | int j = 0; 13 | while(j <= 3){ 14 | printf("%d\n",id); 15 | j = j + 1; 16 | } 17 | while(j < 5){ 18 | printf("%d\n",id); 19 | j = j + 1; 20 | } 21 | return; 22 | } 23 | 24 | int playID(int id) 25 | { 26 | int i = 0; 27 | while(i < id){ 28 | i = i + 1; 29 | if(i == 711){ 30 | continue; 31 | } 32 | if(i == 19182622){ 33 | break; 34 | } 35 | } 36 | return i; 37 | } 38 | int block(){return 1;} 39 | 40 | int main() 41 | { 42 | const int id = 19182622; 43 | printMyID(id); 44 | while(0); 45 | return 0; 46 | } -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/testfile14.txt: -------------------------------------------------------------------------------- 1 | const int Mod = 10007; 2 | 3 | const int Map[2][2] = { 4 | {1, 1}, 5 | {1, 0} 6 | }, Bound[2] = {2, 2}; 7 | 8 | int T, f[2] = {1, 0}; 9 | int ori[2][2] = { 10 | {1, 0}, 11 | {0, 0} 12 | }; 13 | 14 | void calc(int a[][2], int b[][2]) { 15 | int i = 0, j = 0, k = 0; 16 | int Map[2][2]; 17 | while (i < Bound[0]) { 18 | j = 0; 19 | while (j < Bound[1]) { 20 | k = 0; 21 | int sum = 0; 22 | while (k < Bound[0]) { 23 | sum = (sum + a[i][k] * b[k][j] % Mod) % Mod; 24 | k = k + 1; 25 | } 26 | Map[i][j] = sum; 27 | j = j + 1; 28 | } 29 | i = i + 1; 30 | } 31 | i = 0; 32 | j = 0; 33 | while (i < Bound[0]) { 34 | while (j < Bound[1]) { 35 | a[i][j] = Map[i][j]; 36 | j = j + 1; 37 | } 38 | i = i + 1; 39 | } 40 | } 41 | 42 | int getans(int a[]) { 43 | int i = 0, sum = 0; 44 | while (i < Bound[0]) { 45 | sum = sum + a[i]; 46 | i = i + 1; 47 | } 48 | return sum; 49 | } 50 | 51 | void Copy(int a[][2]) { 52 | a[0][0] = Map[0][0]; a[0][1] = Map[0][1]; 53 | a[1][0] = Map[1][0]; a[1][1] = Map[1][1]; 54 | } 55 | 56 | int main() { 57 | printf("19373459\n"); 58 | T = getint(); 59 | int temp[2][2]; 60 | Copy(temp); 61 | while (T) { 62 | if (T / 2 * 2 != T) { 63 | calc(ori, temp); 64 | } else {} 65 | T = T / 2; 66 | calc(temp, temp); 67 | } 68 | int i = 0; 69 | while (i < Bound[0]) { 70 | printf("f%d: %d\n", f[i], getans(ori[i])); 71 | i = i + 1; 72 | } 73 | printf("ori00:%d\n", ori[0][0]); 74 | return 0; 75 | } -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/B/testfile5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/B/testfile5.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/input1.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input10.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/input10.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input11.txt: -------------------------------------------------------------------------------- 1 | 5 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/input12.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input13.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input14.txt: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input15.txt: -------------------------------------------------------------------------------- 1 | 2 2 | 3 3 | 4 4 | 5 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input16.txt: -------------------------------------------------------------------------------- 1 | 10 2 | 15 3 | 6 4 | 6 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input17.txt: -------------------------------------------------------------------------------- 1 | 12345 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input18.txt: -------------------------------------------------------------------------------- 1 | 0 2 | 1 3 | 0 4 | -1 5 | 1 6 | 2 7 | 2 8 | -1 9 | 2 10 | 2 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input19.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/input19.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input2.txt: -------------------------------------------------------------------------------- 1 | 54633487 2 | 632917 3 | 30 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input20.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input21.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 2 3 | 2 4 | 3 5 | 3 6 | 4 7 | 2 8 | 4 9 | 0 10 | 1 11 | 1 12 | 0 13 | 123456789 14 | 987654321 15 | -1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input22.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input23.txt: -------------------------------------------------------------------------------- 1 | 0 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input24.txt: -------------------------------------------------------------------------------- 1 | 19260817 2 | 114514 3 | 1919810 4 | 4 5 | 16 6 | 13 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input25.txt: -------------------------------------------------------------------------------- 1 | 11 2 | 13 3 | 12341 4 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input26.txt: -------------------------------------------------------------------------------- 1 | 33 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input27.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input28.txt: -------------------------------------------------------------------------------- 1 | 6 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input29.txt: -------------------------------------------------------------------------------- 1 | 233 2 | 1 3 | 42 4 | -15 5 | 0 6 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input3.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 23 3 | 3 4 | 4 5 | 52 6 | 6 7 | 7 8 | 8 9 | 99 10 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input4.txt: -------------------------------------------------------------------------------- 1 | 56 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input5.txt: -------------------------------------------------------------------------------- 1 | -4 2 | 0 3 | 1 4 | 2 5 | 3 6 | 4 7 | 5 8 | 6 9 | 7 10 | 8 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input6.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/input6.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input7.txt: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input8.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/input8.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/input9.txt: -------------------------------------------------------------------------------- 1 | 9 2 | 8 3 | 7 4 | 6 5 | 5 6 | 4 7 | 3 8 | 2 9 | 1 10 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output1.txt: -------------------------------------------------------------------------------- 1 | 19231204 2 | + is error! 3 | + is error! 4 | + is error! 5 | + is error! 6 | Break is error! 7 | a1+b1 is 3 8 | a2+b2 is -2 9 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output10.txt: -------------------------------------------------------------------------------- 1 | 19373025 2 | 1 3 | funi 4 | try 5 | try 6 | try 7 | try 8 | try 9 | try 10 | try -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output11.txt: -------------------------------------------------------------------------------- 1 | 19182650 2 | this is d 3 | 4 4 | 5 5 | 4 6 | 5 7 | 2 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output12.txt: -------------------------------------------------------------------------------- 1 | 19182623 2 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output13.txt: -------------------------------------------------------------------------------- 1 | 10, 30972, -5 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output14.txt: -------------------------------------------------------------------------------- 1 | 19373372 2 | fact[10] = 3628800 3 | fact[1] = 1 4 | fact[2] = 2 5 | fact[3] = 6 6 | fact[4] = 24 7 | fact[5] = 120 8 | fact[6] = 720 9 | fact[7] = 5040 10 | fact[8] = 40320 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output15.txt: -------------------------------------------------------------------------------- 1 | 19373479 2 | print int : 0 3 | print int : 2 4 | print int : 2 5 | print int : 0 6 | print int : 41 7 | print int : 61 8 | print int : 4884 9 | print int : -45015 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output16.txt: -------------------------------------------------------------------------------- 1 | 19373373 2 | j : 4, k : 10, l : 4 3 | a! = 720, num = 5 4 | 6 5 | scanf a, b to get gcd and lcm 6 | gcd is 5 7 | lcm is 30 8 | -6 9 | scanf a to get Fibonacci 10 | fib is 8 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output17.txt: -------------------------------------------------------------------------------- 1 | 19373682 2 | hello? 12345 12345 12345 3 | func1 done! 4 | func2 done! 5 | func3 input = 0 6 | func3 done! 7 | 204 204 100 100 20400 100 0 100 100 8 | func4 done! 9 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output18.txt: -------------------------------------------------------------------------------- 1 | 19373719 2 | 0 -2 3 | 0 2 4 | 4 5 | 0 6 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output19.txt: -------------------------------------------------------------------------------- 1 | 19373135 2 | l_const_0, should be 0: 0 3 | l_const_1, should be 1: 1 4 | l_const_3, should be 2: 2 5 | l_const_5[2], l_const_6[0][1], should be 3, 1: 3, 1 6 | l_var_0, should be 0: 0 7 | l_var_1, should be 2: 2 8 | l_var_3, should be 4: 4 9 | l_var_5, should be 5: 5 10 | l_var_6[2], l_var_7[0][1], should be 3, 1: 3, 1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output2.txt: -------------------------------------------------------------------------------- 1 | 18375200 2 | -163900461 3 | -628 4 | -925500 5 | ppgod7mi 6 | 4396yoga7 7 | 2333 8 | 9 | 10 | 11 | 632917 is not a prime, with factor 41. 12 | The 30th Fibonacci num is 832040. -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output20.txt: -------------------------------------------------------------------------------- 1 | 19373061 2 | 0 3 | 1 4 | 0 5 | 0 6 | 1 7 | 0 8 | 1 9 | 0 10 | t:1 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output21.txt: -------------------------------------------------------------------------------- 1 | gcd is 1 2 | gcd is 1 3 | gcd is 1 4 | gcd is 2 5 | invaild input! 6 | invaild input! 7 | gcd is 9 8 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output22.txt: -------------------------------------------------------------------------------- 1 | 19373034 2 | 1 3 | 1 4 | 0 5 | 1 6 | 0 7 | 10 8 | 8 9 | 9 10 | 10 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output23.txt: -------------------------------------------------------------------------------- 1 | 19373044 2 | s+1=2 3 | m=0 4 | m=1 5 | m=0 6 | m=0 7 | m=1 8 | m=2 9 | m=3 10 | before break -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output24.txt: -------------------------------------------------------------------------------- 1 | 19373022 2 | b:-19260604 3 | Bool1 is false! 4 | 1919820 5 | 1932053504 6 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output25.txt: -------------------------------------------------------------------------------- 1 | 19373341 2 | the num is 851 3 | the num is 11 4 | the num is 13 5 | the num is 12341 6 | 11 is odd! 7 | 13 is odd! 8 | max of 11 and 13 is 13 9 | min of 11 and 13 is 11 10 | No, 12341 is not a prime! It has a factor 7 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output26.txt: -------------------------------------------------------------------------------- 1 | 19373276 2 | !()*+,-./0123456789:;<>=?@[]^_`~{}| 3 | qwertyuiopasd 4 | fghjklzxcvbnmQWERTYUIOPASD 5 | FGHJKLZXCVBNM0 6 | 72 23 7 | addSum: 105, 45 8 | -2169 9 | 1008-6 10 | end -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output27.txt: -------------------------------------------------------------------------------- 1 | 19373315 2 | this is a yu ju ky 3 | unbelievable! 4 | var_a from getint() is 1 5 | getint is 1 6 | tmp 7 | tmp 8 | tmp 9 | tmp 10 | tmp 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output28.txt: -------------------------------------------------------------------------------- 1 | 19373332 2 | Stmt-3(Block): c = 2, d = 46 3 | Stmt-3(Block): e = 4, f = 829 4 | Stmt-4(if) check finish! 5 | Stmt-5,6 check finish! 6 | Stmt-7 check finish! 7 | Stmt-8 check finish! 8 | 9 | FormatChar. 10 | 13 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output29.txt: -------------------------------------------------------------------------------- 1 | 19373348 2 | Got a number: 233! 3 | 247 4 | Got a number: 1! 5 | -3 6 | Got a number: 42! 7 | 738 8 | Got a number: -15! 9 | 1711 10 | Got a number: 0! 11 | 3667 12 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output3.txt: -------------------------------------------------------------------------------- 1 | 19231177 2 | 1 3 | 23 4 | 3 5 | 4 6 | 52 7 | 6 8 | 7 9 | 8 10 | 99 11 | 10 12 | appear 13 | 20 14 | not 15 | 30 16 | not 17 | 40 18 | not 19 | 50 20 | not 21 | 60 22 | not 23 | 99 24 | not 25 | 99 26 | not 27 | 99 28 | not 29 | print123 30 | 123 31 | /****/123 32 | /**/123 33 | print return value : 34 | in : 5 ,out = 50 35 | in : 5 ,out = 50 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output4.txt: -------------------------------------------------------------------------------- 1 | 19231204 2 | The score is 56. 3 | Yes! 4 | Yes! 5 | Yes! 6 | No! -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output5.txt: -------------------------------------------------------------------------------- 1 | 16061069 2 | input an integer,judge if it is prime number,10 groups in total 3 | input > 0 is needed 4 | input > 0 is needed 5 | 1 is not concerned 6 | 2 is a prime number 7 | 3 is a prime number 8 | 4 is not a prime number 9 | 5 is a prime number 10 | 6 is not a prime number 11 | 7 is a prime number 12 | 8 is not a prime number 13 | while times is 22 in total 14 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output6.txt: -------------------------------------------------------------------------------- 1 | 19231177 2 | _ = 1; a = 20; b = 30; c = 460; 3 | 20+30=50; 460-1=459; 50*459=22950; 459/50=9; 22950mod30=0 4 | 50+459+22950=23459; 459-22950-9=-22500; 22950*9*0=0; 0/50/459=0; 9mod0mod50=9 5 | 10+17-23*37/43mod71-17*23+43=-340=-340 6 | 10+(17-23)*37/43mod(71-37)*-340=1710 7 | all chars : !()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~ 8 | 5!+7+3=130 9 | max: 2147483647 ; min : -2147483647 ; sum : 0 10 | 19231177 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output7.txt: -------------------------------------------------------------------------------- 1 | 19373755 2 | n = -864 3 | n = -7938 4 | n = 10 5 | n = -15 6 | n = 861 7 | n = 0 8 | test_if done! 9 | test_while done! 10 | test_break_continue done! -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output8.txt: -------------------------------------------------------------------------------- 1 | 19182650 2 | 1 3 | 2 4 | 3 5 | 4 6 | 5 7 | 6 8 | 21 9 | 1 10 | 6 -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/output9.txt: -------------------------------------------------------------------------------- 1 | 19231076 2 | >/!~varg1 is:-1;~ 3 | >/!~varg2 is:-8;~ 4 | >/!~varg3 is:7;~ 5 | >/!~varg4 is:6;~ 6 | >/!~varg5 is:5;~ 7 | >/!~varg6 is:4;~ 8 | >/!~varg7 is:3;~ 9 | >/!~varg8 is:2;~ 10 | >/!~varg9 is:1;~ 11 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile1.txt: -------------------------------------------------------------------------------- 1 | const int a1 = 1, a2 = +3, a3 = 8; 2 | int b1 = 0 + 2, b2 = -5, b3 = +6; 3 | 4 | int main() { 5 | printf("19231204"); 6 | printf("\n"); 7 | int n = 10; 8 | while (n) { 9 | n = n - 1; 10 | if (n < b3) { 11 | continue; 12 | printf("Continue is error!\n"); 13 | } 14 | if (n < a1) { 15 | break; 16 | printf("Break is error!And < is error!\n"); 17 | } 18 | if (n == a2) { 19 | printf("+ is correct!\n"); 20 | } else { 21 | printf("+ is error!\n"); 22 | } 23 | if (n == b1) { 24 | break; 25 | } 26 | } 27 | if (n != b1) { 28 | if (n == 0) { 29 | printf("Break is error!\n"); 30 | } else { 31 | printf("Continue is error!\n"); 32 | } 33 | } 34 | printf("a1+b1 is %d\n", a1 + b1); 35 | printf("a2+b2 is %d\n", a2 + b2); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile10.txt: -------------------------------------------------------------------------------- 1 | const int ci=1; 2 | const int ciexp=1+1*1/1%1-1; 3 | const int ca=1,cb=2; 4 | int i=-+1; 5 | int iexp=1+1*1/1%1-1; 6 | int a=1,b=2; 7 | void funv(int a,int b) {{ 8 | printf("funv\n"); 9 | }} 10 | int funi(int a){ 11 | printf("funi\n"); 12 | return 0; 13 | } 14 | int funvnop(){ 15 | return 0; 16 | } 17 | int main() { 18 | int ma1,ma2,ma3,ma4; 19 | printf("19373025\n"); 20 | ma1=1; 21 | ma2=1+1; 22 | ma3=1; 23 | ma4=1; 24 | if(ma1!=ma2) { 25 | int mif1=1; 26 | printf("%d\n",mif1); 27 | } else { 28 | return 0; 29 | } 30 | if(ma1==ma3){ 31 | funi(ma1); 32 | } 33 | if(ma1!=ma3){ 34 | funvnop(); 35 | } 36 | if(ma1>=ma3){ 37 | 38 | } 39 | if(ma2<=ma3){ 40 | funvnop(); 41 | } 42 | if(ma1>ma3){ 43 | funvnop(); 44 | } 45 | if(ma2= 2) _6 = 1; 17 | else _6 = 0; 18 | while (_5 <= _4 / 2) { 19 | if (_4 % _5 == 0) { 20 | _6 = 0; 21 | break; 22 | } 23 | _5 = _5 + 1; 24 | } 25 | if (_6 == 0)printf("%d is not a prime, with factor %d.\n", _4, _5); 26 | else printf("%d is a prime.\n", _4); 27 | _7 = getint(); 28 | _8 = 1; 29 | _9 = 1; 30 | _2 = 2; 31 | while (_2 < _7) { 32 | _3 = (_8 + _9) % 1000007; 33 | _8 = _9; 34 | _9 = _3; 35 | _2 = _2 + 1; 36 | } 37 | printf("The %dth Fibonacci num is %d.", _7, _9); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile20.txt: -------------------------------------------------------------------------------- 1 | 2 | int isPrime(int m) { 3 | int i; 4 | i = 2; 5 | while (i < m) { 6 | if (m % i == 0) 7 | return 0; 8 | i = i + 1; 9 | } 10 | return 1; 11 | } 12 | 13 | 14 | void check_group(int t[]) { 15 | int i; 16 | i = 0; 17 | while (i < 2) { 18 | int tmp; 19 | tmp = t[i]; 20 | tmp = isPrime(tmp); 21 | printf("%d\n", tmp); 22 | i = i + 1; 23 | } 24 | 25 | 26 | } 27 | 28 | int test(int t[][2]) { 29 | if (!t[0][1]) { 30 | ; 31 | } 32 | return 0; 33 | } 34 | 35 | int main() { 36 | 37 | printf("19373061\n"); 38 | int num; 39 | num = 30; 40 | printf("%d\n", isPrime(num)); 41 | num = 31; 42 | printf("%d\n", isPrime(num)); 43 | int tmp[3][2] = {{111, 2222},{3, 4},{5, 6}}; 44 | check_group(tmp[0]); 45 | check_group(tmp[1]); 46 | check_group(tmp[2]); 47 | 48 | int t; 49 | t = 1; 50 | while (t > 0) { 51 | if (t < 10) 52 | break; 53 | t = t + 1; 54 | } 55 | printf("t:%d\n", t); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile21.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/testfile21.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile23.txt: -------------------------------------------------------------------------------- 1 | 2 | int a,b=2+0; 3 | int c=3+0; 4 | int d=4; 5 | 6 | void shayemeiyou(){ 7 | int m; 8 | } 9 | int yi(){ 10 | return 1; 11 | } 12 | int pidoubushi(int n){ 13 | return 0; 14 | } 15 | int mult(int g,int k){ 16 | return g*k; 17 | } 18 | int main(){ 19 | int i=0; 20 | int m; 21 | int s=1; 22 | printf("19373044\n"); 23 | printf("s+1=%d\n",s+1); 24 | m=getint(); 25 | printf("m=%d\n",m); 26 | { 27 | } 28 | if(!m){ 29 | m=m+yi(); 30 | } 31 | printf("m=%d\n",m); 32 | if(m==1){ 33 | m=m-1; 34 | } 35 | else; 36 | printf("m=%d\n",m); 37 | while(m!=3){ 38 | printf("m=%d\n",m); 39 | m=-+-((mult(m,1)/1+1)%4); 40 | } 41 | i=mult(m,1); 42 | printf("m=%d\n",m); 43 | while(m>0){ 44 | if(m<=0){ 45 | continue; 46 | } 47 | printf("before break\n"); 48 | break; 49 | } 50 | if(m>=0){ 51 | } 52 | return 0; 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile29.txt: -------------------------------------------------------------------------------- 1 | const int A = 1; 2 | const int B = 2, C = 3, D = 4; 3 | 4 | int n = 10; 5 | int m = 20, p = 99, q = 66; 6 | 7 | void f0() { 8 | return; 9 | } 10 | 11 | int f1(int x) { 12 | if (x >= 0) { 13 | x = x + 1;;;; 14 | } 15 | 16 | if (x <= 0) { 17 | x = x + 1; 18 | } else { 19 | } 20 | 21 | { 22 | x = x + 1; 23 | } 24 | 25 | while (x < 0) { 26 | x = -x; 27 | } 28 | 29 | while (x > 0) { 30 | x = -x; 31 | continue; 32 | } 33 | 34 | while (x == 0) 35 | x = x + 1; 36 | 37 | while (x != 0) { 38 | break; 39 | } 40 | 41 | while (1) { 42 | while (!1) { 43 | } 44 | break; 45 | } 46 | 47 | return x; 48 | } 49 | 50 | int f2(int x, int y, int z) { 51 | int a; 52 | a = x + n * B - m / C + z % (A + B) + 233 + -y + f1(y); 53 | a = a * +A; 54 | return x + y + a; 55 | } 56 | 57 | int gi() { 58 | int r; 59 | r = getint(); 60 | printf("Got a number: "); 61 | printf("%d!\n", r); 62 | return r; 63 | } 64 | 65 | int main() { 66 | printf("19373348\n"); 67 | 68 | int a = f2(1, 2, gi()); 69 | f0(); 70 | printf("%d\n", a); 71 | printf("%d\n", f1(gi())); 72 | int b = f2(a, A, gi()), c, d; 73 | printf("%d\n", b); 74 | c = f2(b, n, gi()); 75 | printf("%d\n", c); 76 | printf("%d\n", f2(c, gi(), q)); 77 | d = 0; 78 | return d; 79 | } 80 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile3.txt: -------------------------------------------------------------------------------- 1 | //#include 2 | const int a = 9; 3 | const int b = a; 4 | int d = a; 5 | 6 | //int getint(){ 7 | // int n; 8 | // scanf("%d",&n); 9 | // return n; 10 | // 11 | //} 12 | int mycheck(int a){ 13 | if (a == 1) return 10; 14 | if (a==2) return 20; 15 | if (a==4) return 40 ; 16 | else if (a==5) return 50; 17 | else if (a == 6) return 60; 18 | if (a==3) return 30 ;else return 99 ; 19 | return 0; 20 | return 1; 21 | } 22 | 23 | void testGetInt(){ 24 | int i = 0; 25 | 26 | while(i<9){ 27 | int temp; 28 | temp = getint(); 29 | printf("%d\n",temp); 30 | i = i + 1; 31 | } 32 | } 33 | 34 | 35 | int main(){ 36 | const int in1 = 89; 37 | const int in2 = in1; 38 | int vin1 = in1; 39 | int vin2 = vin1; 40 | int vin3 = in2; 41 | int vin4 = a + b; 42 | int vin5 = d; 43 | 44 | 45 | printf("%d\n",19231177); 46 | testGetInt(); 47 | int a = 1; 48 | while(a<10){ 49 | printf("%d\n",mycheck(a)); 50 | if (mycheck(a) < mycheck(mycheck(a)/20) ){ 51 | printf("appear\n"); 52 | }else{ 53 | printf("not\n"); 54 | } 55 | a = a + 1; 56 | } 57 | int a1 = 1,a2 = 2,a3 = 3; 58 | printf("print123\n"); 59 | printf("%d%d%d\n",1,2,3); 60 | printf("/****/%d%d%d\n",1,a2,a3); 61 | printf("/**/%d%d%d\n",a1,a2,a3); 62 | printf("print return value :\n"); 63 | int temp = 5; 64 | printf("in : 5 ,out = %d\n",mycheck(5)); 65 | printf("in : 5 ,out = %d\n",mycheck(temp)); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile4.txt: -------------------------------------------------------------------------------- 1 | const int max_number = 100; 2 | const int min_number = 0; 3 | int a = 0; 4 | int main(){ 5 | printf("19231204"); 6 | printf("\n"); 7 | int score; 8 | int b = 30; 9 | score = getint(); 10 | if (score >= min_number){ 11 | printf("The score is %d.\n",score); 12 | } 13 | a = 4 / 2; 14 | if (a == 2){ 15 | printf("Yes!\n"); 16 | } 17 | a = 3 + 5; 18 | if (a != 8){ 19 | printf("No!\n"); 20 | }else{ 21 | printf("Yes!\n"); 22 | } 23 | a = 10 * 10; 24 | if (a <= max_number){ 25 | printf("Yes!\n"); 26 | } 27 | if (a < max_number){ 28 | printf("Yes!\n"); 29 | } 30 | if (a > b) { 31 | printf("No!"); 32 | }else { 33 | printf("Yes!"); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile6.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/代码生成测试样例库/testfiles/C/testfile6.txt -------------------------------------------------------------------------------- /文档/代码生成测试样例库/testfiles/C/testfile8.txt: -------------------------------------------------------------------------------- 1 | int aa(int b[][3]) 2 | { 3 | int w; 4 | w=b[0][0]+b[0][1]+b[0][2]+b[1][0]+b[1][1]+b[1][2]; 5 | return w; 6 | } 7 | int main() 8 | { 9 | printf("19182650\n"); 10 | const int a[2][3]={{1,2,3},{4,5,6}}; 11 | int b[2][3]={{1,2,3},{4,5,6}}; 12 | int c[2][3]; 13 | int d; 14 | d=aa(b); 15 | c[0][0]=b[0][0]; 16 | c[0][1]=b[0][1]; 17 | c[0][2]=b[0][2]; 18 | c[1][0]=b[1][0]; 19 | c[1][1]=b[1][1]; 20 | c[1][2]=b[1][2]; 21 | printf("%d\n",a[0][0]); 22 | printf("%d\n",a[0][1]); 23 | printf("%d\n",a[0][2]); 24 | printf("%d\n",a[1][0]); 25 | printf("%d\n",a[1][1]); 26 | printf("%d\n",a[1][2]); 27 | printf("%d\n",d); 28 | printf("%d\n",c[0][0]); 29 | printf("%d\n",c[1][2]); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /文档/编译文法.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SgtPepperr/BUAA_Compile_2021/23819e410bd45a4ed0a2c16b33c06ba17101d675/文档/编译文法.pdf --------------------------------------------------------------------------------