mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-27 05:00:08 +08:00
Added support for temporary variables
This commit is contained in:
parent
2719308ada
commit
77d1317964
@ -33,6 +33,7 @@
|
||||
import com.sk89q.worldedit.expression.runtime.Constant;
|
||||
import com.sk89q.worldedit.expression.runtime.Functions;
|
||||
import com.sk89q.worldedit.expression.runtime.RValue;
|
||||
import com.sk89q.worldedit.expression.runtime.Variable;
|
||||
|
||||
/**
|
||||
* Processes a list of tokens into an executable tree.
|
||||
@ -103,7 +104,12 @@ private final RValue parseInternal(boolean isStatement) throws ParserException {
|
||||
} else {
|
||||
RValue variable = variables.get(identifierToken.value);
|
||||
if (variable == null) {
|
||||
throw new ParserException(current.getPosition(), "Variable '" + identifierToken.value + "' not found");
|
||||
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");
|
||||
}
|
||||
}
|
||||
halfProcessed.add(variable);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user