simpletoken.java
来自「是有关解释器的.用JAVA编写.可以解释一般的JAVA程序.」· Java 代码 · 共 77 行
JAVA
77 行
/**
* Contains a simple char from the following set. : '.', ',', ';', '=', '~' (the
* last representing the end of the file).
*/
public class SimpleToken extends Token {
private char symbol;
SimpleToken(int l, int p, char c) {
super(l, p);
symbol = c;
}
/**
* @see #isMessageSend()
* @see #isSequence()
* @see #isStatementEnd()
* @see #isAssign()
* @see #isEOF()
*/
char content() {
return symbol;
}
boolean isSimple() {
return true;
}
/**
* Is it a dot ('.'), which represents a method call/message sent?
*
* @see #content()
*/
boolean isMessageSend() {
return symbol == '.';
}
/**
* Is it a comma (','), representing the divider in sequences?
*
* @see #content()
*/
boolean isSequence() {
return symbol == ',';
}
/**
* Is it a semicolon (';'), representing the end of a statement?
*
* @see #content()
*/
boolean isStatementEnd() {
return symbol == ';';
}
/**
* Is it a equal sign ('='), representing an assignment?
*
* @see #content()
*/
boolean isAssign() {
return symbol == '=';
}
/**
* Is it a tilde ('~'), representing the end of the input file?
*
* @see #content()
*/
boolean isEOF() {
return symbol == '~';
}
public String toString() {
return "SimpleToken<" + symbol + ">";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?