sync with reality?
This commit is contained in:
parent
370c107793
commit
de572db0bc
|
@ -53,4 +53,4 @@ STARTER_RELAY_LOGIC=rpm < cranking_rpm
|
|||
|
||||
BOOST_CONTROLLER=fsio_table (3, rpm, map) / 100
|
||||
|
||||
ANALOG_CONDITION=if(fsio_input (0) > 20, 0, 10)
|
||||
ANALOG_CONDITION=if(fsio_analog_input (0) > 20, 0, 10)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.fathzer.soft.javaluator;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
/** An abstract evaluator, able to evaluate infix expressions.
|
||||
* <br>Some standard evaluators are included in the library, you can define your own by subclassing this class.
|
||||
|
@ -184,7 +186,13 @@ public abstract class AbstractEvaluator<T> {
|
|||
System.out.println("doFunction " + function + " " + argCount);
|
||||
|
||||
if (function.getMinimumArgumentCount()>argCount || function.getMaximumArgumentCount()<argCount) {
|
||||
throw new IllegalArgumentException("Invalid argument count for "+function.getName() + " while " + argCount);
|
||||
Iterator<?> a = getArguments(values, argCount);
|
||||
Iterable iterable = () -> a;
|
||||
|
||||
List actualList = (List) StreamSupport
|
||||
.stream(iterable.spliterator(), false)
|
||||
.collect(Collectors.toList());
|
||||
throw new IllegalArgumentException("Invalid argument count for "+function.getName() + " while " + argCount + ": " + actualList);
|
||||
}
|
||||
values.push(evaluate(function, getArguments(values, argCount), evaluationContext));
|
||||
}
|
||||
|
|
|
@ -245,6 +245,11 @@ public class DoubleEvaluator extends AbstractEvaluator<Double> {
|
|||
ParsePosition p = new ParsePosition(0);
|
||||
Number result = FORMATTER.get().parse(literal, p);
|
||||
if (p.getIndex() == 0 || p.getIndex() != literal.length()) {
|
||||
/**
|
||||
* We are here if function is not know
|
||||
* TODO: shall we throw exception?
|
||||
*/
|
||||
System.err.println("Not known " + literal);
|
||||
return 6666666.0; // let's return this magic in case of any function call
|
||||
// throw new IllegalArgumentException(literal + " is not a number");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue