Skip to content

Commit 9d5bd3d

Browse files
committed
save
1 parent 911f695 commit 9d5bd3d

2 files changed

Lines changed: 37 additions & 20 deletions

File tree

pom.xml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.github.gbenroscience</groupId>
55
<artifactId>parser-ng</artifactId>
6-
<version>1.1.0</version>
6+
<version>1.1.1</version>
77
<packaging>jar</packaging>
88
<!--
99
I started this project 2009 and have been upgrading it since then.
@@ -14,9 +14,7 @@
1414
<name>ParserNG</name>
1515
<description>Rich and Performant, Cross Platform Java Library(100% Java).No native dependencies.
1616
ParserNG is the height of interpreted Math parsing in Java. It is the fastest of all interpreted Java math parsers.
17-
Version 1.1.0 retains high frequency execution and squashes assignment bugs in Functions, Matrices and Rotors.
18-
It also allows the rotor function to rotate a Matrix(Nx3) of Points and produces an output which is a Matrix(Nx3) of the rotated points.
19-
It continues to support the 2 Point rotation form and also fixes and upgrades a bug in the function rotation form.
17+
Version 1.1.1 implements the dynamic version read of ParserNG jar executable
2018
</description>
2119
<url>https://github.com/gbenroscience/ParserNG</url>
2220

@@ -104,7 +102,7 @@
104102
<configuration>
105103
<archive>
106104
<manifest>
107-
<mainClass>math.Main</mainClass>
105+
<mainClass>com.github.gbenroscience.math.Main</mainClass>
108106
</manifest>
109107
</archive>
110108
</configuration>

src/main/java/com/github/gbenroscience/math/Main.java

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,37 @@
66
import java.util.List;
77

88
import com.github.gbenroscience.interfaces.Solvable;
9-
import com.github.gbenroscience.logic.DRG_MODE;
109
import com.github.gbenroscience.parser.ExpandingExpression;
1110
import com.github.gbenroscience.parser.LogicalExpression;
1211
import com.github.gbenroscience.parser.MathExpression;
1312
import com.github.gbenroscience.parser.cmd.ParserCmd;
1413
import com.github.gbenroscience.parser.logical.ExpressionLogger;
1514
import com.github.gbenroscience.parser.methods.Help;
15+
import java.util.Properties;
16+
import java.io.InputStream;
1617

1718
public class Main {
1819

20+
public static final class RuntimeVersion {
21+
22+
final static String getVersion() {
23+
try (InputStream resourceAsStream = RuntimeVersion.class.getResourceAsStream(
24+
"/META-INF/maven/com.github.gbenroscience/parser-ng/pom.properties")) {
25+
26+
Properties props = new Properties();
27+
if (resourceAsStream != null) {
28+
props.load(resourceAsStream);
29+
return props.getProperty("version");
30+
}
31+
} catch (Exception e) {
32+
// Log error
33+
}
34+
return "Unknown";
35+
}
36+
}
37+
1938
public static class MultiSwitch {
39+
2040
private final String[] switches;
2141

2242
public MultiSwitch(String... switches) {
@@ -76,7 +96,7 @@ public String getSwitch(int i) {
7696
private static boolean logic = false;
7797
private static boolean expandable = false;
7898

79-
public static void main(String... args) throws IOException {
99+
public static void main(String... args) throws IOException {
80100
List<String> aargs = new ArrayList<>(Arrays.asList(args));
81101
if (verboseSwitch.isContained(aargs)) {
82102
//todo pass, to debug in ParserNG engine
@@ -119,14 +139,14 @@ public static void main(String... args) throws IOException {
119139
}
120140
String r = null;
121141
try {
122-
Solvable exp = logic ?
123-
new LogicalExpression(ex, LogicalExpression.verboseStderrLogger) :
124-
expandable ?
125-
new ExpandingExpression(ex, ExpandingExpression.getValuesFromVariables(), ExpandingExpression.verboseStderrLogger) :
126-
new MathExpression(ex);
127-
r = exp.solve();
128-
}catch(Exception fatal){
129-
if (verbose){
142+
Solvable exp = logic
143+
? new LogicalExpression(ex, LogicalExpression.verboseStderrLogger)
144+
: expandable
145+
? new ExpandingExpression(ex, ExpandingExpression.getValuesFromVariables(), ExpandingExpression.verboseStderrLogger)
146+
: new MathExpression(ex);
147+
r = exp.solve();
148+
} catch (Exception fatal) {
149+
if (verbose) {
130150
throw fatal;
131151
} else {
132152
r = fatal.getMessage();
@@ -145,10 +165,10 @@ static void help() {
145165
System.out.println(" Logical expression parser is much less evolved and slow. Do not use it if you don't must");
146166
System.out.println(" If you use logical parse, result is always true/false. If it is not understood, it reuslts to false");
147167
System.out.println(expandableSwitch + " Will add expandable parser around logical expression to allow you to work with sets and views on those sets");
148-
System.out.println(" by "+ ExpandingExpression.VALUES_PNG + "/" + ExpandingExpression.VALUES_IPNG + "variables you can pass in the set of numbers");
168+
System.out.println(" by " + ExpandingExpression.VALUES_PNG + "/" + ExpandingExpression.VALUES_IPNG + "variables you can pass in the set of numbers");
149169
System.out.println(" and access them by L0,L1,,, L1.. ..L2 L3,..L5 notations (set is space delimited)");
150170
System.out.println(" you can calculate dynamic indexes by L{expression} and use MN variable which stores length of input set");
151-
System.out.println(" Expandable parser is not natural by CLI usage. using directly "+ExpandingExpression.class.getName() + " is better, but CLI is crucial for testing expressions");
171+
System.out.println(" Expandable parser is not natural by CLI usage. using directly " + ExpandingExpression.class.getName() + " is better, but CLI is crucial for testing expressions");
152172
System.out.println(trimSwitch + " by default, each line is one expression,");
153173
System.out.println(" however for better redability, sometimes it is worthy to");
154174
System.out.println(" to split the expression to multiple lines. and evaluate as one.");
@@ -246,9 +266,8 @@ public static void setExpandable(boolean expandable) {
246266
Main.expandable = expandable;
247267
}
248268

249-
public static String getVersion() {
250-
//todo, read from pom. See JRD how we did it
251-
return "0.1.9";
269+
public static String getVersion() {
270+
return RuntimeVersion.getVersion();
252271
}
253272

254273
public static MultiSwitch getLogcalSwitch() {

0 commit comments

Comments
 (0)