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

📄 token.java

📁 是有关解释器的.用JAVA编写.可以解释一般的JAVA程序.
💻 JAVA
字号:
/**
 * Tokens are lexical identities, generated by the scanner and used by the
 * parser. There are different kinds of tokens, all derived from this abstract
 * class. <code>AbstractSyntaxNode</code> contains several methods to read and
 * check tokens. <code>Token</code> contains methods to check the token type,
 * the object has to be "casted" to that certain type, to call any methods
 * specific to that type.
 * 
 * @see Scanner
 * @see AbstractSyntaxNode
 */
public abstract class Token {
    private int line; // occurred at "line" in file

    private int pos; // occurred at "pos" within line

    /**
     * Constructor setting the position of this token.
     * 
     * @param l
     *            line
     * @param p
     *            position within line (column)
     */
    Token(int l, int p) {
        line = l;
        pos = p;
    }

    int line() {
        return line;
    }

    int pos() {
        return pos;
    }

    // The following methods return false by default, this is changed by the
    // actual implementations in derived classes.

    boolean isSimple() {
        return false;
    }

    boolean isBracket() {
        return false;
    }

    boolean isOperator() {
        return false;
    }

    boolean isKeyword() {
        return false;
    }

    boolean isIdentifier() {
        return false;
    }

    boolean isBooleanLiteral() {
        return false;
    }

    boolean isNumberLiteral() {
        return false;
    }
}

⌨️ 快捷键说明

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