Package heronarts.lx.structure
Class Expression
java.lang.Object
heronarts.lx.structure.Expression
Expressions can have ambiguous types when nested with parentheses! This is getting
out of control and I really should have just used a proper expression parsing library
of some sort.
Did you actually read that? I kept leaving comments like that for years, suggesting this
should all be replaced, but at this point (July 2025) I suppose I've changed my tune.
This is self-contained enough in a reasonably manageable small-ish amount of code, with a
few particular bits-and-bobs like rounding float precision errors that are of direct
relevance to the LXF use case. Thanks to Andrew Look for adding unit test support.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Expression.Result<?> Evaluate a mathematical expression containing a mix of operators, function calls and parentheses.static booleanevaluateBoolean(String expression) static floatevaluateNumeric(String expression)
-
Constructor Details
-
Expression
public Expression()
-
-
Method Details
-
evaluateNumeric
-
evaluateBoolean
-
evaluate
Evaluate a mathematical expression containing a mix of operators, function calls and parentheses. The result type is ambiguous, depending upon the content. Use evaluateNumeric() or evaluateBoolean() when a known result type is desired.- Parameters:
expression- Portion of expression to evaluate- Returns:
- Result, which may be Boolean, Numeric or List
-