token.java
来自「是有关解释器的.用JAVA编写.可以解释一般的JAVA程序.」· Java 代码 · 共 69 行
JAVA
69 行
/**
* 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 + =
减小字号Ctrl + -
显示快捷键?