token.java

来自「语法分析器」· Java 代码 · 共 71 行

JAVA
71
字号
/**
 * this class is used for storage a token information form lex analysis a token
 * include three aspects information
 * 
 * @author:贺静
 * @version:1.2
 */
public class Token {
	// the line number of current token
	private int lineNum;

	// the type of current token
	private int type;

	// the name of current token
	private String name;

	public Token() {
		this.name = "";
	}

	public Token(String name, int type, int lineNum) {
		this.name = name;
		this.type = type;
		this.lineNum = lineNum;
	}

	/**
	 * @return an int as the type of the token
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param lex
	 *            for change current token's type
	 */
	public void setType(int lex) {
		this.type = lex;
	}

	/**
	 * get then line number of the token
	 */
	public int getLineNum() {
		return lineNum;
	}

	/*
	 * set the line number of the token
	 */
	public void setLineNum(int lineNum) {
		this.lineNum = lineNum;
	}

	/*
	 * get the name of the token
	 */
	public String getName() {
		return name;
	}

	/*
	 * set the name of the token
	 */
	public void setName(String name) {
		this.name = name;
	}
}

⌨️ 快捷键说明

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