Skip to content

Commit

Permalink
Remove JSON writer/parser
Browse files Browse the repository at this point in the history
  • Loading branch information
cprudhom committed Jan 21, 2020
1 parent 162f533 commit 7d91440
Show file tree
Hide file tree
Showing 41 changed files with 10 additions and 7,303 deletions.
100 changes: 0 additions & 100 deletions parsers/JSON.md

This file was deleted.

5 changes: 2 additions & 3 deletions parsers/README.md
Expand Up @@ -16,20 +16,19 @@ and to import a JSON format file into a `Model`.
* [MiniZinc](./MINIZINC.md)
* [XCSP3](XCSP3.md)
* [MPS](MPS.md)
* [JSON](JSON.md)


<a name="par"></a>
### Parsing a file

By default, the extension of a file helps choosing the accurate parser.
Thus, any supported file (FlatZinc, XCSP3, MPS or JSON) can be parsed and solved using the following command:
Thus, any supported file (FlatZinc, XCSP3 or MPS) can be parsed and solved using the following command:

```java -jar .:/path/to/choco-parsers-4.0.5-with-dependencies.jar [options] <file>```

Only the file name is mandatory.
Alternatively, if the file has no explicit extension, the option ```-pa``` followed a digit between 1 and 4
can be declared to specify the parser to use; 1: FlatZinc, 2: XCSP3, 3: MPS and 4: JSON.
can be declared to specify the parser to use; 1: FlatZinc, 2: XCSP3 and 3: MPS.

A Bash file named ```parse.sh``` can also be found in `./src/main/bash/` that handles basic options.

Expand Down
6 changes: 0 additions & 6 deletions parsers/pom.xml
Expand Up @@ -77,12 +77,6 @@
<version>3.16</version>
<scope>test</scope>
</dependency>
<!-- Gson: Java to Json conversion -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
</dependency>
</dependencies>

<build>
Expand Down
112 changes: 0 additions & 112 deletions parsers/src/main/bash/json-exec.sh

This file was deleted.

2 changes: 0 additions & 2 deletions parsers/src/main/bash/release.sh
Expand Up @@ -41,10 +41,8 @@ sedInPlace "s%Copyright.*.%Copyright (c) $YEAR, IMT Atlantique%" LICENSE
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" README.md
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" MINIZINC.md
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" XCSP3.md
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" JSON.md
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" ./src/main/bash/fzn-exec.sh
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" ./src/main/bash/xcsp3-exec
sedInPlace "s%choco-parsers-.*-with-dependencies.jar%choco-parsers-${VERSION}-with-dependencies.jar%" ./src/main/bash/json-exec.sh
#Update the poms:wq
mvn versions:set -DnewVersion=${VERSION} -DgenerateBackupPoms=false || quit "unable to set new version"
mvn license:format || quit "unable to format the license"
Expand Down
2 changes: 0 additions & 2 deletions parsers/src/main/java/module-info.java
Expand Up @@ -20,12 +20,10 @@
requires choco.geost;
requires xcsp3.tools;
requires args4j;
requires gson;
requires java.sql;
requires antlr4.runtime;
requires trove4j;

opens org.chocosolver.parser to args4j;
opens org.chocosolver.parser.mps to args4j;
opens org.chocosolver.parser.json to testng;
}
16 changes: 7 additions & 9 deletions parsers/src/main/java/org/chocosolver/parser/Parser.java
Expand Up @@ -10,7 +10,7 @@
package org.chocosolver.parser;

import org.chocosolver.parser.flatzinc.ChocoFZN;
import org.chocosolver.parser.json.ChocoJSON;
import org.chocosolver.parser.mps.ChocoMPS;
import org.chocosolver.parser.xcsp.ChocoXCSP;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
Expand All @@ -33,8 +33,7 @@ public class Parser {
"0: automatic -- based on file name extension (compression is allowed), " +
"1: FlatZinc (.fzn)," +
"2: XCSP3 (.xml)," +
"3: MPS (.mps)," +
"4: JSON (.json).")
"3: MPS (.mps)")
private int pa = 0;

public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -62,17 +61,16 @@ private void main0(String[] args) throws Exception {
}
if (pa == 0) {
String[] parts = instance.split("\\.");
int i = parts.length - 1;
while (i >= 0) {
if (parts[i].equals("fzn")) {
for (String part : parts) {
if (part.equals("fzn")) {
pa = 1;
break;
}
if (parts[i].equals("xml")) {
if (part.equals("xml")) {
pa = 2;
break;
}
if (parts[i].equals("json")) {
if (part.equals("mps")) {
pa = 3;
break;
}
Expand All @@ -85,7 +83,7 @@ private void main0(String[] args) throws Exception {
ChocoXCSP.main(args);
break;
case 3:
ChocoJSON.main(args);
ChocoMPS.main(args);
break;
}
}
Expand Down
28 changes: 0 additions & 28 deletions parsers/src/main/java/org/chocosolver/parser/json/ChocoJSON.java

This file was deleted.

0 comments on commit 7d91440

Please sign in to comment.