src/main/java/org/semgus/java/Main.java
public static void main(String[] args) throws IOException, ParseException, DeserializationException {
        // check CLI args
        if (args.length != 1) {
            System.err.println("Usage: semgus-java <spec-json>");
            System.exit(1);
        }
        Path specFile = Paths.get(args[0]);

        // check if it's stream mode or batch mode JSON by checking the first non-space character
        boolean stream = true;
        try (BufferedReader specJsonReader = Files.newBufferedReader(specFile)) {
            int chr;
            while ((chr = specJsonReader.read()) != 0) {
                if (!Character.isSpaceChar(chr)) {
                    if (chr == '[') { // if it's a [, it must be a JSON array, and so it's in batch mode
                        stream = false;
                    }
                    break;
                }
            }
        }

        // parse the problem
        SemgusProblem problem;
        try (BufferedReader specJsonReader = Files.newBufferedReader(Paths.get(args[0]))) {
            if (stream) { // stream mode: each line is an event
                List<SpecEvent> events = new ArrayList<>();
                String eventJson;
                while ((eventJson = specJsonReader.readLine()) != null) {
                    eventJson = eventJson.trim();
                    if (eventJson.isEmpty()) {
                        continue;
                    }
                    events.add(EventParser.parseEvent(eventJson));
                }
                problem = ProblemGenerator.fromEvents(events);
            } else { // batch mode: it's a big JSON array
                problem = ProblemGenerator.parse(specJsonReader);
            }
        }

        // dump the problem to stdout
        System.out.println(problem.dump());
    }
/**
     * Entry point: reads a JSON document, parses it as a SemGuS JSON specification, and dumps it to standard output.
     *
     * @param args CLI args
     * @throws IOException              If I/O fails.
     * @throws ParseException           if the JSON document is malformed.
     * @throws DeserializationException If the JSON document is not a valid SemGuS JSON specification.
     */
Entry point: reads a JSON document, parses it as a SemGuS JSON specification, and dumps it to standard output.
@param args CLI args
@throws IOException              If I/O fails.
@throws ParseException           if the JSON document is malformed.
@throws DeserializationException If the JSON document is not a valid SemGuS JSON specification.
Entry point : reads a JSON document parses it as a SemGuS JSON specification and dumps it to standard output . @param args CLI args @throws IOException If I / O fails . @throws ParseException if the JSON document is malformed . @throws DeserializationException If the JSON document is not a valid SemGuS JSON specification .
public static void main(String[] args) throws IOException, ParseException, DeserializationException {
        if (args.length != 1) {
            System.err.println("Usage: semgus-java <spec-json>");
            System.exit(1);
        }
        Path specFile = Paths.get(args[0]);
        boolean stream = true;
        try (BufferedReader specJsonReader = Files.newBufferedReader(specFile)) {
            int chr;
            while ((chr = specJsonReader.read()) != 0) {
                if (!Character.isSpaceChar(chr)) {
                    if (chr == '[') { 
                        stream = false;
                    }
                    break;
                }
            }
        }
        SemgusProblem problem;
        try (BufferedReader specJsonReader = Files.newBufferedReader(Paths.get(args[0]))) {
            if (stream) { 
                List<SpecEvent> events = new ArrayList<>();
                String eventJson;
                while ((eventJson = specJsonReader.readLine()) != null) {
                    eventJson = eventJson.trim();
                    if (eventJson.isEmpty()) {
                        continue;
                    }
                    events.add(EventParser.parseEvent(eventJson));
                }
                problem = ProblemGenerator.fromEvents(events);
            } else { 
                problem = ProblemGenerator.parse(specJsonReader);
            }
        }
        System.out.println(problem.dump());
    }
public static void main ( String [ ] args ) throws IOException , ParseException , DeserializationException { if ( args . length != 1 ) { System . err . println ( "Usage: semgus-java <spec-json>" ) ; System . exit ( 1 ) ; } Path specFile = Paths . get ( args [ 0 ] ) ; boolean stream = true ; try ( BufferedReader specJsonReader = Files . newBufferedReader ( specFile ) ) { int chr ; while ( ( chr = specJsonReader . read ( ) ) != 0 ) { if ( ! Character . isSpaceChar ( chr ) ) { if ( chr == '[' ) { stream = false ; } break ; } } } SemgusProblem problem ; try ( BufferedReader specJsonReader = Files . newBufferedReader ( Paths . get ( args [ 0 ] ) ) ) { if ( stream ) { List < SpecEvent > events = new ArrayList < > ( ) ; String eventJson ; while ( ( eventJson = specJsonReader . readLine ( ) ) != null ) { eventJson = eventJson . trim ( ) ; if ( eventJson . isEmpty ( ) ) { continue ; } events . add ( EventParser . parseEvent ( eventJson ) ) ; } problem = ProblemGenerator . fromEvents ( events ) ; } else { problem = ProblemGenerator . parse ( specJsonReader ) ; } } System . out . println ( problem . dump ( ) ) ; }
Entry point: reads a JSON document, parses it as a SemGuS JSON specification, and dumps it to standard output.
Entry point : reads a JSON document parses it as a SemGuS JSON specification and dumps it to standard output .
// check CLI args // check if it's stream mode or batch mode JSON by checking the first non-space character // if it's a [, it must be a JSON array, and so it's in batch mode // parse the problem // stream mode: each line is an event // batch mode: it's a big JSON array // dump the problem to stdout