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

📄 prettyprinter.java

📁 program assegment for compiler
💻 JAVA
字号:
package edu.berkeley.cs164.interp;

import java.util.List;

import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.Block;
import org.eclipse.jdt.core.dom.ExpressionStatement;
import org.eclipse.jdt.core.dom.IfStatement;
import org.eclipse.jdt.core.dom.InfixExpression;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.NumberLiteral;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.internal.corext.dom.GenericVisitor;

/**
 * This is the pretty printer class. As given, it does nothing. You
 * will write the class as part of the assignment.
 */
public class PrettyPrinter extends GenericVisitor {
	public boolean visit(TypeDeclaration e) {
		// TODO more code is needed in this method
		List l = e.bodyDeclarations();
		assert l.size() == 1;
		ASTNode ch = (ASTNode) l.get(0);
		ch.accept(this);
		return false;
	}
		
	public boolean visit(MethodDeclaration e) {
		// TODO more code is needed in this method
		e.getBody().accept(this);
		return false;
	}
	
	public boolean visit(NumberLiteral e) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + e.getClass().getName() + "]");
		return false;
	}

	public boolean visit(MethodInvocation e) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + e.getClass().getName() + "]");
		return false;
	}
	
	public boolean visit(Assignment e) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + e.getClass().getName() + "]");
		return false;
	}

	public boolean visit(InfixExpression e) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + e.getClass().getName() + "]");
		return false;
	}

	public boolean visit(SimpleName e) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + e.getClass().getName() + "]");
		return false;
	}

	public boolean visit(ExpressionStatement s) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + s.getClass().getName() + "]");
		return false;
	}
	
	public boolean visit(IfStatement s) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + s.getClass().getName() + "]");
		return false;
	}

	public boolean visit(WhileStatement s) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + s.getClass().getName() + "]");
		return false;
	}

	public boolean visit(Block s) {
		// TODO Implement this node type
		System.out.println("[PrettyPrinter not implemented for node type " + s.getClass().getName() + "]");
		return false;
	}
}

⌨️ 快捷键说明

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