Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
Added support for temporary variables
Dieser Commit ist enthalten in:
Ursprung
2719308ada
Commit
77d1317964
@ -33,6 +33,7 @@ import com.sk89q.worldedit.expression.lexer.tokens.Token;
|
|||||||
import com.sk89q.worldedit.expression.runtime.Constant;
|
import com.sk89q.worldedit.expression.runtime.Constant;
|
||||||
import com.sk89q.worldedit.expression.runtime.Functions;
|
import com.sk89q.worldedit.expression.runtime.Functions;
|
||||||
import com.sk89q.worldedit.expression.runtime.RValue;
|
import com.sk89q.worldedit.expression.runtime.RValue;
|
||||||
|
import com.sk89q.worldedit.expression.runtime.Variable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a list of tokens into an executable tree.
|
* Processes a list of tokens into an executable tree.
|
||||||
@ -103,8 +104,13 @@ public class Parser {
|
|||||||
} else {
|
} else {
|
||||||
RValue variable = variables.get(identifierToken.value);
|
RValue variable = variables.get(identifierToken.value);
|
||||||
if (variable == null) {
|
if (variable == null) {
|
||||||
|
if (next instanceof OperatorToken && ((OperatorToken)next).operator.equals("=")) {
|
||||||
|
// Ugly hack to make temporary variables work while not sacrificing error reporting.
|
||||||
|
variables.put(identifierToken.value, variable = new Variable(0));
|
||||||
|
} else {
|
||||||
throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found");
|
throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
halfProcessed.add(variable);
|
halfProcessed.add(variable);
|
||||||
}
|
}
|
||||||
expressionStart = false;
|
expressionStart = false;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren