rpn progress
This commit is contained in:
parent
a9fca33dea
commit
e563021963
|
@ -1,5 +1,7 @@
|
|||
package com.fathzer.soft.javaluator;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Arrays;
|
||||
|
@ -46,6 +48,13 @@ import java.util.Locale;
|
|||
* @see <a href="../../../license.html">License information</a>
|
||||
*/
|
||||
public class DoubleEvaluator extends AbstractEvaluator<Double> {
|
||||
@NotNull
|
||||
public static DoubleEvaluator process(String expression) {
|
||||
DoubleEvaluator evaluator = new DoubleEvaluator();
|
||||
evaluator.evaluate(expression.toLowerCase());
|
||||
return evaluator;
|
||||
}
|
||||
|
||||
/** The order or operations (operator precedence) is not clearly defined, especially between the unary minus operator and exponentiation
|
||||
* operator (see <a href="http://en.wikipedia.org/wiki/Order_of_operations#Exceptions_to_the_standard">http://en.wikipedia.org/wiki/Order_of_operations</a>).
|
||||
* These constants define the operator precedence styles.
|
||||
|
|
|
@ -65,12 +65,10 @@ public class CompileTool {
|
|||
|
||||
String expression = line.substring(indexOfEquals + 1).trim();
|
||||
|
||||
DoubleEvaluator evaluator = new DoubleEvaluator();
|
||||
evaluator.evaluate(expression.toLowerCase());
|
||||
|
||||
String rpn = evaluator.getRusEfi();
|
||||
String rpn = DoubleEvaluator.process(expression).getRusEfi();
|
||||
|
||||
bw.write("\n// Human-readable: " + expression + "\r\n");
|
||||
bw.write("#define " + name + " \"" + rpn + "\"\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.rusefi.ui.fsio;
|
||||
|
||||
import com.autsia.bracer.BracerParser;
|
||||
import com.fathzer.soft.javaluator.DoubleEvaluator;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* (c) Andrey Belomutskiy
|
||||
|
@ -25,7 +24,7 @@ public class FlexibleControls {
|
|||
human2rpm.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
process();
|
||||
process(FlexibleControls.this.normalForm.getText());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -37,17 +36,11 @@ public class FlexibleControls {
|
|||
|
||||
normalForm.setText("(time_since_boot < 4) | (rpm > 0)");
|
||||
|
||||
process();
|
||||
process(normalForm.getText());
|
||||
}
|
||||
|
||||
private void process() {
|
||||
BracerParser bp = new BracerParser();
|
||||
try {
|
||||
bp.parse(normalForm.getText());
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
rpnForm.setText(bp.getRusEfi());
|
||||
private void process(String text) {
|
||||
rpnForm.setText(DoubleEvaluator.process(text).getRusEfi());
|
||||
}
|
||||
|
||||
public JPanel getPanel() {
|
||||
|
|
Loading…
Reference in New Issue