diff --git a/.classpath b/.classpath
index a7a42f2b..ea6b8fae 100644
--- a/.classpath
+++ b/.classpath
@@ -1,25 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 00000000..bca02739
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding//src/bit/minisys/minicc/MiniCCompiler.java=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index d17b6724..a698e596 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/bit-minic-clean/src/bit/minisys/minicc/MiniCCCfg.java b/bit-minic-clean/src/bit/minisys/minicc/MiniCCCfg.java
deleted file mode 100644
index 633bbc46..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/MiniCCCfg.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package bit.minisys.minicc;
-
-public class MiniCCCfg {
- // input and output for MiniCCPreProcessor
- public static String MINICC_PP_INPUT_EXT = ".c";//C源程序
- public static String MINICC_PP_OUTPUT_EXT = ".pp.c";//删除无用注释和空格,宏替换与文件包含
- // input and output for MiniCCScanner
- public static String MINICC_SCANNER_INPUT_EXT = ".pp.c";//预处理过的C程序
- public static String MINICC_SCANNER_OUTPUT_EXT = ".token.xml";//词法分析,生成属性字符流
- // input and output for MiniCCParser
- public static String MINICC_PARSER_INPUT_EXT = ".token.xml";//词法分析后的属性字符流
- public static String MINICC_PARSER_OUTPUT_EXT = ".tree.xml";//语法分析,生成语法树
- // input and output for MiniCCSemantic
- public static String MINICC_SEMANTIC_INPUT_EXT = ".tree.xml";//语法树
- public static String MINICC_SEMANTIC_OUTPUT_EXT = ".tree2.xml";//语义检查
- // input and output for MiniCCICGen
- public static String MINICC_ICGEN_INPUT_EXT = ".tree2.xml";//语法树
- public static String MINICC_ICGEN_OUTPUT_EXT = ".ic.xml";//生成四元式列表
- // input and output for MiniCCOpt
- public static String MINICC_OPT_INPUT_EXT = ".ic.xml";//中间代码
- public static String MINICC_OPT_OUTPUT_EXT = ".ic2.xml";//实施常量合并等代码优化
- // input and output for MiniCCCodeGen
- public static String MINICC_CODEGEN_INPUT_EXT = ".ic2.xml";//中间代码
- public static String MINICC_CODEGEN_OUTPUT_EXT = ".code.s";//生成x86或者MIPS汇编代码
- // input and output for simulator
- public static String MINICC_ASSEMBLER_INPUT_EXT = ".code.s";//目标代码
-
- //structure for config.xml
- public String type;
- public String path;
- public String skip;
- public String arch;
- public String headless;
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/MiniCCompiler.java b/bit-minic-clean/src/bit/minisys/minicc/MiniCCompiler.java
deleted file mode 100644
index b865cc0c..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/MiniCCompiler.java
+++ /dev/null
@@ -1,285 +0,0 @@
-package bit.minisys.minicc;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.python.util.PythonInterpreter;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import bit.minisys.minicc.codegen.MiniCCCodeGen;
-import bit.minisys.minicc.icgen.MiniCCICGen;
-import bit.minisys.minicc.optimizer.MiniCCOptimizer;
-import bit.minisys.minicc.parser.MiniCCParser;
-import bit.minisys.minicc.pp.MiniCCPreProcessor;
-import bit.minisys.minicc.scanner.MiniCCScanner;
-import bit.minisys.minicc.semantic.MiniCCSemantic;
-import bit.minisys.minicc.simulator.*;
-
-
-public class MiniCCompiler {
- MiniCCCfg pp = new MiniCCCfg();
- MiniCCCfg scanning = new MiniCCCfg();
- MiniCCCfg parsing = new MiniCCCfg();
- MiniCCCfg semantic = new MiniCCCfg();
- MiniCCCfg icgen = new MiniCCCfg();
- MiniCCCfg optimizing = new MiniCCCfg();
- MiniCCCfg codegen = new MiniCCCfg();
- MiniCCCfg simulating = new MiniCCCfg();
-
- private void readConfig() throws ParserConfigurationException, SAXException, IOException{
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- Document doc = db.parse("./config.xml");
-
- NodeList nodeList = doc.getElementsByTagName("phase");
- for (int i = 0; i < nodeList.getLength(); i++){
- Element temp = (Element) nodeList.item(i);
- String name = temp.getAttribute("name");
- if(name.equals("pp")) {
- pp.type = temp.getAttribute("type");
- pp.path = temp.getAttribute("path");
- pp.skip = temp.getAttribute("skip");
- }
- else if(name.equals("scanning")) {
- scanning.type = temp.getAttribute("type");
- scanning.path = temp.getAttribute("path");
- scanning.skip = temp.getAttribute("skip");
-
- }
- else if(name.equals("parsing")) {
- parsing.type = temp.getAttribute("type");
- parsing.path = temp.getAttribute("path");
- parsing.skip = temp.getAttribute("skip");
- }
- else if(name.equals("semantic")) {
- semantic.type = temp.getAttribute("type");
- semantic.path = temp.getAttribute("path");
- semantic.skip = temp.getAttribute("skip");
- }
- else if(name.equals("icgen")) {
- icgen.type = temp.getAttribute("type");
- icgen.path = temp.getAttribute("path");
- icgen.skip = temp.getAttribute("skip");
- }
- else if(name.equals("optimizing")) {
- optimizing.type = temp.getAttribute("type");
- optimizing.path = temp.getAttribute("path");
- optimizing.skip = temp.getAttribute("skip");
- }
- else if(name.equals("codegen")) {
- codegen.type = temp.getAttribute("type");
- codegen.path = temp.getAttribute("path");
- codegen.skip = temp.getAttribute("skip");
- codegen.arch = temp.getAttribute("arch");
- }
- else if(name.equals("simulating")) {
- simulating.type = temp.getAttribute("type");
- simulating.path = temp.getAttribute("path");
- simulating.skip = temp.getAttribute("skip");
- simulating.headless = temp.getAttribute("headless");
- }
- }
- }
-
- public void run(String cFile) throws Exception{
-
- String filename = cFile;
-
- readConfig();
-
- // step 1: preprocess
- if(pp.skip.equals("false")){
- if(pp.type.equals("java")){
- if(!pp.path.equals("")){
- Class> c = Class.forName(pp.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), cFile);
- }else{
- MiniCCPreProcessor prep = new MiniCCPreProcessor();
- filename = prep.run(cFile);
- }
- }else {
- String ppOutFile = cFile.replace(MiniCCCfg.MINICC_PP_INPUT_EXT, MiniCCCfg.MINICC_PP_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(cFile, ppOutFile, pp.path);
- } else {
- this.run(cFile, ppOutFile, pp.path);
- }
- filename = ppOutFile;
- }
- }
-
- // step 2: scan
- if(scanning.skip.equals("false")){
- if(scanning.type.equals("java")){
- if(!scanning.path.equals("")){
- Class> c = Class.forName(scanning.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), filename);
- }else{
- MiniCCScanner sc = new MiniCCScanner();
- filename = sc.run(filename);
- }
- }else {
- String scOutFile = filename.replace(MiniCCCfg.MINICC_SCANNER_INPUT_EXT, MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(filename, scOutFile, scanning.path);
- }else {
- this.run(filename, scOutFile, scanning.path);
- }
- filename = scOutFile;
- }
- }
-
- // step 3: parser
- if(parsing.skip.equals("false")){
- if(parsing.type.equals("java")){
- if(parsing.path != ""){
- Class> c = Class.forName(parsing.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), filename);
- }else{
- MiniCCParser p = new MiniCCParser();
- filename = p.run(filename);
- }
- }else {
- String pOutFile = filename.replace(MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT, MiniCCCfg.MINICC_PARSER_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(filename, pOutFile, parsing.path);
- } else {
- this.run(filename, pOutFile, parsing.path);
- }
- filename = pOutFile;
- }
- }
-
- // step 4: semantic
- if(semantic.skip.equals("false")){
- if(semantic.type.equals("java")){
- if(!semantic.path.equals("")){
- Class> c = Class.forName(semantic.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), filename);
- }else{
- MiniCCSemantic se = new MiniCCSemantic();
- filename = se.run(filename);
- }
- }else {
- String seOutFile = filename.replace(MiniCCCfg.MINICC_PARSER_OUTPUT_EXT, MiniCCCfg.MINICC_SEMANTIC_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(filename, seOutFile, semantic.path);
- }else{
- this.run(filename, seOutFile, semantic.path);
- }
- filename = seOutFile;
- }
- }
-
- // step 5: intermediate code generate
- if(icgen.skip.equals("false")){
- if(icgen.type.equals("java")){
- if(!icgen.path.equals("")){
- Class> c = Class.forName(icgen.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), filename);
- }else{
- MiniCCICGen ic = new MiniCCICGen();
- filename = ic.run(filename);
- }
- }else {
- String icOutFile = filename.replace(MiniCCCfg.MINICC_SEMANTIC_OUTPUT_EXT, MiniCCCfg.MINICC_ICGEN_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(filename, icOutFile, icgen.path);
- } else {
- this.run(filename, icOutFile, icgen.path);
- }
- filename = icOutFile;
- }
- }
-
- // step 6: optimization
- if(optimizing.skip.equals("false")){
- if(optimizing.type.equals("java")){
- if(!optimizing.path.equals("")){
- Class> c = Class.forName(optimizing.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), filename);
- }else{
- MiniCCOptimizer o = new MiniCCOptimizer();
- filename = o.run(filename);
- }
- }else {
- String oOutFile = filename.replace(MiniCCCfg.MINICC_ICGEN_OUTPUT_EXT, MiniCCCfg.MINICC_OPT_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(filename, oOutFile, optimizing.path);
- } else {
- this.run(filename, oOutFile, optimizing.path);
- }
- filename = oOutFile;
- }
- }
-
- // step 7: code generate
- if(codegen.skip.equals("false")){
- if(codegen.type.equals("java")){
- if(!codegen.path.equals("")){
- Class> c = Class.forName(codegen.path);
- Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), filename);
- }else{
- MiniCCCodeGen g = new MiniCCCodeGen();
- filename = g.run(filename, codegen.arch);
- }
- }else {
- String cOutFile = filename.replace(MiniCCCfg.MINICC_OPT_OUTPUT_EXT, MiniCCCfg.MINICC_CODEGEN_OUTPUT_EXT);
- if(pp.type.equals("python")){
- this.runPy(filename, cOutFile, codegen.path);
- } else {
- this.run(filename, cOutFile, codegen.path);
- }
- filename = cOutFile;
- }
- }
-
- // step 8: simulate
-
- if(simulating.skip.equals("false")){
- IMiniCCSimulator m = null;
- if(simulating.type.equals("riscv")) {
- m = new RISCVSimulator();
- } else {
- m = new MIPSSimulator();
- }
-
- if(simulating.headless.equals("false")) {
- m.run(null);
- } else {
- m.run(filename);
- }
- }
-
- }
-
- private void run(String iFile, String oFile, String path) throws IOException{
- Runtime rt = Runtime.getRuntime();//鏍煎紡锛歟xe鍚� 杈撳叆鏂囦欢 杈撳嚭鏂囦欢
- Process p = rt.exec(path + " " + iFile + " " + oFile);
- try {
- p.wait();
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- private void runPy(String iFile, String oFile, String path) throws IOException{
- PythonInterpreter pyi = new PythonInterpreter();//鏍煎紡锛歅ython鑴氭湰鍚� 杈撳叆鏂囦欢 杈撳嚭鏂囦欢
- pyi.exec(path + " " + iFile + " " + oFile);
- }
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/icgen/IMiniCCICGen.java b/bit-minic-clean/src/bit/minisys/minicc/icgen/IMiniCCICGen.java
deleted file mode 100644
index dfa22bee..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/icgen/IMiniCCICGen.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package bit.minisys.minicc.icgen;
-
-import java.io.IOException;
-
-public interface IMiniCCICGen {
- public void run(String iFile, String oFile) throws IOException;
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/optimizer/IMiniCCOptimizer.java b/bit-minic-clean/src/bit/minisys/minicc/optimizer/IMiniCCOptimizer.java
deleted file mode 100644
index e7153e9b..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/optimizer/IMiniCCOptimizer.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package bit.minisys.minicc.optimizer;
-
-import java.io.IOException;
-
-public interface IMiniCCOptimizer {
- public void run(String iFile, String oFile) throws IOException;
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java b/bit-minic-clean/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java
deleted file mode 100644
index 1274f46a..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package bit.minisys.minicc.pp;
-
-public interface IMiniCCPreProcessor {
- public void run(String iFile, String oFile);
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/scanner/IMiniCCScanner.java b/bit-minic-clean/src/bit/minisys/minicc/scanner/IMiniCCScanner.java
deleted file mode 100644
index 92c56a69..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/scanner/IMiniCCScanner.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package bit.minisys.minicc.scanner;
-
-import java.io.IOException;
-
-public interface IMiniCCScanner {
- public void run(String iFile, String oFile) throws IOException, Exception;
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/semantic/IMiniCCSemantic.java b/bit-minic-clean/src/bit/minisys/minicc/semantic/IMiniCCSemantic.java
deleted file mode 100644
index 91d0edcb..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/semantic/IMiniCCSemantic.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package bit.minisys.minicc.semantic;
-
-import java.io.IOException;
-
-public interface IMiniCCSemantic {
- public void run(String iFile, String oFile) throws IOException;
-}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/simulator/IMIPSSimulator.java b/bit-minic-clean/src/bit/minisys/minicc/simulator/IMIPSSimulator.java
deleted file mode 100644
index 97809b13..00000000
--- a/bit-minic-clean/src/bit/minisys/minicc/simulator/IMIPSSimulator.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package bit.minisys.minicc.simulator;
-
-public interface IMIPSSimulator {
- public void run(String iFile);
-}
diff --git a/config.xml b/config.xml
index 6b790d84..8d02b921 100644
--- a/config.xml
+++ b/config.xml
@@ -6,10 +6,10 @@
-
-
-
-
+
+
+
+
diff --git a/input/test.code.s b/input/test.code.s
index ef9bfc3e..7850f76a 100644
--- a/input/test.code.s
+++ b/input/test.code.s
@@ -1,15 +1,22 @@
+# code generated by MiniCC
+# architecture: MIPS32
-# Code generated from MiniCCompiler at
-# input file:D:\projects\bit-minicc\bit-minic-clean\input\test.ic2.xml
-# Please do not change this file!
+.data
+
+# string literals
+
+# label refs
+
+# integer literals
+
+# arrays
+
+.text
- .data
- .text
__init:
# setup the stack
lui $sp, 0x8000
addi $sp, $sp, 0x0000
- addiu $sp, $sp, -1024
# redirect to main function
jal __main
@@ -19,81 +26,111 @@ __init:
syscall
-__MARS_SCANF_I:
+
+
+__main:
+ addiu $sp, $sp, -52
+ sw $s0, 8($sp)
+ sw $s1, 12($sp)
+ sw $s2, 16($sp)
+ sw $s3, 20($sp)
+ sw $s4, 24($sp)
+ sw $s5, 28($sp)
+ sw $s6, 32($sp)
+ sw $s7, 36($sp)
+ sw $fp, 40($sp)
+ sw $gp, 44($sp)
+ sw $ra, 48($sp)
+
+ move $s0, $a0
+ move $s1, $a1
+ move $s2, $a2
+ move $s3, $a3
+ jal __MARS_SCANF_I
+ move $a0, $s0
+ move $a1, $s1
+ move $a2, $s2
+ move $a3, $s3
+ move $t0, $v0
+ li $t1, 0
+ move $t2, $sp
+ add $t2, $t2, $t1
+ sw $t0, 0($t2)
+ move $s0, $a0
+ move $s1, $a1
+ move $s2, $a2
+ move $s3, $a3
+ jal __MARS_SCANF_I
+ move $a0, $s0
+ move $a1, $s1
+ move $a2, $s2
+ move $a3, $s3
+ move $t0, $v0
+ li $t1, 4
+ move $t2, $sp
+ add $t2, $t2, $t1
+ sw $t0, 0($t2)
+ li $t1, 0
+ move $t2, $sp
+ add $t2, $t2, $t1
+ lw $t0, 0($t2)
+ li $t2, 4
+ move $t3, $sp
+ add $t3, $t3, $t2
+ lw $t1, 0($t3)
+ add $t0, $t0, $t1
+ li $t1, 0
+ move $t2, $sp
+ add $t2, $t2, $t1
+ sw $t0, 0($t2)
+ move $s0, $a0
+ move $s1, $a1
+ move $s2, $a2
+ move $s3, $a3
+ li $t2, 0
+ move $t3, $sp
+ add $t3, $t3, $t2
+ lw $t1, 0($t3)
+ move $a0, $t1
+ jal __MARS_PRINTF_I
+ move $a0, $s0
+ move $a1, $s1
+ move $a2, $s2
+ move $a3, $s3
+ move $t0, $v0
+ li $t0, 0
+ move $v0, $t0
+ lw $s0, 8($sp)
+ lw $s1, 12($sp)
+ lw $s2, 16($sp)
+ lw $s3, 20($sp)
+ lw $s4, 24($sp)
+ lw $s5, 28($sp)
+ lw $s6, 32($sp)
+ lw $s7, 36($sp)
+ lw $fp, 40($sp)
+ lw $gp, 44($sp)
+ lw $ra, 48($sp)
+ addiu $sp, $sp, 52
+ jr $ra
+
+
+__MARS_GETI:
li $v0, 5
syscall
move $t0, $v0
jr $ra
-__MARS_PRINTF_I:
+__MARS_PUTI:
li $v0, 1
syscall
jr $ra
-__main:
-
- # allocate stack frame for the callee
- addiu $fp, $sp, 0
- addiu $sp, $sp, -136
- sw $ra, 0($fp)
-
- sw $a0, 8($fp)
- sw $a1, 12($fp)
- sw $a2, 16($fp)
- sw $a3, 20($fp)
-
-
- jal __MARS_SCANF_I
-
- lw $ra, 0($fp)
-
- lw $a0, 8($sp)
- lw $a1, 12($sp)
- lw $a2, 16($sp)
- lw $a3, 20($sp)
-
- move $t9, $v0
- sw $ra, 0($fp)
-
- sw $a0, 8($fp)
- sw $a1, 12($fp)
- sw $a2, 16($fp)
- sw $a3, 20($fp)
-
-
- jal __MARS_SCANF_I
-
- lw $ra, 0($fp)
-
- lw $a0, 8($sp)
- lw $a1, 12($sp)
- lw $a2, 16($sp)
- lw $a3, 20($sp)
-
- move $t8, $v0
- add $t9, $t9, $t8
- sw $ra, 0($fp)
- sw $a0, 8($fp)
- sw $a1, 12($fp)
- sw $a2, 16($fp)
- sw $a3, 20($fp)
-
- move $a0, $25
-
- jal __MARS_PRINTF_I
-
- lw $ra, 0($fp)
-
- lw $a0, 8($sp)
- lw $a1, 12($sp)
- lw $a2, 16($sp)
- lw $a3, 20($sp)
-
- addi $v0, $v0, 0
- addiu $sp, $fp, 0
- addiu $fp, $fp, -136
+__MARS_PUTS:
+ li $v0, 4
+ syscall
jr $ra
-
-
+
+# EOF
diff --git a/input/test.tree.xml b/input/test.tree.xml
index ba7c55d3..e8fe440e 100644
--- a/input/test.tree.xml
+++ b/input/test.tree.xml
@@ -55,10 +55,10 @@
-
+
-
+
diff --git a/input/test.tree2.xml b/input/test.tree2.xml
index ba7c55d3..e8fe440e 100644
--- a/input/test.tree2.xml
+++ b/input/test.tree2.xml
@@ -55,10 +55,10 @@
-
+
-
+
diff --git a/bit-minic-clean/lib/BITMiniCC-obf.jar b/lib/BITMiniCC-obf.jar
similarity index 100%
rename from bit-minic-clean/lib/BITMiniCC-obf.jar
rename to lib/BITMiniCC-obf.jar
diff --git a/lib/antlr-4.6-complete.jar b/lib/antlr-4.6-complete.jar
deleted file mode 100644
index b488881e..00000000
Binary files a/lib/antlr-4.6-complete.jar and /dev/null differ
diff --git a/lib/codegen.jar b/lib/codegen.jar
deleted file mode 100644
index 7ed12f36..00000000
Binary files a/lib/codegen.jar and /dev/null differ
diff --git a/lib/icgen.jar b/lib/icgen.jar
deleted file mode 100644
index 796f2196..00000000
Binary files a/lib/icgen.jar and /dev/null differ
diff --git a/lib/jython.jar b/lib/jython.jar
deleted file mode 100644
index 44db1f86..00000000
Binary files a/lib/jython.jar and /dev/null differ
diff --git a/lib/opt.jar b/lib/opt.jar
deleted file mode 100644
index 3059c624..00000000
Binary files a/lib/opt.jar and /dev/null differ
diff --git a/lib/parser.jar b/lib/parser.jar
deleted file mode 100644
index fa39873b..00000000
Binary files a/lib/parser.jar and /dev/null differ
diff --git a/lib/pp.jar b/lib/pp.jar
deleted file mode 100644
index 3e29f7dc..00000000
Binary files a/lib/pp.jar and /dev/null differ
diff --git a/lib/scanner.jar b/lib/scanner.jar
deleted file mode 100644
index 5358fee5..00000000
Binary files a/lib/scanner.jar and /dev/null differ
diff --git a/lib/semantic.jar b/lib/semantic.jar
deleted file mode 100644
index 958d7698..00000000
Binary files a/lib/semantic.jar and /dev/null differ
diff --git a/lib/simulator.jar b/lib/simulator.jar
deleted file mode 100644
index b0e1e4d9..00000000
Binary files a/lib/simulator.jar and /dev/null differ
diff --git a/lib/util.jar b/lib/util.jar
deleted file mode 100644
index cbca61dc..00000000
Binary files a/lib/util.jar and /dev/null differ
diff --git a/run/BITMiniCC.jar b/run/BITMiniCC.jar
deleted file mode 100644
index 55a4c414..00000000
Binary files a/run/BITMiniCC.jar and /dev/null differ
diff --git a/bit-minic-clean/src/bit/minisys/minicc/BITMiniCC.java b/src/bit/minisys/minicc/BITMiniCC.java
similarity index 75%
rename from bit-minic-clean/src/bit/minisys/minicc/BITMiniCC.java
rename to src/bit/minisys/minicc/BITMiniCC.java
index 91ff8df9..83cf546d 100644
--- a/bit-minic-clean/src/bit/minisys/minicc/BITMiniCC.java
+++ b/src/bit/minisys/minicc/BITMiniCC.java
@@ -6,10 +6,7 @@ public class BITMiniCC {
* @param args
* @throws Exception
*/
-
- public static void main(String[] args) throws Exception {
- //System.out.println(System.getProperty("user.dir"));
-
+ public static void main(String[] args) throws Exception {
if(args.length < 1){
usage();
return;
@@ -23,7 +20,6 @@ public static void main(String[] args) throws Exception {
MiniCCompiler cc = new MiniCCompiler();
System.out.println("Start to compile ...");
-// System.out.println(System.getProperty("user.dir"));
cc.run(file);
System.out.println("Compiling completed!");
}
diff --git a/src/bit/minisys/minicc/MiniCCCfg.java b/src/bit/minisys/minicc/MiniCCCfg.java
index 9d18882e..633bbc46 100644
--- a/src/bit/minisys/minicc/MiniCCCfg.java
+++ b/src/bit/minisys/minicc/MiniCCCfg.java
@@ -2,31 +2,33 @@
public class MiniCCCfg {
// input and output for MiniCCPreProcessor
- public static String MINICC_PP_INPUT_EXT = ".c";//CԴ
- public static String MINICC_PP_OUTPUT_EXT = ".pp.c";//ɾעͺͿո滻ļ
+ public static String MINICC_PP_INPUT_EXT = ".c";//C源程序
+ public static String MINICC_PP_OUTPUT_EXT = ".pp.c";//删除无用注释和空格,宏替换与文件包含
// input and output for MiniCCScanner
- public static String MINICC_SCANNER_INPUT_EXT = ".pp.c";//ԤC
- public static String MINICC_SCANNER_OUTPUT_EXT = ".token.xml";//ʷַ
+ public static String MINICC_SCANNER_INPUT_EXT = ".pp.c";//预处理过的C程序
+ public static String MINICC_SCANNER_OUTPUT_EXT = ".token.xml";//词法分析,生成属性字符流
// input and output for MiniCCParser
- public static String MINICC_PARSER_INPUT_EXT = ".token.xml";//ʷַ
- public static String MINICC_PARSER_OUTPUT_EXT = ".tree.xml";//
+ public static String MINICC_PARSER_INPUT_EXT = ".token.xml";//词法分析后的属性字符流
+ public static String MINICC_PARSER_OUTPUT_EXT = ".tree.xml";//语法分析,生成语法树
// input and output for MiniCCSemantic
- public static String MINICC_SEMANTIC_INPUT_EXT = ".tree.xml";//
- public static String MINICC_SEMANTIC_OUTPUT_EXT = ".tree2.xml";//
+ public static String MINICC_SEMANTIC_INPUT_EXT = ".tree.xml";//语法树
+ public static String MINICC_SEMANTIC_OUTPUT_EXT = ".tree2.xml";//语义检查
// input and output for MiniCCICGen
- public static String MINICC_ICGEN_INPUT_EXT = ".tree2.xml";//
- public static String MINICC_ICGEN_OUTPUT_EXT = ".ic.xml";//Ԫʽб
+ public static String MINICC_ICGEN_INPUT_EXT = ".tree2.xml";//语法树
+ public static String MINICC_ICGEN_OUTPUT_EXT = ".ic.xml";//生成四元式列表
// input and output for MiniCCOpt
- public static String MINICC_OPT_INPUT_EXT = ".ic.xml";//м
- public static String MINICC_OPT_OUTPUT_EXT = ".ic2.xml";//ʵʩϲȴŻ
+ public static String MINICC_OPT_INPUT_EXT = ".ic.xml";//中间代码
+ public static String MINICC_OPT_OUTPUT_EXT = ".ic2.xml";//实施常量合并等代码优化
// input and output for MiniCCCodeGen
- public static String MINICC_CODEGEN_INPUT_EXT = ".ic2.xml";//м
- public static String MINICC_CODEGEN_OUTPUT_EXT = ".code.s";//x86MIPS
+ public static String MINICC_CODEGEN_INPUT_EXT = ".ic2.xml";//中间代码
+ public static String MINICC_CODEGEN_OUTPUT_EXT = ".code.s";//生成x86或者MIPS汇编代码
// input and output for simulator
- public static String MINICC_ASSEMBLER_INPUT_EXT = ".code.s";//Ŀ
+ public static String MINICC_ASSEMBLER_INPUT_EXT = ".code.s";//目标代码
//structure for config.xml
public String type;
public String path;
public String skip;
+ public String arch;
+ public String headless;
}
diff --git a/src/bit/minisys/minicc/MiniCCompiler.java b/src/bit/minisys/minicc/MiniCCompiler.java
index 526b7431..b865cc0c 100644
--- a/src/bit/minisys/minicc/MiniCCompiler.java
+++ b/src/bit/minisys/minicc/MiniCCompiler.java
@@ -6,26 +6,22 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import bit.minisys.minicc.pp.MiniCCPreProcessor;
+
import org.python.util.PythonInterpreter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-
-
-
-
-
import bit.minisys.minicc.codegen.MiniCCCodeGen;
import bit.minisys.minicc.icgen.MiniCCICGen;
import bit.minisys.minicc.optimizer.MiniCCOptimizer;
+import bit.minisys.minicc.parser.MiniCCParser;
+import bit.minisys.minicc.pp.MiniCCPreProcessor;
import bit.minisys.minicc.scanner.MiniCCScanner;
import bit.minisys.minicc.semantic.MiniCCSemantic;
-import bit.minisys.minicc.parser.MiniCCParser;
+import bit.minisys.minicc.simulator.*;
-import bit.minisys.minicc.simulator.MIPSSimulator;
public class MiniCCompiler {
MiniCCCfg pp = new MiniCCCfg();
@@ -41,210 +37,238 @@ private void readConfig() throws ParserConfigurationException, SAXException, IOE
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("./config.xml");
-// System.out.println("path: " + path);
+
NodeList nodeList = doc.getElementsByTagName("phase");
for (int i = 0; i < nodeList.getLength(); i++){
Element temp = (Element) nodeList.item(i);
-// System.out.println(temp.getAttribute("type") + temp.getAttribute("path"));
- switch(temp.getAttribute("name")){
- case "pp":
+ String name = temp.getAttribute("name");
+ if(name.equals("pp")) {
pp.type = temp.getAttribute("type");
pp.path = temp.getAttribute("path");
pp.skip = temp.getAttribute("skip");
- break;
- case "scanning":
+ }
+ else if(name.equals("scanning")) {
scanning.type = temp.getAttribute("type");
scanning.path = temp.getAttribute("path");
scanning.skip = temp.getAttribute("skip");
- break;
- case "parsing":
+
+ }
+ else if(name.equals("parsing")) {
parsing.type = temp.getAttribute("type");
parsing.path = temp.getAttribute("path");
parsing.skip = temp.getAttribute("skip");
- break;
- case "semantic":
+ }
+ else if(name.equals("semantic")) {
semantic.type = temp.getAttribute("type");
semantic.path = temp.getAttribute("path");
semantic.skip = temp.getAttribute("skip");
- break;
- case "icgen":
+ }
+ else if(name.equals("icgen")) {
icgen.type = temp.getAttribute("type");
icgen.path = temp.getAttribute("path");
icgen.skip = temp.getAttribute("skip");
- break;
- case "optimizing":
+ }
+ else if(name.equals("optimizing")) {
optimizing.type = temp.getAttribute("type");
optimizing.path = temp.getAttribute("path");
optimizing.skip = temp.getAttribute("skip");
- break;
- case "codegen":
+ }
+ else if(name.equals("codegen")) {
codegen.type = temp.getAttribute("type");
codegen.path = temp.getAttribute("path");
codegen.skip = temp.getAttribute("skip");
- break;
- case "simulating":
+ codegen.arch = temp.getAttribute("arch");
+ }
+ else if(name.equals("simulating")) {
simulating.type = temp.getAttribute("type");
simulating.path = temp.getAttribute("path");
simulating.skip = temp.getAttribute("skip");
- break;
+ simulating.headless = temp.getAttribute("headless");
}
}
}
public void run(String cFile) throws Exception{
+ String filename = cFile;
+
readConfig();
// step 1: preprocess
- String ppOutFile = cFile.replace(MiniCCCfg.MINICC_PP_INPUT_EXT, MiniCCCfg.MINICC_PP_OUTPUT_EXT);
-
if(pp.skip.equals("false")){
if(pp.type.equals("java")){
if(!pp.path.equals("")){
Class> c = Class.forName(pp.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), cFile, ppOutFile);
+ method.invoke(c.newInstance(), cFile);
}else{
MiniCCPreProcessor prep = new MiniCCPreProcessor();
- prep.run(cFile, ppOutFile);
+ filename = prep.run(cFile);
+ }
+ }else {
+ String ppOutFile = cFile.replace(MiniCCCfg.MINICC_PP_INPUT_EXT, MiniCCCfg.MINICC_PP_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(cFile, ppOutFile, pp.path);
+ } else {
+ this.run(cFile, ppOutFile, pp.path);
}
- }else if(pp.type.equals("python")){
- this.runPy(cFile, ppOutFile, pp.path);
- }else{
- this.run(cFile, ppOutFile, pp.path);
+ filename = ppOutFile;
}
}
// step 2: scan
- String scOutFile = ppOutFile.replace(MiniCCCfg.MINICC_PP_OUTPUT_EXT, MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT);
-
if(scanning.skip.equals("false")){
if(scanning.type.equals("java")){
if(!scanning.path.equals("")){
Class> c = Class.forName(scanning.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), ppOutFile, scOutFile);
+ method.invoke(c.newInstance(), filename);
}else{
MiniCCScanner sc = new MiniCCScanner();
- sc.run(ppOutFile, scOutFile);
+ filename = sc.run(filename);
}
- }else if(pp.type.equals("python")){
- this.runPy(ppOutFile, scOutFile, scanning.path);
- }else{
- this.run(ppOutFile, scOutFile, scanning.path);
+ }else {
+ String scOutFile = filename.replace(MiniCCCfg.MINICC_SCANNER_INPUT_EXT, MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(filename, scOutFile, scanning.path);
+ }else {
+ this.run(filename, scOutFile, scanning.path);
+ }
+ filename = scOutFile;
}
}
// step 3: parser
- String pOutFile = scOutFile.replace(MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT, MiniCCCfg.MINICC_PARSER_OUTPUT_EXT);
-
if(parsing.skip.equals("false")){
if(parsing.type.equals("java")){
if(parsing.path != ""){
Class> c = Class.forName(parsing.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), scOutFile, pOutFile);
+ method.invoke(c.newInstance(), filename);
}else{
MiniCCParser p = new MiniCCParser();
- p.run(scOutFile, pOutFile);
+ filename = p.run(filename);
}
- }else if(pp.type.equals("python")){
- this.runPy(scOutFile, pOutFile, parsing.path);
- }else{
- this.run(scOutFile, pOutFile, parsing.path);
+ }else {
+ String pOutFile = filename.replace(MiniCCCfg.MINICC_SCANNER_OUTPUT_EXT, MiniCCCfg.MINICC_PARSER_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(filename, pOutFile, parsing.path);
+ } else {
+ this.run(filename, pOutFile, parsing.path);
+ }
+ filename = pOutFile;
}
}
// step 4: semantic
- String seOutFile = pOutFile.replace(MiniCCCfg.MINICC_PARSER_OUTPUT_EXT, MiniCCCfg.MINICC_SEMANTIC_OUTPUT_EXT);
-
if(semantic.skip.equals("false")){
if(semantic.type.equals("java")){
if(!semantic.path.equals("")){
Class> c = Class.forName(semantic.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), pOutFile, seOutFile);
+ method.invoke(c.newInstance(), filename);
}else{
MiniCCSemantic se = new MiniCCSemantic();
- se.run(pOutFile, seOutFile);
+ filename = se.run(filename);
+ }
+ }else {
+ String seOutFile = filename.replace(MiniCCCfg.MINICC_PARSER_OUTPUT_EXT, MiniCCCfg.MINICC_SEMANTIC_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(filename, seOutFile, semantic.path);
+ }else{
+ this.run(filename, seOutFile, semantic.path);
}
- }else if(pp.type.equals("python")){
- this.runPy(pOutFile, seOutFile, semantic.path);
- }else{
- this.run(pOutFile, seOutFile, semantic.path);
+ filename = seOutFile;
}
}
// step 5: intermediate code generate
- String icOutFile = seOutFile.replace(MiniCCCfg.MINICC_SEMANTIC_OUTPUT_EXT, MiniCCCfg.MINICC_ICGEN_OUTPUT_EXT);
-
if(icgen.skip.equals("false")){
if(icgen.type.equals("java")){
if(!icgen.path.equals("")){
Class> c = Class.forName(icgen.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), seOutFile, icOutFile);
+ method.invoke(c.newInstance(), filename);
}else{
MiniCCICGen ic = new MiniCCICGen();
- ic.run(seOutFile, icOutFile);
+ filename = ic.run(filename);
+ }
+ }else {
+ String icOutFile = filename.replace(MiniCCCfg.MINICC_SEMANTIC_OUTPUT_EXT, MiniCCCfg.MINICC_ICGEN_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(filename, icOutFile, icgen.path);
+ } else {
+ this.run(filename, icOutFile, icgen.path);
}
- }else if(pp.type.equals("python")){
- this.runPy(seOutFile, icOutFile, icgen.path);
- }else{
- this.run(seOutFile, icOutFile, icgen.path);
+ filename = icOutFile;
}
}
// step 6: optimization
- String oOutFile = icOutFile.replace(MiniCCCfg.MINICC_ICGEN_OUTPUT_EXT, MiniCCCfg.MINICC_OPT_OUTPUT_EXT);
-
if(optimizing.skip.equals("false")){
if(optimizing.type.equals("java")){
if(!optimizing.path.equals("")){
Class> c = Class.forName(optimizing.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), icOutFile, oOutFile);
+ method.invoke(c.newInstance(), filename);
}else{
MiniCCOptimizer o = new MiniCCOptimizer();
- o.run(icOutFile, oOutFile);
+ filename = o.run(filename);
}
- }else if(pp.type.equals("python")){
- this.runPy(icOutFile, oOutFile, optimizing.path);
- }else{
- this.run(icOutFile, oOutFile, optimizing.path);
+ }else {
+ String oOutFile = filename.replace(MiniCCCfg.MINICC_ICGEN_OUTPUT_EXT, MiniCCCfg.MINICC_OPT_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(filename, oOutFile, optimizing.path);
+ } else {
+ this.run(filename, oOutFile, optimizing.path);
+ }
+ filename = oOutFile;
}
}
// step 7: code generate
- String cOutFile = oOutFile.replace(MiniCCCfg.MINICC_OPT_OUTPUT_EXT, MiniCCCfg.MINICC_CODEGEN_OUTPUT_EXT);
-
if(codegen.skip.equals("false")){
if(codegen.type.equals("java")){
if(!codegen.path.equals("")){
Class> c = Class.forName(codegen.path);
Method method = c.getMethod("run", String.class, String.class);
- method.invoke(c.newInstance(), oOutFile, cOutFile);
+ method.invoke(c.newInstance(), filename);
}else{
MiniCCCodeGen g = new MiniCCCodeGen();
- g.run(oOutFile, cOutFile);
+ filename = g.run(filename, codegen.arch);
}
- }else if(pp.type.equals("python")){
- this.runPy(oOutFile, cOutFile, codegen.path);
- }else{
- this.run(oOutFile, cOutFile, codegen.path);
+ }else {
+ String cOutFile = filename.replace(MiniCCCfg.MINICC_OPT_OUTPUT_EXT, MiniCCCfg.MINICC_CODEGEN_OUTPUT_EXT);
+ if(pp.type.equals("python")){
+ this.runPy(filename, cOutFile, codegen.path);
+ } else {
+ this.run(filename, cOutFile, codegen.path);
+ }
+ filename = cOutFile;
}
}
// step 8: simulate
+
if(simulating.skip.equals("false")){
- MIPSSimulator m = new MIPSSimulator();
- m.run(cOutFile);
+ IMiniCCSimulator m = null;
+ if(simulating.type.equals("riscv")) {
+ m = new RISCVSimulator();
+ } else {
+ m = new MIPSSimulator();
+ }
+
+ if(simulating.headless.equals("false")) {
+ m.run(null);
+ } else {
+ m.run(filename);
+ }
}
}
private void run(String iFile, String oFile, String path) throws IOException{
- Runtime rt = Runtime.getRuntime();//ʽexe ļ ļ
+ Runtime rt = Runtime.getRuntime();//鏍煎紡锛歟xe鍚� 杈撳叆鏂囦欢 杈撳嚭鏂囦欢
Process p = rt.exec(path + " " + iFile + " " + oFile);
try {
p.wait();
@@ -255,7 +279,7 @@ private void run(String iFile, String oFile, String path) throws IOException{
}
private void runPy(String iFile, String oFile, String path) throws IOException{
- PythonInterpreter pyi = new PythonInterpreter();//ʽPythonű ļ ļ
+ PythonInterpreter pyi = new PythonInterpreter();//鏍煎紡锛歅ython鑴氭湰鍚� 杈撳叆鏂囦欢 杈撳嚭鏂囦欢
pyi.exec(path + " " + iFile + " " + oFile);
}
}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/codegen/IMiniCCCodeGen.java b/src/bit/minisys/minicc/codegen/IMiniCCCodeGen.java
similarity index 51%
rename from bit-minic-clean/src/bit/minisys/minicc/codegen/IMiniCCCodeGen.java
rename to src/bit/minisys/minicc/codegen/IMiniCCCodeGen.java
index 50527e93..3c18168b 100644
--- a/bit-minic-clean/src/bit/minisys/minicc/codegen/IMiniCCCodeGen.java
+++ b/src/bit/minisys/minicc/codegen/IMiniCCCodeGen.java
@@ -7,5 +7,10 @@
import org.xml.sax.SAXException;
public interface IMiniCCCodeGen {
- public void run(String iFile, String oFile) throws IOException, ParserConfigurationException, SAXException;
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ * @param type architecture
+ */
+ public String run(String iFile, String type) throws Exception;
}
diff --git a/src/bit/minisys/minicc/icgen/IMiniCCICGen.java b/src/bit/minisys/minicc/icgen/IMiniCCICGen.java
new file mode 100644
index 00000000..b9d9c739
--- /dev/null
+++ b/src/bit/minisys/minicc/icgen/IMiniCCICGen.java
@@ -0,0 +1,11 @@
+package bit.minisys.minicc.icgen;
+
+import java.io.IOException;
+
+public interface IMiniCCICGen {
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ */
+ public String run(String iFile) throws Exception;
+}
diff --git a/src/bit/minisys/minicc/optimizer/IMiniCCOptimizer.java b/src/bit/minisys/minicc/optimizer/IMiniCCOptimizer.java
new file mode 100644
index 00000000..ad333049
--- /dev/null
+++ b/src/bit/minisys/minicc/optimizer/IMiniCCOptimizer.java
@@ -0,0 +1,11 @@
+package bit.minisys.minicc.optimizer;
+
+import java.io.IOException;
+
+public interface IMiniCCOptimizer {
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ */
+ public String run(String iFile) throws Exception;
+}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/parser/IMiniCCParser.java b/src/bit/minisys/minicc/parser/IMiniCCParser.java
similarity index 57%
rename from bit-minic-clean/src/bit/minisys/minicc/parser/IMiniCCParser.java
rename to src/bit/minisys/minicc/parser/IMiniCCParser.java
index 37b96663..ba45b4ce 100644
--- a/bit-minic-clean/src/bit/minisys/minicc/parser/IMiniCCParser.java
+++ b/src/bit/minisys/minicc/parser/IMiniCCParser.java
@@ -7,5 +7,9 @@
import org.xml.sax.SAXException;
public interface IMiniCCParser {
- public void run(String iFile, String oFile) throws ParserConfigurationException, SAXException, IOException;
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ */
+ public String run(String iFile) throws Exception;
}
diff --git a/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java b/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java
new file mode 100644
index 00000000..80613ca8
--- /dev/null
+++ b/src/bit/minisys/minicc/pp/IMiniCCPreProcessor.java
@@ -0,0 +1,9 @@
+package bit.minisys.minicc.pp;
+
+public interface IMiniCCPreProcessor {
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ */
+ public String run(String iFile) throws Exception;
+}
diff --git a/src/bit/minisys/minicc/scanner/IMiniCCScanner.java b/src/bit/minisys/minicc/scanner/IMiniCCScanner.java
new file mode 100644
index 00000000..87a43b45
--- /dev/null
+++ b/src/bit/minisys/minicc/scanner/IMiniCCScanner.java
@@ -0,0 +1,11 @@
+package bit.minisys.minicc.scanner;
+
+import java.io.IOException;
+
+public interface IMiniCCScanner {
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ */
+ public String run(String iFile) throws Exception;
+}
diff --git a/src/bit/minisys/minicc/semantic/IMiniCCSemantic.java b/src/bit/minisys/minicc/semantic/IMiniCCSemantic.java
new file mode 100644
index 00000000..256c6db3
--- /dev/null
+++ b/src/bit/minisys/minicc/semantic/IMiniCCSemantic.java
@@ -0,0 +1,11 @@
+package bit.minisys.minicc.semantic;
+
+import java.io.IOException;
+
+public interface IMiniCCSemantic {
+ /*
+ * @return String the path of the output file
+ * @param iFile input file path
+ */
+ public String run(String iFile) throws Exception;
+}
diff --git a/src/bit/minisys/minicc/simulator/IMIPSSimulator.java b/src/bit/minisys/minicc/simulator/IMIPSSimulator.java
new file mode 100644
index 00000000..34ef409c
--- /dev/null
+++ b/src/bit/minisys/minicc/simulator/IMIPSSimulator.java
@@ -0,0 +1,8 @@
+package bit.minisys.minicc.simulator;
+
+public interface IMIPSSimulator {
+ /*
+ * @param input input file path
+ */
+ public void run(String input) throws Exception;
+}
diff --git a/bit-minic-clean/src/bit/minisys/minicc/simulator/IMiniCCSimulator.java b/src/bit/minisys/minicc/simulator/IMiniCCSimulator.java
similarity index 100%
rename from bit-minic-clean/src/bit/minisys/minicc/simulator/IMiniCCSimulator.java
rename to src/bit/minisys/minicc/simulator/IMiniCCSimulator.java
diff --git a/bit-minic-clean/src/bit/minisys/minicc/util/MiniCCUtil.java b/src/bit/minisys/minicc/util/MiniCCUtil.java
similarity index 100%
rename from bit-minic-clean/src/bit/minisys/minicc/util/MiniCCUtil.java
rename to src/bit/minisys/minicc/util/MiniCCUtil.java