⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 实现的一个简单的语言编译器,可以编译类JAVA 的小语言
💻 JAVA
字号:
package edu.ustc.cs.compile.parser;

import java.io.File;

import org.eclipse.jdt.core.dom.ASTNode;

import edu.ustc.cs.compile.parser.expr.ExprParser;
import edu.ustc.cs.compile.platform.interfaces.CheckerException;
import edu.ustc.cs.compile.platform.interfaces.InterRepresent;
import edu.ustc.cs.compile.platform.interfaces.ParserException;
import edu.ustc.cs.compile.platform.util.ASTView.core.ASTViewer;

public class Main {
	private static boolean viewAST =  true;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//runPart1();
		runPart2();
	}
	
 
	public static void runPart2() {
		boolean viewAST = true;
		
        String srcFileName = "E:/student/PB05011/PB05210242/test/quicksort.mj"; 
        File srcFile = new File(srcFileName);
		ASTNode block;
		ExprParser parser = new ExprParser();
		InterRepresent ir = null;
        try {
            ir = parser.doParse(srcFile);
        } catch (ParserException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        if (!parser.getResult()) {
        	System.out.println("[NOTICE] Vital error found in the parser,compilering stopped.....");
        	System.exit(-1);
        }
        // 调用ASTViewer显示生成的AST	
        if (viewAST){
            ASTViewer astviewer = new ASTViewer((ASTNode)ir.getIR());
            astviewer.show();
        }
        
        Checker socheck = new Checker();
        try{
        	if (!socheck.check(ir)) System.exit(-1);
        }catch (CheckerException e) {
        	e.printStackTrace();
        	System.exit(-1);
        }
        System.out.println(" 前端:PB05210242王卅");
        //    System.out.println("Checker has not found any errors.");
        //} else {
        //    System.out.println("Checker has found some errors.");
        //}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -