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

📄 calculatestack.java

📁 词法和语法分析器
💻 JAVA
字号:
package cminusCompiler;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedList;
import java.util.Stack;

/**   
 * @author tanfei E-mail:tanfei158876110@163.com   
 * @version Create Time:2007-12-9 上午01:10:51   
 * description:   
 */
public class CalculateStack {
	
	private Stack<InputLine> input;
	
	private Stack<String> parse;
	
	private String firstElement;
	
	private BufferedReader brReader;
	
	private String name;

	public CalculateStack(Stack<InputLine> i, Stack<String> p, String n, String name) {
		this.input = i;
		this.parse= p;
		this.firstElement = n;
		this.name = name;
		try {
			brReader = new BufferedReader(new FileReader(name + ".txt"));
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("The file " + this.name + ".txt can not be found!");
			System.exit(1);
		}

	}
	
	public void constructInputStack(){
		try{
		int i;
		LinkedList<InputLine> tempList = new LinkedList<InputLine>();
		String str;
		str = brReader.readLine();
		str = brReader.readLine();
		while(str != null){
			tempList.add(new InputLine(str));
			str = brReader.readLine();
		}
		for(i = tempList.size() - 1; i >= 0; i--){
			input.push(tempList.get(i));
		}
		tempList.clear();
		tempList = null;
		System.gc();
		}catch (Throwable t){
			t.printStackTrace();
			System.out.println("Construct input stack error!");
			System.exit(1);
		}
	}
	
	public void constructParseStack(){
		parse.push(firstElement);
	}

}

⌨️ 快捷键说明

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