LexerContext class
Пакет: com.hypixel.hytale.server.npc.util.expression.compile
Файл: com/hypixel/hytale/server/npc/util/expression/compile/LexerContext.java
Поля (9)
| Модификаторы | Тип | Имя |
|---|---|---|
|
|
break |
|
|
continue |
private |
String |
expression |
|
|
var1 |
|
char |
var2 |
|
|
var2 |
|
|
var2 |
|
|
var2 |
|
|
var2 |
Методы (32)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
abstract |
throw new |
ParseExceptionthrow new ParseException(var1, this.tokenPosition) |
abstract |
throw new |
ParseExceptionthrow new ParseException("Invalid number format", this.tokenPosition) |
protected |
char |
addTokenCharacterchar addTokenCharacter(char var1) |
protected |
void |
adjustPositionvoid adjustPosition(int var1) |
private |
char |
copyDigitschar copyDigits(char var1) |
protected |
char |
currentCharchar currentChar() |
protected |
boolean |
eatWhiteSpaceboolean eatWhiteSpace() |
abstract |
|
for for(char var2 = this.nextChar("Unterminated string") |
public |
String |
getExpressionString getExpression() |
protected |
int |
getPositionint getPosition() |
public |
T |
getTokenT getToken() |
public |
double |
getTokenNumberdouble getTokenNumber() |
public |
int |
getTokenPositionint getTokenPosition() |
protected |
boolean |
haveCharboolean haveChar() |
|
|
if if(this.position >= this.length) |
|
|
if if(var1 < this.position) |
|
|
if if(this.position < this.length && var2 == '.') |
|
|
if if(var2 == '-' || var2 == '+') |
public |
void |
initvoid init(@Nonnull String var1) |
protected |
boolean |
isNumberboolean isNumber(char var1) |
protected |
char |
nextCharchar nextChar(String var1) |
protected |
void |
parseIdentvoid parseIdent(char var1) |
protected |
void |
parseNumbervoid parseNumber(char var1) |
protected |
void |
parseStringvoid parseString(char var1) |
protected |
char |
peekCharchar peekChar(char var1) |
protected |
char |
peekCharchar peekChar() |
protected |
char |
peekCharchar peekChar(int var1, char var2) |
protected |
char |
peekCharchar peekChar(int var1) |
public |
void |
resetTokenvoid resetToken() |
protected |
void |
setPositionvoid setPosition(int var1) |
public |
T |
setTokenT setToken(T var1) |
|
|
while while(this.position < this.length) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.npc.util.expression.compile;
class="kw">import java.text.ParseException;
class="kw">import javax.annotation.Nonnull;
class="kw">public class LexerContext<T> {
class="kw">private String expression;
class="kw">private int length;
class="kw">private int position;
class="kw">private T token;
class="kw">private int tokenPosition;
@Nonnull
class="kw">private StringBuilder tokenString = new StringBuilder(200);
class="kw">private double tokenNumber;
class="kw">public LexerContext() {
}
class="kw">public void init(@Nonnull String var1) {
this.expression = var1;
this.length = var1.length();
this.position = 0;
}
class="kw">public void resetToken() {
this.tokenPosition = this.position;
this.tokenString.setLength(0);
}
class="kw">public T setToken(T var1) {
this.token = var1;
class="kw">return var1;
}
class="kw">public String getExpression() {
class="kw">return this.expression;
}
class="kw">public T getToken() {
class="kw">return this.token;
}
class="kw">public int getTokenPosition() {
class="kw">return this.tokenPosition;
}
@Nonnull
class="kw">public String getTokenString() {
class="kw">return this.tokenString.toString();
}
class="kw">public double getTokenNumber() {
class="kw">return this.tokenNumber;
}
class="kw">protected char nextChar(String var1) class="kw">throws ParseException {
this.position++;
if (this.position >= this.length) {
throw new ParseException(var1, this.tokenPosition);
} else {
class="kw">return this.expression.charAt(this.position);
}
}
class="kw">protected boolean haveChar() {
class="kw">return this.position < this.length;
}
class="kw">protected char currentChar() {
class="kw">return this.expression.charAt(this.position);
}
class="kw">protected char peekChar(char var1) {
class="kw">return this.position < this.length ? this.currentChar() : var1;
}
class="kw">protected char peekChar() {
class="kw">return this.position < this.length ? this.currentChar() : '\u0000';
}
class="kw">protected char peekChar(int var1, char var2) {
class="kw">return this.position + var1 < this.length ? this.expression.charAt(this.position + var1) : var2;
}
class="kw">protected char peekChar(int var1) {
class="kw">return this.position + var1 < this.length ? this.expression.charAt(this.position + var1) : '\u0000';
}
class="kw">protected boolean eatWhiteSpace() {
while (this.position < this.length && Character.isWhitespace(this.expression.charAt(this.position))) {
this.position++;
}
class="kw">return this.position < this.length;
}
class="kw">protected char addTokenCharacter(char var1) {
this.tokenString.append(var1);
this.position++;
class="kw">return this.peekChar();
}
class="kw">protected int getPosition() {
class="kw">return this.position;
}
class="kw">protected void setPosition(int var1) {
this.position = var1;
}
class="kw">protected void adjustPosition(int var1) {
if (var1 < this.position) {
this.tokenString.setLength(this.tokenString.length() - (this.position - var1));
}
this.position = var1;
}
class="kw">protected boolean isNumber(char var1) {
class="kw">return Character.isDigit(var1) || var1 == '.' && Character.isDigit(this.peekChar(1, '\u0000'));
}
class="kw">protected void parseNumber(char var1) class="kw">throws ParseException {
char var2 = var1;
this.tokenNumber = 0.0;
var2 = this.copyDigits(var2);
if (this.position < this.length && var2 == '.') {
this.tokenString.append(var2);
this.position++;
if (!Character.isDigit(this.currentChar())) {
throw new ParseException("Invalid number format", this.tokenPosition);
}
var2 = this.copyDigits(var2);
}
if (this.position < this.length && (var2 == 'e' || var2 == 'E')) {
this.tokenString.append(var2);
var2 = this.nextChar("Invalid number format");
if (var2 == '-' || var2 == '+') {
this.tokenString.append(var2);
var2 = this.nextChar("Invalid number format");
}
if (!Character.isDigit(var2)) {
throw new ParseException("Invalid number format", this.tokenPosition);
}
this.copyDigits(var2);
}
this.tokenNumber = Double.parseDouble(this.tokenString.toString());
}
class="kw">private char copyDigits(char var1) {
while (this.position < this.length) {
var1 = this.currentChar();
if (Character.isDigit(var1)) {
this.tokenString.append(var1);
this.position++;
class="kw">continue;
}
break;
}
class="kw">return var1;
}
class="kw">protected void parseIdent(char var1) {
this.tokenString.append(var1);
this.position++;
while (this.position < this.length && (Character.isLetterOrDigit(this.currentChar()) || this.currentChar() == '_')) {
this.tokenString.append(this.currentChar());
this.position++;
}
}
class="kw">protected void parseString(char var1) class="kw">throws ParseException {
this.tokenPosition = this.position;
for (char var2 = this.nextChar("Unterminated string"); var2 != var1; var2 = this.nextChar("Unterminated string")) {
this.tokenString.append(var2 != '\\' ? var2 : this.nextChar("Unterminated string"));
}
this.position++;
}
}