Class AbstractEvaluator
- All Implemented Interfaces:
Evaluator
- Direct Known Subclasses:
AbstractStandardEvaluator
Evaluator
implementations.- Author:
- Curtis Rueden
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the value of a variable.Gets the parser used when evaluating expressions.boolean
isStrict()
Gets whether the evaluator is operating in strict mode.void
Sets the value of a variable.void
Assigns variables en masse.void
setStrict
(boolean strict) Sets whether the evaluator is operating in strict mode.
-
Constructor Details
-
AbstractEvaluator
public AbstractEvaluator() -
AbstractEvaluator
-
-
Method Details
-
getParser
Description copied from interface:Evaluator
Gets the parser used when evaluating expressions. -
isStrict
public boolean isStrict()Description copied from interface:Evaluator
Gets whether the evaluator is operating in strict mode. -
setStrict
public void setStrict(boolean strict) Description copied from interface:Evaluator
Sets whether the evaluator is operating in strict mode. Evaluators operate in strict mode by default.When evaluating strictly, usage of an unassigned variable token in a place where its value is needed will generate an
IllegalArgumentException
with an "Unknown variable" message; in non-strict mode, such a variable will instead be resolved to an object of typeUnresolved
with the same name as the original variable.In cases such as assignment, this may be sufficient to complete the evaluation; for example, the expression
foo=bar
will complete successfully in non-strict mode, with the variablefoo
containing an object of typeUnresolved
and token value"bar"
. But in cases where the unresolved value is needed as an input for additional operations, the evaluation may still ultimately fail if the operation in question is not defined for unresolved values. For example, theDefaultStackEvaluator
will fail with an "Unsupported binary operator" exception when given the expressionfoo+bar
, sincefoo
andbar
are unresolved variables, and the+
operator cannot handle such objects. -
get
Description copied from interface:Evaluator
Gets the value of a variable. -
set
Description copied from interface:Evaluator
Sets the value of a variable. -
setAll
Description copied from interface:Evaluator
Assigns variables en masse.
-